@kanonak-protocol/sdk 3.52.0 → 3.53.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.
@@ -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.
@@ -167,19 +179,16 @@ export declare class LookRenderer {
167
179
  * appear without authors needing a custom look.Figure band.
168
180
  */
169
181
  /**
170
- * Render the publisher index — the default publisher root page (`/`).
171
- * A grid of the publisher's packages, each linking to its `/{package}`
172
- * overview, so the entire publisher is discoverable from the root.
173
- * `tokenSource` is any resource in the publisher (used for the token
174
- * cascade + nav chrome); `entries` are the packages to list.
182
+ * The Publisher resource for a domain — the single configuration point for
183
+ * a publisher's presentation: its `derivation.look` is the landing
184
+ * PublisherView (default on `ck.Publisher` in universal-look) and its nav
185
+ * is the site nav. Returns an authored `ck.Publisher` resource in the
186
+ * publisher's namespace when present; otherwise synthesizes a minimal one
187
+ * (`rdfs.label` = the domain) so the publisher root ALWAYS renders through
188
+ * the normal look cascade — the same path as any other resource page, no
189
+ * special-case index renderer.
175
190
  */
176
- renderPublisherIndex(publisher: string, entries: Array<{
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;
191
+ publisherSubject(publisher: string): SubjectKanonak;
183
192
  /**
184
193
  * True when the instance has a look declaration closer than the
185
194
  * rdfs.Resource floor — i.e. an instance-level or class-level view
@@ -326,6 +335,31 @@ export declare class LookRenderer {
326
335
  */
327
336
  private detailReferenceLink;
328
337
  private detailEmbedded;
338
+ /**
339
+ * The `rdfs:range` of a property, as a single-element type-ref list (for
340
+ * seeding the look cascade for range-typed embedded objects). Empty when
341
+ * the property or its range can't be resolved.
342
+ */
343
+ private rangeTypeRefs;
344
+ /**
345
+ * Render an EmbeddedViews band: each embedded item of `look.source` is
346
+ * rendered through ITS OWN class look — the same type-chain cascade page
347
+ * instances use — so a document-tree ontology (Protocol → Convention →
348
+ * Rule) composes readable nested sections instead of collapsing into one
349
+ * generic recursive sheet. Items whose class declares no look fall
350
+ * through to the rdfs.Resource floor (Hero + Details), so every item
351
+ * still renders sensibly. Non-embedded values are skipped (use
352
+ * PropertyList / ReferenceList for scalars and references). Recursion is
353
+ * bounded by the data's embedding depth.
354
+ */
355
+ private renderEmbeddedViews;
356
+ /**
357
+ * A small "copy this link" anchor. Its href is the in-page fragment, so
358
+ * clicking puts the full deep URL in the address bar and right-click →
359
+ * Copy Link Address yields the exact URL for this embedded resource. The
360
+ * fragment is shown in the tooltip.
361
+ */
362
+ private anchorLink;
329
363
  /** Predicates surfaced by other bands (or look-layer meta) — skipped by Details. */
330
364
  private isMetaPredicate;
331
365
  /**
@@ -349,6 +383,31 @@ export declare class LookRenderer {
349
383
  * cannot.
350
384
  */
351
385
  private renderReferencedBy;
386
+ /**
387
+ * One resource card: a main link (SemanticSvg + label + truncated summary)
388
+ * to the resource, plus a subtle, hover-revealed footer linking to the
389
+ * resource's package, with the version as a pill — `package@version`. The
390
+ * card is a container (not a single `<a>`) so the package footer can be a
391
+ * real sibling link (nested `<a>`s are invalid). Both links are
392
+ * same-publisher-gated.
393
+ */
394
+ private resourceCard;
395
+ /**
396
+ * Render an Instances band — the resources whose `rdf:type` is the page
397
+ * resource (a class). DIRECT by default (exact type); `look.transitive:
398
+ * true` widens to instances of subclasses too (the subclass closure) —
399
+ * which is why direct is the default, since transitive on rdfs.Resource
400
+ * would be every resource. Deduped to the highest version per canonical
401
+ * key, capped (with a total count), and self-suppressing when the
402
+ * resource is not a class or has no instances.
403
+ */
404
+ private renderInstances;
405
+ /**
406
+ * The set of canonical class keys covered by `target` plus every class
407
+ * that is (transitively) a subclass of it — used for transitive instance
408
+ * matching. Iterates to a fixpoint over the catalog's subClassOf edges.
409
+ */
410
+ private subclassClosure;
352
411
  /**
353
412
  * True if `subject` has a reference (in a ReferenceStatement or a
354
413
  * ListStatement) whose target's canonical key equals `targetKey`. When
@@ -373,20 +432,18 @@ export declare class LookRenderer {
373
432
  */
374
433
  private renderDistribution;
375
434
  /**
376
- * Render a PublisherPackages band — a grid of the publisher's packages
377
- * (latest version of each), each card linking to its bare `/{package}`
378
- * overview, with the package's SemanticSvg + label + truncated comment.
379
- * Powers the discovery section of a publisher root view.
435
+ * Render a PublisherPackages band — a grid of package cards, each
436
+ * linking to its bare `/{package}` overview with the package's
437
+ * SemanticSvg + label + truncated comment. Powers the discovery
438
+ * section of a publisher root view.
439
+ *
440
+ * By default it enumerates every package the context publisher
441
+ * authors (latest version of each, alphabetical). When the band
442
+ * declares an explicit `look.packages` list, it instead features
443
+ * exactly those packages, in author order — each reference resolved
444
+ * to its package's latest self-resource.
380
445
  */
381
446
  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
447
  private renderTimeline;
391
448
  /**
392
449
  * Render the Timeline trajectory chart — a server-rendered inline SVG with
@@ -411,7 +468,6 @@ export declare class LookRenderer {
411
468
  * compact variant") is deferred — that requires a variant system.
412
469
  */
413
470
  private renderResourceGrid;
414
- private parseVersion;
415
471
  /**
416
472
  * Find every SubjectKanonak in the catalog whose declared `rdf:type` set
417
473
  * includes the given class URI (canonical, version-agnostic). Used by
@@ -438,6 +494,14 @@ export declare class LookRenderer {
438
494
  * resource reference (use the target's `rdfs.label`, urlForm `*`).
439
495
  */
440
496
  private renderNavGroup;
497
+ /**
498
+ * Render the site-wide footer, shown on every page. Like nav, it is the
499
+ * `footer` (a `look.Footer`) declared on the publisher's
500
+ * core-kanonak.Publisher resource — the single config point. The Footer
501
+ * carries optional literal `text` (license/copyright) and an optional
502
+ * list of `links` (NavLinks). Returns empty when no footer is declared.
503
+ */
504
+ private renderSiteFooter;
441
505
  /**
442
506
  * Resolve a nav entry to (href, label). NavLink resources contribute
443
507
  * their explicit label + target; direct references read the target's
@@ -445,16 +509,31 @@ export declare class LookRenderer {
445
509
  */
446
510
  private resolveNavEntry;
447
511
  /**
448
- * Find the first `look.NavGroup` instance in the catalog authored by
449
- * `publisher`. Returns undefined if the publisher has not declared one.
512
+ * The catalog-sourced code highlighter (built once). Every
513
+ * `code-grammars.CodeGrammar` in the catalog becomes a grammar spec;
514
+ * the generic scanner in highlight.ts applies them. Returns the SDK
515
+ * mechanism wired to graph-declared intent — no language is hardcoded
516
+ * here.
450
517
  */
451
- private findNavGroupForPublisher;
518
+ private codeHighlighter;
519
+ /** Read every CodeGrammar resource in the catalog into a grammar spec. */
520
+ private collectGrammars;
521
+ /**
522
+ * Render a Links band — the resource's outbound links (the
523
+ * `links.links` property named by `look.source`) as a row of real
524
+ * `<a href>` anchors. Each value is a `links.Link`, embedded inline or
525
+ * referenced, read for its `url`, label (rdfs.label → the link text)
526
+ * and comment (rdfs.comment → the hover title). Renders nothing when
527
+ * the resource has no links, so it is safe on the universal floor.
528
+ */
529
+ private renderLinks;
452
530
  /**
453
531
  * Render a Markdown band — reads the property identified by
454
532
  * `look.source` from the instance and pipes its string value through
455
- * the SDK's minimal CommonMark renderer. Wraps the result in a
456
- * `<section class="kan-markdown">` so stylesheets can target the
457
- * prose block without bleeding into other bands.
533
+ * the SDK's minimal CommonMark renderer (with catalog-driven code
534
+ * highlighting). Wraps the result in a `<section class="kan-markdown">`
535
+ * so stylesheets can target the prose block without bleeding into
536
+ * other bands.
458
537
  */
459
538
  private renderMarkdown;
460
539
  /**
@@ -477,6 +556,29 @@ export declare class LookRenderer {
477
556
  renderRawMarkdown(instance: SubjectKanonak): string | undefined;
478
557
  private renderHero;
479
558
  private renderPropertyList;
559
+ /**
560
+ * Render `look.source` (a list of dict-keyed embeddeds) as a table:
561
+ * columns are the union of the items' predicate names, one row per item
562
+ * with the item's dict-key as a leading row-header. The source
563
+ * property's label captions the table, and the table is omitted
564
+ * entirely when there are no items (so an empty group leaves no dangling
565
+ * caption). Cells render scalars / markdown / references inline; a cell
566
+ * whose value is itself a list of embeddeds recurses into a nested
567
+ * table, so a document tree (rules holding sub-rules, etc.) stays
568
+ * tabular all the way down.
569
+ */
570
+ private renderPropertyTable;
571
+ /**
572
+ * Build a `<table>` from a list of embedded resources. Columns are the
573
+ * union of non-meta predicates across the items, in first-seen order;
574
+ * each row is one item (its dict-key as a `<th scope="row">` when
575
+ * present). Recurses for embedded-list cell values.
576
+ */
577
+ private renderEmbeddedTable;
578
+ /** Render one statement value for a table cell (recurses for embedded lists). */
579
+ private tableCellValue;
580
+ /** Markdown (or plain string) statement → HTML, with [[reference]] links resolved. */
581
+ private statementToMarkdownHtml;
480
582
  private renderBadgeRow;
481
583
  private renderChipRow;
482
584
  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 declare function renderMarkdownToHtml(source: string): string;
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
+ }
@@ -1 +1 @@
1
- import{a as c,b as d,c as e,d as f}from"../chunk-HMDTGNEA.js";import{c as b}from"../chunk-YYFIJNSP.js";import"../chunk-H2LEQLVD.js";import{a}from"../chunk-7CUTGGH3.js";import"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
1
+ import{a as c,b as d,c as e,d as f}from"../chunk-CYDDQF6S.js";import{c as b}from"../chunk-VJT6YUWK.js";import"../chunk-H2LEQLVD.js";import{a}from"../chunk-7CUTGGH3.js";import"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
@@ -1 +1 @@
1
- import{a as g,b as h,c as i,d as j,e as k}from"../chunk-DGR77PRS.js";import"../chunk-YYFIJNSP.js";import"../chunk-H2LEQLVD.js";import"../chunk-7CUTGGH3.js";import{d as a,e as b,f as c,h as d,i as e,j as f}from"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";export{f as KanonakVocabulary,i as OWL_RL_CLASSIFICATION_RULES,h as RDFS_RULES,k as Reasoner,j as ReasoningResult,g as TripleStore,e as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
1
+ import{a as g,b as h,c as i,d as j,e as k}from"../chunk-SD5QKNBC.js";import"../chunk-VJT6YUWK.js";import"../chunk-H2LEQLVD.js";import"../chunk-7CUTGGH3.js";import{d as a,e as b,f as c,h as d,i as e,j as f}from"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";export{f as KanonakVocabulary,i as OWL_RL_CLASSIFICATION_RULES,h as RDFS_RULES,k as Reasoner,j as ReasoningResult,g as TripleStore,e as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
@@ -1,4 +1,4 @@
1
- import{a as p}from"../chunk-2WQR7OHH.js";import"../chunk-3NEUHF7E.js";import"../chunk-DC774EQL.js";import"../chunk-NIGFQYVA.js";import"../chunk-H2LEQLVD.js";import{d as m,g as x}from"../chunk-N224PFBI.js";import{a as d,f as S}from"../chunk-Q4DKP5DO.js";import{a as v}from"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import{c as j}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{homedir as P}from"os";import{join as k}from"path";import{existsSync as B,mkdirSync as C,readFileSync as D,writeFileSync as O}from"fs";import{createHash as z}from"crypto";var f="Xenova/all-MiniLM-L6-v2",w="q8",b=32,g=null;async function K(){return g||(g=(async()=>{let t;try{t=await import("@huggingface/transformers")}catch(i){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
1
+ import{a as p}from"../chunk-WQZBKRDG.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+`
@@ -1,3 +1,3 @@
1
- import{c as O}from"../chunk-2WQR7OHH.js";import"../chunk-3NEUHF7E.js";import{a as P,d as _,f as F,g as N}from"../chunk-H673KOGN.js";import{a as V,d as K}from"../chunk-VHUJSHH7.js";import{a as L}from"../chunk-NIGFQYVA.js";import{c as D}from"../chunk-YYFIJNSP.js";import"../chunk-H2LEQLVD.js";import{a as M}from"../chunk-7CUTGGH3.js";import"../chunk-Q4DKP5DO.js";import{a as x,e as R}from"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import{c as C}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{readFileSync as B}from"fs";async function A(n,e={}){let a=new M,r=new V(a),c=[];for(let o of N(n)){let h;try{h=B(o,"utf-8")}catch{continue}let u;try{u=a.parse(h).metadata?.namespace_}catch{continue}if(!u?.version)continue;let v=u.version,w=`${v.major}.${v.minor}.${v.patch}`;await r.saveDocumentAsync(a.parse(h),`${u.publisher}/${u.package_}@${w}`),c.push({publisher:u.publisher,package_:u.package_,verStr:w,source:h})}let g=[...new Set(c.map(o=>o.publisher))].sort(),m=e.publisher;if(m){if(!g.includes(m))throw new Error(`Publisher "${m}" not found in workspace. Available: ${g.join(", ")||"(none)"}`)}else if(g.length===1)m=g[0];else throw g.length===0?new Error(`No Kanonak packages found under ${n}`):new Error(`Workspace has multiple publishers (${g.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let d=new Set,b=new Map;for(let o of c)o.publisher===m&&(d.add(`${o.publisher}/${o.package_}@${o.verStr}`),b.set(`${o.package_}@${o.verStr}`,o.source));let $=e.repository??new F(r,new P(_(),!0,a),new K(e.httpCache?{getFromCache:e.httpCache.getFromCache,onFetch:e.httpCache.onFetch}:void 0)),i=await new D(a).parseKanonaks($),s=new O(i),t=new Map,l=new Map,k=new Map,y=new Set;for(let o of i){if(!(o instanceof C))continue;let h=o.namespace||"";if(!d.has(h))continue;t.set(`${h}/${o.name}`,o);let u=h.split("/")[1]??"",[v,w]=u.split("@");if(!v||!w)continue;let j=R(w);j&&(y.has(u)||(y.add(u),l.has(v)||l.set(v,[]),l.get(v).push({verStr:w,version:j})),o.name===v&&k.set(u,o))}for(let o of l.values())o.sort((h,u)=>x(u.version,h.version));return{publisher:m,availablePublishers:g,catalog:i,lookRenderer:s,localNamespaces:d,rawByNsKey:b,bySubject:t,pkgVersions:l,pkgSelfByVer:k}}var p={".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=(n,e,a,r)=>({status:n,headers:{"Content-Type":e,...r||{}},body:a}),S=n=>f(404,p[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${n}</p>`),I=n=>({status:301,headers:{Location:n},body:""});function E(n,e,a){let r=n.pkgVersions.get(e);if(!r||r.length===0)return null;switch(a.kind){case"any":return r[0].verStr;case"major-pin":return r.find(c=>c.version.major===a.major)?.verStr??null;case"minor-pin":return r.find(c=>c.version.major===a.major&&c.version.minor===a.minor)?.verStr??null;case"exact":return r.find(c=>c.version.major===a.major&&c.version.minor===a.minor&&c.version.patch===a.patch)?.verStr??null;default:return null}}function T(n,e,a=""){let{lookRenderer:r,publisher:c}=n;if(e==="/.well-known/kanonak.json")return f(200,p[".json"],JSON.stringify({version:1,auth:"none"},null,2));if(e==="/index.txt"){let s=[...n.localNamespaces].map(t=>t.split("/")[1].replace("@","/")).sort();return f(200,p[".txt"],s.join(`
1
+ import{c as E}from"../chunk-WQZBKRDG.js";import"../chunk-3NEUHF7E.js";import{a as K,d as P,f as N,g as C}from"../chunk-H673KOGN.js";import{a as _,d as F}from"../chunk-VHUJSHH7.js";import{a as O}from"../chunk-NIGFQYVA.js";import{c as L}from"../chunk-VJT6YUWK.js";import"../chunk-H2LEQLVD.js";import{a as M}from"../chunk-7CUTGGH3.js";import"../chunk-Q4DKP5DO.js";import{a as $,e as V}from"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import{c as D}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{readFileSync as B}from"fs";async function T(n,r={}){let o=new M,t=new _(o),i=[],k=[];for(let e of C(n)){let g;try{g=B(e,"utf-8")}catch{continue}let f;try{f=o.parse(g).metadata?.namespace_}catch{continue}if(!f?.version)continue;let h=f.version;k.push({publisher:f.publisher,package_:f.package_,verStr:`${h.major}.${h.minor}.${h.patch}`,version:h,source:g})}k.sort((e,g)=>$(g.version,e.version));for(let e of k)await t.saveDocumentAsync(o.parse(e.source),`${e.publisher}/${e.package_}@${e.verStr}`),i.push({publisher:e.publisher,package_:e.package_,verStr:e.verStr,source:e.source});let d=[...new Set(i.map(e=>e.publisher))].sort(),l=r.publisher;if(l){if(!d.includes(l))throw new Error(`Publisher "${l}" not found in workspace. Available: ${d.join(", ")||"(none)"}`)}else if(d.length===1)l=d[0];else throw d.length===0?new Error(`No Kanonak packages found under ${n}`):new Error(`Workspace has multiple publishers (${d.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let y=new Set,b=new Map;for(let e of i)e.publisher===l&&(y.add(`${e.publisher}/${e.package_}@${e.verStr}`),b.set(`${e.package_}@${e.verStr}`,e.source));let a=r.repository??new N(t,new K(P(),!0,o),new F(r.httpCache?{getFromCache:r.httpCache.getFromCache,onFetch:r.httpCache.onFetch}:void 0)),s=await new L(o).parseKanonaks(a),c=new E(s),v=new Map,m=new Map,w=new Map,R=new Set;for(let e of s){if(!(e instanceof D))continue;let g=e.namespace||"";if(!y.has(g))continue;v.set(`${g}/${e.name}`,e);let f=g.split("/")[1]??"",[h,j]=f.split("@");if(!h||!j)continue;let x=V(j);x&&(R.has(f)||(R.add(f),m.has(h)||m.set(h,[]),m.get(h).push({verStr:j,version:x})),e.name===h&&w.set(f,e))}for(let e of m.values())e.sort((g,f)=>$(f.version,g.version));return{publisher:l,availablePublishers:d,catalog:s,lookRenderer:c,localNamespaces:y,rawByNsKey:b,bySubject:v,pkgVersions:m,pkgSelfByVer:w}}var u={".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"},p=(n,r,o,t)=>({status:n,headers:{"Content-Type":r,...t||{}},body:o}),S=n=>p(404,u[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${n}</p>`),W=n=>({status:301,headers:{Location:n},body:""});function A(n,r,o){let t=n.pkgVersions.get(r);if(!t||t.length===0)return null;switch(o.kind){case"any":return t[0].verStr;case"major-pin":return t.find(i=>i.version.major===o.major)?.verStr??null;case"minor-pin":return t.find(i=>i.version.major===o.major&&i.version.minor===o.minor)?.verStr??null;case"exact":return t.find(i=>i.version.major===o.major&&i.version.minor===o.minor&&i.version.patch===o.patch)?.verStr??null;default:return null}}function I(n,r,o=""){let{lookRenderer:t,publisher:i}=n;if(r==="/.well-known/kanonak.json")return p(200,u[".json"],JSON.stringify({version:1,auth:"none"},null,2));if(r==="/index.txt"){let s=[...n.localNamespaces].map(c=>c.split("/")[1].replace("@","/")).sort();return p(200,u[".txt"],s.join(`
2
2
  `)+`
3
- `)}if(e==="/"||e==="/index.html"||e==="/index.css"){let s=r.findPublisherRootView(c),t=[...n.pkgVersions.keys()].sort(),l=s??(t.length?n.pkgSelfByVer.get(`${t[0]}@${n.pkgVersions.get(t[0])[0].verStr}`):void 0);if(e==="/index.css")return f(200,p[".css"],s?r.renderStylesheet(s):r.renderPublisherIndexStylesheet(l));if(s)return f(200,p[".html"],r.renderDocument(s,{rootIndex:!0}));let k=t.map(y=>({label:y,href:`/${y}`}));return f(200,p[".html"],r.renderPublisherIndex(c,k,l))}let g=".html",m=!1,d=e;for(let s of[".kan.yml",".css",".svg",".md",".html"])if(e.endsWith(s)){g=s,m=!0,d=e.slice(0,-s.length);break}let b=!m&&/application\/yaml|text\/yaml/i.test(a),$=d.endsWith("/");$&&d!=="/"&&(d=d.slice(0,-1));let i=L.parse(d,c);if(!i)return S(e);if(i.kind==="package"){let s=E(n,i.package_,i.versionSpec);if(!s)return S(e);if(g===".kan.yml"||b){let k=n.rawByNsKey.get(`${i.package_}@${s}`);return k!==void 0?f(200,p[".kan.yml"],k):S(e)}let t=n.pkgSelfByVer.get(`${i.package_}@${s}`);if(!t)return S(e);if(g===".css")return f(200,p[".css"],r.renderStylesheet(t));if(!$)return I(d+"/");let l=i.versionSpec.kind==="any";if(l&&!r.hasDeclaredView(t)){let k=(n.pkgVersions.get(i.package_)||[]).map(y=>y.verStr);return f(200,p[".html"],r.renderPackageVersionList(i.package_,k,t))}return f(200,p[".html"],r.renderDocument(t,l?{bareOverview:!0}:void 0))}if(i.kind==="resource"){let s=E(n,i.package_,i.versionSpec);if(!s)return S(e);let t=n.bySubject.get(`${c}/${i.package_}@${s}/${i.name}`);if(!t)return S(e);switch(g){case".css":return f(200,p[".css"],r.renderStylesheet(t));case".svg":return f(200,p[".svg"],r.renderSvg(t));case".md":{let l=r.renderRawMarkdown(t);return l===void 0?S(e):f(200,p[".md"],l)}default:return f(200,p[".html"],r.renderDocument(t))}}return S(e)}export{A as loadServerModel,T as route};
3
+ `)}if(r==="/"||r==="/index.html"||r==="/index.css"){let s=t.publisherSubject(i);return r==="/index.css"?p(200,u[".css"],t.renderStylesheet(s)):p(200,u[".html"],t.renderDocument(s,{rootIndex:!0}))}let k=".html",d=!1,l=r;for(let s of[".kan.yml",".css",".svg",".md",".html"])if(r.endsWith(s)){k=s,d=!0,l=r.slice(0,-s.length);break}let y=!d&&/application\/yaml|text\/yaml/i.test(o),b=l.endsWith("/");b&&l!=="/"&&(l=l.slice(0,-1));let a=O.parse(l,i);if(!a)return S(r);if(a.kind==="package"){let s=A(n,a.package_,a.versionSpec);if(!s)return S(r);if(k===".kan.yml"||y){let m=n.rawByNsKey.get(`${a.package_}@${s}`);return m!==void 0?p(200,u[".kan.yml"],m):S(r)}let c=n.pkgSelfByVer.get(`${a.package_}@${s}`);if(!c)return S(r);if(k===".css")return p(200,u[".css"],t.renderStylesheet(c));if(!b)return W(l+"/");let v=a.versionSpec.kind==="any";if(v&&!t.hasDeclaredView(c)){let m=(n.pkgVersions.get(a.package_)||[]).map(w=>w.verStr);return p(200,u[".html"],t.renderPackageVersionList(a.package_,m,c))}return p(200,u[".html"],t.renderDocument(c,v?{bareOverview:!0}:void 0))}if(a.kind==="resource"){let s=A(n,a.package_,a.versionSpec);if(!s)return S(r);let c=n.bySubject.get(`${i}/${a.package_}@${s}/${a.name}`);if(!c)return S(r);switch(k){case".css":return p(200,u[".css"],t.renderStylesheet(c));case".svg":return p(200,u[".svg"],t.renderSvg(c));case".md":{let v=t.renderRawMarkdown(c);return v===void 0?S(r):p(200,u[".md"],v)}default:return p(200,u[".html"],t.renderDocument(c))}}return S(r)}export{T as loadServerModel,I as route};
@@ -1,4 +1,4 @@
1
- import{b as X,c as ye}from"../chunk-2WQR7OHH.js";import{a as Ne}from"../chunk-IIODYDKS.js";import"../chunk-3NEUHF7E.js";import"../chunk-HMDTGNEA.js";import"../chunk-NIGFQYVA.js";import{c as Ue}from"../chunk-YYFIJNSP.js";import{a as C,c as Ce}from"../chunk-H2LEQLVD.js";import{a as Re}from"../chunk-7CUTGGH3.js";import{b as E,c as F,d as f,f as M,l as Oe}from"../chunk-Q4DKP5DO.js";import{e as Le}from"../chunk-FQHALFRR.js";import"../chunk-64TVBQFR.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";var yt="kanonak.org",kt="document-ast",m=t=>({publisher:yt,package_:kt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ie(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=ht(e.metadata,n),a=St(e.children),u=["---",...r,"---","",a].join(`
1
+ import{b as X,c as ye}from"../chunk-WQZBKRDG.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(`
@@ -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-XHCSTAUK.js";import"../chunk-YYFIJNSP.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};
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.52.0",
3
+ "version": "3.53.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.52.0",
124
+ "@kanonak-protocol/types": "^3.53.0",
125
125
  "ignore": "^7.0.5",
126
126
  "js-yaml": "^4.1.0",
127
127
  "yaml": "^2.7.0"