@kanonak-protocol/sdk 3.52.0 → 3.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/chunk-7O76F4TH.js +148 -0
- package/dist/{chunk-XHCSTAUK.js → chunk-BSJ6PEKE.js} +1 -1
- package/dist/{chunk-HMDTGNEA.js → chunk-CYDDQF6S.js} +1 -1
- package/dist/{chunk-DGR77PRS.js → chunk-SD5QKNBC.js} +1 -1
- package/dist/chunk-VJT6YUWK.js +1 -0
- package/dist/{chunk-B7QSKW7E.js → chunk-WDQONH3P.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/look/LookRenderer.d.ts +246 -31
- package/dist/markdown/MarkdownRenderer.d.ts +10 -1
- package/dist/markdown/highlight.d.ts +42 -0
- package/dist/parsing/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/server/index.js +2 -2
- package/dist/transformations/index.js +1 -1
- package/dist/validation/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-2WQR7OHH.js +0 -116
- package/dist/chunk-YYFIJNSP.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as R}from"./chunk-
|
|
1
|
+
import{c as R}from"./chunk-VJT6YUWK.js";import{c as S}from"./chunk-H2LEQLVD.js";import{a as h}from"./chunk-N224PFBI.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};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as ct,b as lt,c as dt,d as ut,e as pt}from"./chunk-
|
|
1
|
+
import{a as ct,b as lt,c as dt,d as ut,e as pt}from"./chunk-SD5QKNBC.js";import{a as or,c as ar}from"./chunk-7O76F4TH.js";import{a as at,b as it,c as st,d as b,e as S,f as i}from"./chunk-WDQONH3P.js";import{a as nr}from"./chunk-IIODYDKS.js";import"./chunk-3NEUHF7E.js";import{a as Te,b as je,c as Le,d as Fe,e as De,f as Ue,g as Ve,h as He}from"./chunk-H673KOGN.js";import{a as Ie,b as Ne,c as Oe,d as Ae}from"./chunk-VHUJSHH7.js";import{a as ft,b as yt,c as gt,d as ht}from"./chunk-CYDDQF6S.js";import{a as kt,b as $t}from"./chunk-DC774EQL.js";import{a as Ct}from"./chunk-NIGFQYVA.js";import{A as Qt,B as er,C as tr,E as rr,a as vt,b as Et,c as Kt,d as It,e as Bt,f as Tt,g as jt,h as Lt,i as Ft,j as Dt,k as Nt,l as Ot,m as At,n as Ut,o as Vt,p as Ht,q as Mt,r as _t,s as zt,t as Gt,u as Wt,v as Jt,w as qt,x as Yt,y as Xt,z as Zt}from"./chunk-BSJ6PEKE.js";import{a as tt,b as rt,c as nt}from"./chunk-VJT6YUWK.js";import{a as F,b as N,c as We}from"./chunk-H2LEQLVD.js";import{a as Be}from"./chunk-7CUTGGH3.js";import{a as ot,b as bt,c as St,d as Pt,e as Rt,f as wt,g as xt}from"./chunk-N224PFBI.js";import"./chunk-Q4DKP5DO.js";import{a as Pe,b as Re,c as we,d as xe,e as $e,f as ve,g as Ee,h as Ke}from"./chunk-FQHALFRR.js";import{b as Je,c as qe,d as Ye,e as Xe,f as Ze,h as Qe,j as et}from"./chunk-64TVBQFR.js";import{a as Me,b as j,c as L,d as D,e as ze,f as Ge,g as O,h as A,i as U,j as V,k as H,l as M}from"./chunk-W6T7MOKY.js";import{a as _e}from"./chunk-FUUTGGJS.js";import{a as mt}from"./chunk-ODIECDN7.js";import{VersionOperator as yo}from"@kanonak-protocol/types/document/models/enums";import{existsSync as Rr,readFileSync as wr}from"fs";import{homedir as xr}from"os";import{join as $r}from"path";import{execFile as ir}from"child_process";import{promisify as sr}from"util";var C=sr(ir),P="kanonak",R="/usr/bin/security",p=class{async get(e){let r=i(e);try{let{stdout:n}=await C(R,["find-generic-password","-s",P,"-a",r,"-w"],{timeout:1e4});try{return JSON.parse(n.trim())}catch{throw new Error(`Stored credential for '${r}' is corrupted (not valid JSON).
|
|
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)}
|
|
@@ -40,6 +40,8 @@ export interface ResolvedLook {
|
|
|
40
40
|
export declare class LookRenderer {
|
|
41
41
|
private readonly catalog;
|
|
42
42
|
constructor(catalog: Kanonak[]);
|
|
43
|
+
/** Lazily-built syntax highlighter, sourced from the catalog's grammars. */
|
|
44
|
+
private _codeHighlighter?;
|
|
43
45
|
/**
|
|
44
46
|
* Walk the instance's type chain (BFS) looking for the first class
|
|
45
47
|
* that declares `derivation.look`. Checks the instance itself first
|
|
@@ -49,6 +51,16 @@ export declare class LookRenderer {
|
|
|
49
51
|
* declares one.
|
|
50
52
|
*/
|
|
51
53
|
findCascadedLook(instance: SubjectKanonak): ResolvedLook | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Resolve a cascaded look by walking a type queue (BFS through
|
|
56
|
+
* `subClassOf`), version-agnostically, then the `rdfs.Resource` floor.
|
|
57
|
+
* Shared by `findCascadedLook` (seeded from an instance's declared
|
|
58
|
+
* types) and `renderEmbeddedViews` (seeded from an item's inferred
|
|
59
|
+
* range type when the item carries no explicit `rdf:type` — embedded
|
|
60
|
+
* objects are typed by the containing property's range, not a literal
|
|
61
|
+
* type statement).
|
|
62
|
+
*/
|
|
63
|
+
private lookFromTypeRefs;
|
|
52
64
|
/**
|
|
53
65
|
* Walk the instance's type chain merging token declarations by key.
|
|
54
66
|
* Closer-to-instance wins; tokens from different keys merge cleanly.
|
|
@@ -149,6 +161,15 @@ export declare class LookRenderer {
|
|
|
149
161
|
* Render the instance as body-only HTML using its cascaded look.
|
|
150
162
|
*/
|
|
151
163
|
renderHtml(instance: SubjectKanonak): string;
|
|
164
|
+
/**
|
|
165
|
+
* Wrap a band's HTML in a float container when it declares `look.placement`
|
|
166
|
+
* (floatLeft / floatRight) so the FOLLOWING band's prose flows around it —
|
|
167
|
+
* a magazine-style article layout, done in the HTML layer (the band's own
|
|
168
|
+
* SVG/HTML stays an opaque block; native text reflow does the wrapping).
|
|
169
|
+
* `look.width` (a CSS length, default 42%) sizes the float; an unsafe width
|
|
170
|
+
* is ignored. Applies to any visual band, not just diagrams.
|
|
171
|
+
*/
|
|
172
|
+
private applyBandPlacement;
|
|
152
173
|
/**
|
|
153
174
|
* Scan a view's bands for SectionHeading bands, returning each section's
|
|
154
175
|
* anchor slug and label in document order — the table of contents a
|
|
@@ -167,19 +188,16 @@ export declare class LookRenderer {
|
|
|
167
188
|
* appear without authors needing a custom look.Figure band.
|
|
168
189
|
*/
|
|
169
190
|
/**
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
191
|
+
* The Publisher resource for a domain — the single configuration point for
|
|
192
|
+
* a publisher's presentation: its `derivation.look` is the landing
|
|
193
|
+
* PublisherView (default on `ck.Publisher` in universal-look) and its nav
|
|
194
|
+
* is the site nav. Returns an authored `ck.Publisher` resource in the
|
|
195
|
+
* publisher's namespace when present; otherwise synthesizes a minimal one
|
|
196
|
+
* (`rdfs.label` = the domain) so the publisher root ALWAYS renders through
|
|
197
|
+
* the normal look cascade — the same path as any other resource page, no
|
|
198
|
+
* special-case index renderer.
|
|
175
199
|
*/
|
|
176
|
-
|
|
177
|
-
label: string;
|
|
178
|
-
href: string;
|
|
179
|
-
comment?: string;
|
|
180
|
-
}>, tokenSource: SubjectKanonak | undefined): string;
|
|
181
|
-
/** Stylesheet for the publisher index — the cascaded tokens + base CSS. */
|
|
182
|
-
renderPublisherIndexStylesheet(tokenSource: SubjectKanonak | undefined): string;
|
|
200
|
+
publisherSubject(publisher: string): SubjectKanonak;
|
|
183
201
|
/**
|
|
184
202
|
* True when the instance has a look declaration closer than the
|
|
185
203
|
* rdfs.Resource floor — i.e. an instance-level or class-level view
|
|
@@ -252,6 +270,110 @@ export declare class LookRenderer {
|
|
|
252
270
|
* at the figure's rendered width.
|
|
253
271
|
*/
|
|
254
272
|
private renderFigure;
|
|
273
|
+
/**
|
|
274
|
+
* Render a Diagram band — a relationship diagram derived from the page
|
|
275
|
+
* instance. Each `look.facets` entry traverses a `relation` property to a
|
|
276
|
+
* set of node instances and renders them per its `encode` role. v1 supports
|
|
277
|
+
* the `cluster` role (a grouped set of identity tiles); other roles emit a
|
|
278
|
+
* visible diagnostic until implemented (no silent fallback, per the
|
|
279
|
+
* no-mocks rule). Relation/encode are resolved through the object model —
|
|
280
|
+
* statements are matched by the property's canonical URI, never by name.
|
|
281
|
+
*/
|
|
282
|
+
/** Per-page counter so each diagram's arrowhead marker gets a unique id. */
|
|
283
|
+
private diagramArrowSeq;
|
|
284
|
+
/** Per-page guard so the zoom/modal client script is emitted only once. */
|
|
285
|
+
private diagramScriptEmitted;
|
|
286
|
+
private renderDiagram;
|
|
287
|
+
/**
|
|
288
|
+
* Render a tile figure at ALL FOUR tiers into one container (the declared
|
|
289
|
+
* `active` tier visible, the other three `hidden`). The zoom modal toggles
|
|
290
|
+
* which is shown to snap through detail levels — entirely client-side, so it
|
|
291
|
+
* works on static hosting with no server round-trip. The node `.svg` images
|
|
292
|
+
* are shared across the four, so only the small wrapper markup is duplicated.
|
|
293
|
+
*/
|
|
294
|
+
private embedTiers;
|
|
295
|
+
/**
|
|
296
|
+
* Render an `expand` facet — each node recurses into the named sub-diagram
|
|
297
|
+
* `expandDiagram`, nested under the node's identity tile. Recursion is
|
|
298
|
+
* bounded by two guards: a cycle guard (the node is already on the expansion
|
|
299
|
+
* path) and a max-depth guard; when either trips, the node collapses to its
|
|
300
|
+
* identity tile with no sub-diagram. The `visited` set is per-PATH (copied
|
|
301
|
+
* with the node added on each descent), so a node may appear in sibling
|
|
302
|
+
* branches — only its own ancestry stops it. Deterministic, no DOM.
|
|
303
|
+
*/
|
|
304
|
+
private renderDiagramExpand;
|
|
305
|
+
/**
|
|
306
|
+
* A node's identity tile + label as one inline, linked row (for tree rows).
|
|
307
|
+
* `notePath` adds a small secondary line of ontology-driven context (e.g. a
|
|
308
|
+
* weight or short description resolved off the node).
|
|
309
|
+
*/
|
|
310
|
+
private diagramNodeRow;
|
|
311
|
+
/**
|
|
312
|
+
* The node tile size implied by the nodes' class-declared `look.diagramTier`,
|
|
313
|
+
* or undefined when none declare one. If node classes disagree, the larger
|
|
314
|
+
* tier wins (so detail isn't lost). Layout stays uniform (one size per facet);
|
|
315
|
+
* true per-node heterogeneous sizing is a later refinement.
|
|
316
|
+
*/
|
|
317
|
+
private classTierSize;
|
|
318
|
+
/** Resolve a facet's `relation` property on the instance to node subjects. */
|
|
319
|
+
private resolveFacetNodes;
|
|
320
|
+
/**
|
|
321
|
+
* Resolve a facet's quantitative channels. Each `look.channels` entry reads
|
|
322
|
+
* a numeric off every node via its `mapPath` (the same `/`-path syntax as
|
|
323
|
+
* Distribution's metricPath) and auto-scales it linearly across the node
|
|
324
|
+
* set's observed [min, max] → a per-node value in [0, 1]. Nodes whose value
|
|
325
|
+
* is absent/non-numeric normalize to 0.5 (mid). Returns one entry per
|
|
326
|
+
* channel with its target visual variable (`to`) and the normalized values.
|
|
327
|
+
*/
|
|
328
|
+
private resolveFacetChannels;
|
|
329
|
+
/**
|
|
330
|
+
* The label to draw on a facet's edges. An explicit `edgeLabel` wins; else,
|
|
331
|
+
* when `labelEdges` is true, the edge predicate's own `rdfs.label` is used —
|
|
332
|
+
* ontology-driven edge labels. Returns undefined when neither applies (edges
|
|
333
|
+
* stay unlabeled, the default — avoids clutter on same-relation fans).
|
|
334
|
+
*/
|
|
335
|
+
private facetEdgeLabel;
|
|
336
|
+
/** Assemble an edge's label: static `edgeLabel` plus a per-edge dynamic value
|
|
337
|
+
* (resolved from `valuePath` on the given node), e.g. "weighs on" + "0.82". */
|
|
338
|
+
private edgeText;
|
|
339
|
+
/** A label chip (with a token-colored halo for legibility) at an edge midpoint. */
|
|
340
|
+
private edgeLabelEl;
|
|
341
|
+
/**
|
|
342
|
+
* Render a `cluster` facet — the node subjects as a grid of their own
|
|
343
|
+
* SemanticSvg identity tiles in one content-sized SVG. Each tile links to
|
|
344
|
+
* the node's resource page. Deterministic layout: fixed tile boxes wrapped
|
|
345
|
+
* into rows (node tiles have known size, so no DOM measurement is needed).
|
|
346
|
+
* An `opacity` channel fades each tile by its scaled value.
|
|
347
|
+
*/
|
|
348
|
+
private renderDiagramCluster;
|
|
349
|
+
/**
|
|
350
|
+
* Render a `connector` facet — a hub-and-spoke diagram with the page
|
|
351
|
+
* instance as the central hub and each related node as a spoke, joined by a
|
|
352
|
+
* directed edge. The canonical architecture-graph encoding: "this instance
|
|
353
|
+
* relates to these, via this relationship." Two-rank layered layout (hub
|
|
354
|
+
* left, spokes column right) with curved edges + arrowheads. Deterministic:
|
|
355
|
+
* fixed tile sizes, no DOM measurement. Edge/arrow colors use look tokens so
|
|
356
|
+
* they stay theme-aware without a dedicated stylesheet rule.
|
|
357
|
+
*/
|
|
358
|
+
private renderDiagramConnector;
|
|
359
|
+
/**
|
|
360
|
+
* An arrowhead marker whose BACK (x=0) is the reference point, so a path's
|
|
361
|
+
* end meets the back of the triangle and the tip points forward along the
|
|
362
|
+
* line. userSpaceOnUse keeps it a fixed size regardless of stroke width.
|
|
363
|
+
*/
|
|
364
|
+
private arrowMarkerDef;
|
|
365
|
+
/**
|
|
366
|
+
* Render a `connector` facet with an `edges` predicate as a layered DAG:
|
|
367
|
+
* nodes ranked left-to-right by dependency order, with a directed edge per
|
|
368
|
+
* `nodeA <edges> nodeB` statement (both ends in the node set). Ranking is a
|
|
369
|
+
* cycle-tolerant longest-path layering (a back-edge into a node already on
|
|
370
|
+
* the DFS stack contributes rank 0, breaking the cycle); back-edges still
|
|
371
|
+
* render, so a cycle is visible as an edge curving leftward. Deterministic,
|
|
372
|
+
* no DOM. An optional `thickness` channel sizes edges by their source node.
|
|
373
|
+
*/
|
|
374
|
+
private renderDiagramDag;
|
|
375
|
+
/** One node tile: its identity SVG as an `<image>`, linked, with a title. */
|
|
376
|
+
private diagramTile;
|
|
255
377
|
/**
|
|
256
378
|
* Render a StatRow band — a strip of labeled stats. `look.stats` is a
|
|
257
379
|
* list of Stat specs, each with a `statLabel` and a `statPath` (the same
|
|
@@ -326,6 +448,31 @@ export declare class LookRenderer {
|
|
|
326
448
|
*/
|
|
327
449
|
private detailReferenceLink;
|
|
328
450
|
private detailEmbedded;
|
|
451
|
+
/**
|
|
452
|
+
* The `rdfs:range` of a property, as a single-element type-ref list (for
|
|
453
|
+
* seeding the look cascade for range-typed embedded objects). Empty when
|
|
454
|
+
* the property or its range can't be resolved.
|
|
455
|
+
*/
|
|
456
|
+
private rangeTypeRefs;
|
|
457
|
+
/**
|
|
458
|
+
* Render an EmbeddedViews band: each embedded item of `look.source` is
|
|
459
|
+
* rendered through ITS OWN class look — the same type-chain cascade page
|
|
460
|
+
* instances use — so a document-tree ontology (Protocol → Convention →
|
|
461
|
+
* Rule) composes readable nested sections instead of collapsing into one
|
|
462
|
+
* generic recursive sheet. Items whose class declares no look fall
|
|
463
|
+
* through to the rdfs.Resource floor (Hero + Details), so every item
|
|
464
|
+
* still renders sensibly. Non-embedded values are skipped (use
|
|
465
|
+
* PropertyList / ReferenceList for scalars and references). Recursion is
|
|
466
|
+
* bounded by the data's embedding depth.
|
|
467
|
+
*/
|
|
468
|
+
private renderEmbeddedViews;
|
|
469
|
+
/**
|
|
470
|
+
* A small "copy this link" anchor. Its href is the in-page fragment, so
|
|
471
|
+
* clicking puts the full deep URL in the address bar and right-click →
|
|
472
|
+
* Copy Link Address yields the exact URL for this embedded resource. The
|
|
473
|
+
* fragment is shown in the tooltip.
|
|
474
|
+
*/
|
|
475
|
+
private anchorLink;
|
|
329
476
|
/** Predicates surfaced by other bands (or look-layer meta) — skipped by Details. */
|
|
330
477
|
private isMetaPredicate;
|
|
331
478
|
/**
|
|
@@ -349,6 +496,31 @@ export declare class LookRenderer {
|
|
|
349
496
|
* cannot.
|
|
350
497
|
*/
|
|
351
498
|
private renderReferencedBy;
|
|
499
|
+
/**
|
|
500
|
+
* One resource card: a main link (SemanticSvg + label + truncated summary)
|
|
501
|
+
* to the resource, plus a subtle, hover-revealed footer linking to the
|
|
502
|
+
* resource's package, with the version as a pill — `package@version`. The
|
|
503
|
+
* card is a container (not a single `<a>`) so the package footer can be a
|
|
504
|
+
* real sibling link (nested `<a>`s are invalid). Both links are
|
|
505
|
+
* same-publisher-gated.
|
|
506
|
+
*/
|
|
507
|
+
private resourceCard;
|
|
508
|
+
/**
|
|
509
|
+
* Render an Instances band — the resources whose `rdf:type` is the page
|
|
510
|
+
* resource (a class). DIRECT by default (exact type); `look.transitive:
|
|
511
|
+
* true` widens to instances of subclasses too (the subclass closure) —
|
|
512
|
+
* which is why direct is the default, since transitive on rdfs.Resource
|
|
513
|
+
* would be every resource. Deduped to the highest version per canonical
|
|
514
|
+
* key, capped (with a total count), and self-suppressing when the
|
|
515
|
+
* resource is not a class or has no instances.
|
|
516
|
+
*/
|
|
517
|
+
private renderInstances;
|
|
518
|
+
/**
|
|
519
|
+
* The set of canonical class keys covered by `target` plus every class
|
|
520
|
+
* that is (transitively) a subclass of it — used for transitive instance
|
|
521
|
+
* matching. Iterates to a fixpoint over the catalog's subClassOf edges.
|
|
522
|
+
*/
|
|
523
|
+
private subclassClosure;
|
|
352
524
|
/**
|
|
353
525
|
* True if `subject` has a reference (in a ReferenceStatement or a
|
|
354
526
|
* ListStatement) whose target's canonical key equals `targetKey`. When
|
|
@@ -373,20 +545,18 @@ export declare class LookRenderer {
|
|
|
373
545
|
*/
|
|
374
546
|
private renderDistribution;
|
|
375
547
|
/**
|
|
376
|
-
* Render a PublisherPackages band — a grid of
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
548
|
+
* Render a PublisherPackages band — a grid of package cards, each
|
|
549
|
+
* linking to its bare `/{package}` overview with the package's
|
|
550
|
+
* SemanticSvg + label + truncated comment. Powers the discovery
|
|
551
|
+
* section of a publisher root view.
|
|
552
|
+
*
|
|
553
|
+
* By default it enumerates every package the context publisher
|
|
554
|
+
* authors (latest version of each, alphabetical). When the band
|
|
555
|
+
* declares an explicit `look.packages` list, it instead features
|
|
556
|
+
* exactly those packages, in author order — each reference resolved
|
|
557
|
+
* to its package's latest self-resource.
|
|
380
558
|
*/
|
|
381
559
|
private renderPublisherPackages;
|
|
382
|
-
/**
|
|
383
|
-
* Find the resource that declares the publisher's root view — a resource
|
|
384
|
-
* authored by `publisher` whose instance-level derivation.look is a
|
|
385
|
-
* PublisherView. Returned to the publish step so it can render the root
|
|
386
|
-
* view at `/` instead of the default package index. Undefined when the
|
|
387
|
-
* publisher declares none.
|
|
388
|
-
*/
|
|
389
|
-
findPublisherRootView(publisher: string): SubjectKanonak | undefined;
|
|
390
560
|
private renderTimeline;
|
|
391
561
|
/**
|
|
392
562
|
* Render the Timeline trajectory chart — a server-rendered inline SVG with
|
|
@@ -411,7 +581,6 @@ export declare class LookRenderer {
|
|
|
411
581
|
* compact variant") is deferred — that requires a variant system.
|
|
412
582
|
*/
|
|
413
583
|
private renderResourceGrid;
|
|
414
|
-
private parseVersion;
|
|
415
584
|
/**
|
|
416
585
|
* Find every SubjectKanonak in the catalog whose declared `rdf:type` set
|
|
417
586
|
* includes the given class URI (canonical, version-agnostic). Used by
|
|
@@ -438,6 +607,14 @@ export declare class LookRenderer {
|
|
|
438
607
|
* resource reference (use the target's `rdfs.label`, urlForm `*`).
|
|
439
608
|
*/
|
|
440
609
|
private renderNavGroup;
|
|
610
|
+
/**
|
|
611
|
+
* Render the site-wide footer, shown on every page. Like nav, it is the
|
|
612
|
+
* `footer` (a `look.Footer`) declared on the publisher's
|
|
613
|
+
* core-kanonak.Publisher resource — the single config point. The Footer
|
|
614
|
+
* carries optional literal `text` (license/copyright) and an optional
|
|
615
|
+
* list of `links` (NavLinks). Returns empty when no footer is declared.
|
|
616
|
+
*/
|
|
617
|
+
private renderSiteFooter;
|
|
441
618
|
/**
|
|
442
619
|
* Resolve a nav entry to (href, label). NavLink resources contribute
|
|
443
620
|
* their explicit label + target; direct references read the target's
|
|
@@ -445,16 +622,31 @@ export declare class LookRenderer {
|
|
|
445
622
|
*/
|
|
446
623
|
private resolveNavEntry;
|
|
447
624
|
/**
|
|
448
|
-
*
|
|
449
|
-
* `
|
|
625
|
+
* The catalog-sourced code highlighter (built once). Every
|
|
626
|
+
* `code-grammars.CodeGrammar` in the catalog becomes a grammar spec;
|
|
627
|
+
* the generic scanner in highlight.ts applies them. Returns the SDK
|
|
628
|
+
* mechanism wired to graph-declared intent — no language is hardcoded
|
|
629
|
+
* here.
|
|
450
630
|
*/
|
|
451
|
-
private
|
|
631
|
+
private codeHighlighter;
|
|
632
|
+
/** Read every CodeGrammar resource in the catalog into a grammar spec. */
|
|
633
|
+
private collectGrammars;
|
|
634
|
+
/**
|
|
635
|
+
* Render a Links band — the resource's outbound links (the
|
|
636
|
+
* `links.links` property named by `look.source`) as a row of real
|
|
637
|
+
* `<a href>` anchors. Each value is a `links.Link`, embedded inline or
|
|
638
|
+
* referenced, read for its `url`, label (rdfs.label → the link text)
|
|
639
|
+
* and comment (rdfs.comment → the hover title). Renders nothing when
|
|
640
|
+
* the resource has no links, so it is safe on the universal floor.
|
|
641
|
+
*/
|
|
642
|
+
private renderLinks;
|
|
452
643
|
/**
|
|
453
644
|
* Render a Markdown band — reads the property identified by
|
|
454
645
|
* `look.source` from the instance and pipes its string value through
|
|
455
|
-
* the SDK's minimal CommonMark renderer
|
|
456
|
-
* `<section class="kan-markdown">`
|
|
457
|
-
* prose block without bleeding into
|
|
646
|
+
* the SDK's minimal CommonMark renderer (with catalog-driven code
|
|
647
|
+
* highlighting). Wraps the result in a `<section class="kan-markdown">`
|
|
648
|
+
* so stylesheets can target the prose block without bleeding into
|
|
649
|
+
* other bands.
|
|
458
650
|
*/
|
|
459
651
|
private renderMarkdown;
|
|
460
652
|
/**
|
|
@@ -477,6 +669,29 @@ export declare class LookRenderer {
|
|
|
477
669
|
renderRawMarkdown(instance: SubjectKanonak): string | undefined;
|
|
478
670
|
private renderHero;
|
|
479
671
|
private renderPropertyList;
|
|
672
|
+
/**
|
|
673
|
+
* Render `look.source` (a list of dict-keyed embeddeds) as a table:
|
|
674
|
+
* columns are the union of the items' predicate names, one row per item
|
|
675
|
+
* with the item's dict-key as a leading row-header. The source
|
|
676
|
+
* property's label captions the table, and the table is omitted
|
|
677
|
+
* entirely when there are no items (so an empty group leaves no dangling
|
|
678
|
+
* caption). Cells render scalars / markdown / references inline; a cell
|
|
679
|
+
* whose value is itself a list of embeddeds recurses into a nested
|
|
680
|
+
* table, so a document tree (rules holding sub-rules, etc.) stays
|
|
681
|
+
* tabular all the way down.
|
|
682
|
+
*/
|
|
683
|
+
private renderPropertyTable;
|
|
684
|
+
/**
|
|
685
|
+
* Build a `<table>` from a list of embedded resources. Columns are the
|
|
686
|
+
* union of non-meta predicates across the items, in first-seen order;
|
|
687
|
+
* each row is one item (its dict-key as a `<th scope="row">` when
|
|
688
|
+
* present). Recurses for embedded-list cell values.
|
|
689
|
+
*/
|
|
690
|
+
private renderEmbeddedTable;
|
|
691
|
+
/** Render one statement value for a table cell (recurses for embedded lists). */
|
|
692
|
+
private tableCellValue;
|
|
693
|
+
/** Markdown (or plain string) statement → HTML, with [[reference]] links resolved. */
|
|
694
|
+
private statementToMarkdownHtml;
|
|
480
695
|
private renderBadgeRow;
|
|
481
696
|
private renderChipRow;
|
|
482
697
|
private renderReferenceList;
|
|
@@ -14,4 +14,13 @@
|
|
|
14
14
|
* implementation is ever needed, swap this file out — nothing else in
|
|
15
15
|
* the transformation system depends on its internals.
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export interface MarkdownRenderOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Optional syntax highlighter for fenced code blocks. Receives the
|
|
20
|
+
* fence language and the raw code; MUST return HTML-safe output
|
|
21
|
+
* (escaped text + token spans). When absent, code is plain-escaped.
|
|
22
|
+
*/
|
|
23
|
+
highlight?: (language: string, code: string) => string;
|
|
24
|
+
}
|
|
25
|
+
export declare function renderMarkdownToHtml(source: string, options?: MarkdownRenderOptions): string;
|
|
26
|
+
export declare function escapeHtml(s: string): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic, language-neutral syntax-highlighting scanner.
|
|
3
|
+
*
|
|
4
|
+
* This is the MECHANISM half of the declarative-highlighting split: it
|
|
5
|
+
* knows nothing about any particular language. It is handed a set of
|
|
6
|
+
* grammars (each an ordered list of `{ tokenClass, pattern }` rules,
|
|
7
|
+
* authored declaratively in the `code-grammars` packages) and walks a
|
|
8
|
+
* code string left to right, first-match-wins, emitting one
|
|
9
|
+
* `<span class="kan-tok-<class>">` per matched token. The INTENT (which
|
|
10
|
+
* rules, for which language) lives in the graph; the THEME (token
|
|
11
|
+
* colors) lives in the look stylesheet.
|
|
12
|
+
*
|
|
13
|
+
* Scanning is line-oriented: each line is tokenized independently, which
|
|
14
|
+
* keeps single-line constructs (comments, strings, keys, flags) correct
|
|
15
|
+
* and predictable. Multi-line constructs (heredocs, block strings) are
|
|
16
|
+
* not tracked across lines — adequate for the snippets prose carries,
|
|
17
|
+
* and refinable per-grammar later without touching this scanner.
|
|
18
|
+
*/
|
|
19
|
+
export interface TokenRuleSpec {
|
|
20
|
+
/** TokenClass name → becomes the `kan-tok-<class>` CSS class. */
|
|
21
|
+
tokenClass: string;
|
|
22
|
+
/** JavaScript regex source, applied sticky at the scan position. */
|
|
23
|
+
pattern: string;
|
|
24
|
+
}
|
|
25
|
+
export interface CodeGrammarSpec {
|
|
26
|
+
/** Fence info string this grammar highlights, e.g. "yaml". */
|
|
27
|
+
language: string;
|
|
28
|
+
rules: TokenRuleSpec[];
|
|
29
|
+
}
|
|
30
|
+
export declare class CodeHighlighter {
|
|
31
|
+
private byLang;
|
|
32
|
+
constructor(grammars: CodeGrammarSpec[]);
|
|
33
|
+
/** True when a grammar is registered for `language`. */
|
|
34
|
+
has(language: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Highlight `code` for `language`, returning HTML-safe output (every
|
|
37
|
+
* literal character escaped; tokens wrapped in spans). When no grammar
|
|
38
|
+
* is registered for the language, falls back to a plain escaped block.
|
|
39
|
+
*/
|
|
40
|
+
highlight(language: string, code: string): string;
|
|
41
|
+
private highlightLine;
|
|
42
|
+
}
|
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-CYDDQF6S.js";import{c as b}from"../chunk-VJT6YUWK.js";import"../chunk-H2LEQLVD.js";import{a}from"../chunk-7CUTGGH3.js";import"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
|
package/dist/reasoning/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as g,b as h,c as i,d as j,e as k}from"../chunk-
|
|
1
|
+
import{a as g,b as h,c as i,d as j,e as k}from"../chunk-SD5QKNBC.js";import"../chunk-VJT6YUWK.js";import"../chunk-H2LEQLVD.js";import"../chunk-7CUTGGH3.js";import{d as a,e as b,f as c,h as d,i as e,j as f}from"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";export{f as KanonakVocabulary,i as OWL_RL_CLASSIFICATION_RULES,h as RDFS_RULES,k as Reasoner,j as ReasoningResult,g as TripleStore,e as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
|
package/dist/search/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as p}from"../chunk-
|
|
1
|
+
import{a as p}from"../chunk-7O76F4TH.js";import"../chunk-3NEUHF7E.js";import"../chunk-DC774EQL.js";import"../chunk-NIGFQYVA.js";import"../chunk-H2LEQLVD.js";import{d as m,g as x}from"../chunk-N224PFBI.js";import{a as d,f as S}from"../chunk-Q4DKP5DO.js";import{a as v}from"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import{c as j}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{homedir as P}from"os";import{join as k}from"path";import{existsSync as B,mkdirSync as C,readFileSync as D,writeFileSync as O}from"fs";import{createHash as z}from"crypto";var f="Xenova/all-MiniLM-L6-v2",w="q8",b=32,g=null;async function K(){return g||(g=(async()=>{let t;try{t=await import("@huggingface/transformers")}catch(i){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
|
|
2
2
|
Install it with:
|
|
3
3
|
npm install @huggingface/transformers
|
|
4
4
|
(underlying import error: ${i.message})`)}let{pipeline:r,env:n}=t;n.cacheDir=k(P(),".kanonak","models");let e=await r("feature-extraction",f,{dtype:w});return async i=>(await e(i,{pooling:"mean",normalize:!0})).tolist()})()),g}function H(t,r){let n=0;for(let e=0;e<t.length;e++)n+=t[e]*r[e];return n}function U(t,r){return r?t.version?r.version?v(t.version,r.version)>0:!0:!1:!0}function F(t,r){let n=p(t,r),e=[n.label],i=x(r);if(i.length>0){let s=S(t,i[0]),c=s?p(t,s).label:i[0].name;c&&e.push(`\u2014 a ${c}.`)}return n.summary&&e.push(n.summary),e.join(" ")}function M(t){let r=new Map;for(let n of t){if(!(n instanceof j))continue;let e=m(n);if(!e)continue;let i=d(e),s=r.get(i);(!s||U(e,m(s)))&&r.set(i,n)}return[...r.values()].sort((n,e)=>{let i=m(n)?d(m(n)):n.name,s=m(e)?d(m(e)):e.name;return i.localeCompare(s)})}var y=class{entries=[];get size(){return this.entries.length}async build(r,n={}){let e=M(r);if(n.include&&(e=e.filter(n.include)),e.length===0)return this.entries=[],{size:0,cached:!1};let i=e.map(o=>F(r,o)),s=n.cacheDir,c;if(s){let o=z("sha256").update(f+"|"+w+`
|
package/dist/server/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as U}from"../chunk-7O76F4TH.js";import"../chunk-3NEUHF7E.js";import{a as O,d as M,f as I,g as B}from"../chunk-H673KOGN.js";import{a as C,c as W,d as A}from"../chunk-VHUJSHH7.js";import{a as H}from"../chunk-NIGFQYVA.js";import{c as G}from"../chunk-VJT6YUWK.js";import"../chunk-H2LEQLVD.js";import{a as L}from"../chunk-7CUTGGH3.js";import"../chunk-Q4DKP5DO.js";import{a as V,e as E}from"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import{c as T}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{readFileSync as q,existsSync as z,readdirSync as Q,writeFileSync as X,mkdirSync as Z}from"fs";import{join as K}from"path";var ee=["core-kanonak","site","link","look-tokens","look-styles","look","universal-look"];async function re(t,r={}){let o=new L,n=new C(o),s=[],v=[];for(let e of B(t)){let p;try{p=q(e,"utf-8")}catch{continue}let u;try{u=o.parse(p).metadata?.namespace_}catch{continue}if(!u?.version)continue;let k=u.version;v.push({publisher:u.publisher,package_:u.package_,verStr:`${k.major}.${k.minor}.${k.patch}`,version:k,source:p})}v.sort((e,p)=>V(p.version,e.version));for(let e of v)await n.saveDocumentAsync(o.parse(e.source),`${e.publisher}/${e.package_}@${e.verStr}`),s.push({publisher:e.publisher,package_:e.package_,verStr:e.verStr,source:e.source});let h=[...new Set(s.map(e=>e.publisher))].sort(),l=r.publisher;if(l){if(!h.includes(l))throw new Error(`Publisher "${l}" not found in workspace. Available: ${h.join(", ")||"(none)"}`)}else if(h.length===1)l=h[0];else throw h.length===0?new Error(`No Kanonak packages found under ${t}`):new Error(`Workspace has multiple publishers (${h.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let $=new Set,R=new Map;for(let e of s)e.publisher===l&&($.add(`${e.publisher}/${e.package_}@${e.verStr}`),R.set(`${e.package_}@${e.verStr}`,e.source));let c=new O(M(),!0,o),i=r.repository??new I(n,c,new A(r.httpCache?{getFromCache:r.httpCache.getFromCache,onFetch:r.httpCache.onFetch}:void 0));if(!r.repository){let e=M(),p=d=>K(e,d),u=d=>{let m=p(d);return z(m)?new Set(Q(m).filter(x=>x.endsWith(".kan.yml")).map(x=>x.split("@")[0])):new Set},k=d=>s.some(m=>m.publisher==="kanonak.org"&&m.package_===d),j=new W,_=u("kanonak.org");for(let d of ee)if(!(_.has(d)||k(d)))try{let m=await j.getHighestVersion("kanonak.org",d);if(!m)continue;let x=await j.getPackageUrl("kanonak.org",d,m),F=await fetch(x);if(!F.ok)continue;let J=await F.text(),D=K(e,"kanonak.org");Z(D,{recursive:!0}),X(K(D,`${d}@${m}.kan.yml`),J,"utf-8")}catch{}}let a=await new G(o).parseKanonaks(i),y=new U(a),w=new Map,b=new Map,P=new Map,N=new Set;for(let e of a){if(!(e instanceof T))continue;let p=e.namespace||"";if(!$.has(p))continue;w.set(`${p}/${e.name}`,e);let u=p.split("/")[1]??"",[k,j]=u.split("@");if(!k||!j)continue;let _=E(j);_&&(N.has(u)||(N.add(u),b.has(k)||b.set(k,[]),b.get(k).push({verStr:j,version:_})),e.name===k&&P.set(u,e))}for(let e of b.values())e.sort((p,u)=>V(u.version,p.version));return{publisher:l,availablePublishers:h,catalog:a,lookRenderer:y,localNamespaces:$,rawByNsKey:R,bySubject:w,pkgVersions:b,pkgSelfByVer:P}}var g={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".svg":"image/svg+xml",".md":"text/markdown; charset=utf-8",".kan.yml":"application/yaml; charset=utf-8",".txt":"text/plain; charset=utf-8",".json":"application/json; charset=utf-8"},f=(t,r,o,n)=>({status:t,headers:{"Content-Type":r,...n||{}},body:o}),S=t=>f(404,g[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${t}</p>`),ne=t=>({status:301,headers:{Location:t},body:""});function Y(t,r,o){let n=t.pkgVersions.get(r);if(!n||n.length===0)return null;switch(o.kind){case"any":return n[0].verStr;case"major-pin":return n.find(s=>s.version.major===o.major)?.verStr??null;case"minor-pin":return n.find(s=>s.version.major===o.major&&s.version.minor===o.minor)?.verStr??null;case"exact":return n.find(s=>s.version.major===o.major&&s.version.minor===o.minor&&s.version.patch===o.patch)?.verStr??null;default:return null}}function te(t,r,o=""){let{lookRenderer:n,publisher:s}=t;if(r==="/.well-known/kanonak.json")return f(200,g[".json"],JSON.stringify({version:1,auth:"none"},null,2));if(r==="/index.txt"){let i=[...t.localNamespaces].map(a=>a.split("/")[1].replace("@","/")).sort();return f(200,g[".txt"],i.join(`
|
|
2
2
|
`)+`
|
|
3
|
-
`)}if(
|
|
3
|
+
`)}if(r==="/"||r==="/index.html"||r==="/index.css"){let i=n.publisherSubject(s);return r==="/index.css"?f(200,g[".css"],n.renderStylesheet(i)):f(200,g[".html"],n.renderDocument(i,{rootIndex:!0}))}let v=".html",h=!1,l=r;for(let i of[".kan.yml",".css",".svg",".md",".html"])if(r.endsWith(i)){v=i,h=!0,l=r.slice(0,-i.length);break}let $=!h&&/application\/yaml|text\/yaml/i.test(o),R=l.endsWith("/");R&&l!=="/"&&(l=l.slice(0,-1));let c=H.parse(l,s);if(!c)return S(r);if(c.kind==="package"){let i=Y(t,c.package_,c.versionSpec);if(!i)return S(r);if(v===".kan.yml"||$){let w=t.rawByNsKey.get(`${c.package_}@${i}`);return w!==void 0?f(200,g[".kan.yml"],w):S(r)}let a=t.pkgSelfByVer.get(`${c.package_}@${i}`);if(!a)return S(r);if(v===".css")return f(200,g[".css"],n.renderStylesheet(a));if(!R)return ne(l+"/");let y=c.versionSpec.kind==="any";if(y&&!n.hasDeclaredView(a)){let w=(t.pkgVersions.get(c.package_)||[]).map(b=>b.verStr);return f(200,g[".html"],n.renderPackageVersionList(c.package_,w,a))}return f(200,g[".html"],n.renderDocument(a,y?{bareOverview:!0}:void 0))}if(c.kind==="resource"){let i=Y(t,c.package_,c.versionSpec);if(!i)return S(r);let a=t.bySubject.get(`${s}/${c.package_}@${i}/${c.name}`);if(!a)return S(r);switch(v){case".css":return f(200,g[".css"],n.renderStylesheet(a));case".svg":return f(200,g[".svg"],n.renderSvg(a));case".md":{let y=n.renderRawMarkdown(a);return y===void 0?S(r):f(200,g[".md"],y)}default:return f(200,g[".html"],n.renderDocument(a))}}return S(r)}export{re as loadServerModel,te as route};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as X,c as ye}from"../chunk-
|
|
1
|
+
import{b as X,c as ye}from"../chunk-7O76F4TH.js";import{a as Ne}from"../chunk-IIODYDKS.js";import"../chunk-3NEUHF7E.js";import"../chunk-CYDDQF6S.js";import"../chunk-NIGFQYVA.js";import{c as Ue}from"../chunk-VJT6YUWK.js";import{a as C,c as Ce}from"../chunk-H2LEQLVD.js";import{a as Re}from"../chunk-7CUTGGH3.js";import{b as E,c as F,d as f,f as M,l as Oe}from"../chunk-Q4DKP5DO.js";import{e as Le}from"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";var yt="kanonak.org",kt="document-ast",m=t=>({publisher:yt,package_:kt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ie(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=ht(e.metadata,n),a=St(e.children),u=["---",...r,"---","",a].join(`
|
|
2
2
|
`);return n?.trailingNewline&&(u.endsWith(`
|
|
3
3
|
`)||(u+=`
|
|
4
4
|
`)),u}};function ht(t,e){if(!t)return[];let n=new Map;for(let c of t.entries)n.set(ue(c.key),c);let r=new Map;if(e?.metadataRenames)for(let[c,l]of e.metadataRenames)r.set(ue(c),l);let i=(e?.metadataKeys??t.entries.map(c=>c.key)).map(ue),u=[];for(let c of i){let l=n.get(c);if(!l)continue;let p=r.get(c),y=ue(p??c),h=Me(l.value,l.escapeHint);h!==void 0&&u.push(`${y}: ${h}`)}return u}function ue(t){let e=t.lastIndexOf(".");return e===-1?t:t.substring(e+1)||t}function Me(t,e){switch(t.kind){case"StringScalar":return bt(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let a=Me(r,e);a!==void 0&&n.push(a)}return n.join(", ")}case"StructuredMap":return;default:return}}function bt(t,e){return!e||Ie(e,k.ESC_RAW)?t:Ie(e,k.ESC_YAML_SAFE)?wt(t):t}function wt(t){return t.includes(`
|
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-BSJ6PEKE.js";import"../chunk-VJT6YUWK.js";import"../chunk-H2LEQLVD.js";import"../chunk-7CUTGGH3.js";import"../chunk-N224PFBI.js";import"../chunk-Q4DKP5DO.js";import"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,m as ClassHierarchyCycleRule,t as DefinitionPropertyReferenceRule,D as DisplayLensScopeRule,j as EmbeddedKanonakTypeRule,k as ImportExistenceRule,s as InstancePropertyReferenceRule,E as KanonakObjectValidator,C as MarkdownLinkRule,r as NamespaceImportCycleRule,f as NamespacePrefixRule,x as ObjectPropertyImportRule,y as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,z as PropertyDomainRule,n as PropertyHierarchyCycleRule,w as PropertyRangeReferenceRule,o as PropertyRangeRequiredRule,h as PropertyTypeSpecificityRule,A as PropertyValueTypeRule,g as ResourceNamingRule,p as SubClassOfReferenceRule,q as SubPropertyOfReferenceRule,i as SubjectKanonakTypeRequiredRule,l as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity,u as XsdImportRule};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.54.0",
|
|
4
4
|
"description": "Kanonak Protocol SDK - Document repository and parsing implementations for TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"yaml-parser"
|
|
122
122
|
],
|
|
123
123
|
"dependencies": {
|
|
124
|
-
"@kanonak-protocol/types": "^3.
|
|
124
|
+
"@kanonak-protocol/types": "^3.54.0",
|
|
125
125
|
"ignore": "^7.0.5",
|
|
126
126
|
"js-yaml": "^4.1.0",
|
|
127
127
|
"yaml": "^2.7.0"
|