@kanonak-protocol/sdk 3.60.0 → 3.62.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/README.md +4 -117
- package/dist/browser.js +1 -1
- package/dist/chunk-IL6VHYRU.js +148 -0
- package/dist/chunk-PEJALHXK.js +1 -0
- package/dist/index.js +1 -1
- package/dist/look/LookRenderer.d.ts +35 -0
- package/dist/resolution/KanonakUrlResolver.d.ts +8 -0
- package/dist/resolution/index.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +2 -2
- package/dist/server/requestRouter.d.ts +53 -0
- package/dist/transformations/index.js +1 -1
- package/package.json +4 -3
- package/dist/chunk-JYUZT2JU.js +0 -148
- package/dist/chunk-NIGFQYVA.js +0 -1
|
@@ -82,10 +82,17 @@ export declare class KanonakUrlResolver {
|
|
|
82
82
|
*
|
|
83
83
|
* Default: full URL with `https://` scheme. Pass `pathOnly: true` to
|
|
84
84
|
* get the path component only — useful for same-publisher links.
|
|
85
|
+
*
|
|
86
|
+
* `publisherFirst: true` emits a PUBLISHER-FIRST path
|
|
87
|
+
* (`/{publisher}/{package}/{version}/{name}`) instead — the form a
|
|
88
|
+
* request-driven consumer (the Kanonak Browser, request-driven `serve`)
|
|
89
|
+
* uses so EVERY resource, same- or cross-publisher, resolves back through
|
|
90
|
+
* one local origin. It takes precedence over `pathOnly`/`scheme`.
|
|
85
91
|
*/
|
|
86
92
|
static format(address: UrlAddress, opts?: {
|
|
87
93
|
scheme?: 'https' | 'http';
|
|
88
94
|
pathOnly?: boolean;
|
|
95
|
+
publisherFirst?: boolean;
|
|
89
96
|
}): string;
|
|
90
97
|
/**
|
|
91
98
|
* Format a pinned resource reference as a URL with a specific
|
|
@@ -110,5 +117,6 @@ export declare class KanonakUrlResolver {
|
|
|
110
117
|
}, urlForm: UrlForm, opts?: {
|
|
111
118
|
scheme?: 'https' | 'http';
|
|
112
119
|
contextPublisher?: string;
|
|
120
|
+
publisherFirst?: boolean;
|
|
113
121
|
}): string;
|
|
114
122
|
}
|
package/dist/resolution/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as p,b as x}from"../chunk-PEUTCG3B.js";import{a as s}from"../chunk-
|
|
1
|
+
import{a as p,b as x}from"../chunk-PEUTCG3B.js";import{a as s}from"../chunk-PEJALHXK.js";import{a as k}from"../chunk-SC5M74NM.js";import{a as o,b as q,c as r,d as t,e as u,f as v,g as w}from"../chunk-N224PFBI.js";import"../chunk-Q4DKP5DO.js";import{b as m,c as n}from"../chunk-64TVBQFR.js";import"../chunk-W6T7MOKY.js";import{a as l}from"../chunk-FUUTGGJS.js";import{a,b,c,d,e,f,g,h,i,j}from"../chunk-2ACBWC7K.js";export{l as KanonakUri,p as KanonakUriBuilder,s as KanonakUrlResolver,m as ResourceResolver,o as ResourceTypeClassifier,n as TypeResolver,k as assertPackageIdentity,c as compareVersions,w as contextTypesOf,f as createVersion,x as findInstancesByType,r as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,i as isMajorCompatible,q as parseKanonakAddress,g as parseVersionString,j as pickHighestDocument,u as propertiesInScope,v as resolvePropertyStep,t as subjectUri,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
|
package/dist/search/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as p}from"../chunk-
|
|
1
|
+
import{a as p}from"../chunk-IL6VHYRU.js";import"../chunk-3NEUHF7E.js";import"../chunk-PEUTCG3B.js";import"../chunk-PEJALHXK.js";import"../chunk-SC5M74NM.js";import"../chunk-H2LEQLVD.js";import{d as m,g as x}from"../chunk-N224PFBI.js";import{a as d,f as S}from"../chunk-Q4DKP5DO.js";import"../chunk-64TVBQFR.js";import{c as j}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{c as v}from"../chunk-2ACBWC7K.js";import{homedir as P}from"os";import{join as k}from"path";import{existsSync as B,mkdirSync as C,readFileSync as D,writeFileSync as O}from"fs";import{createHash as z}from"crypto";var f="Xenova/all-MiniLM-L6-v2",w="q8",b=32,g=null;async function K(){return g||(g=(async()=>{let t;try{t=await import("@huggingface/transformers")}catch(i){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
|
|
2
2
|
Install it with:
|
|
3
3
|
npm install @huggingface/transformers
|
|
4
4
|
(underlying import error: ${i.message})`)}let{pipeline:r,env:n}=t;n.cacheDir=k(P(),".kanonak","models");let e=await r("feature-extraction",f,{dtype:w});return async i=>(await e(i,{pooling:"mean",normalize:!0})).tolist()})()),g}function H(t,r){let n=0;for(let e=0;e<t.length;e++)n+=t[e]*r[e];return n}function U(t,r){return r?t.version?r.version?v(t.version,r.version)>0:!0:!1:!0}function F(t,r){let n=p(t,r),e=[n.label],i=x(r);if(i.length>0){let s=S(t,i[0]),c=s?p(t,s).label:i[0].name;c&&e.push(`\u2014 a ${c}.`)}return n.summary&&e.push(n.summary),e.join(" ")}function M(t){let r=new Map;for(let n of t){if(!(n instanceof j))continue;let e=m(n);if(!e)continue;let i=d(e),s=r.get(i);(!s||U(e,m(s)))&&r.set(i,n)}return[...r.values()].sort((n,e)=>{let i=m(n)?d(m(n)):n.name,s=m(e)?d(m(e)):e.name;return i.localeCompare(s)})}var y=class{entries=[];get size(){return this.entries.length}async build(r,n={}){let e=M(r);if(n.include&&(e=e.filter(n.include)),e.length===0)return this.entries=[],{size:0,cached:!1};let i=e.map(o=>F(r,o)),s=n.cacheDir,c;if(s){let o=z("sha256").update(f+"|"+w+`
|
package/dist/server/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export { loadServerModel } from './loadServerModel.js';
|
|
|
2
2
|
export { loadResourceModel } from './loadResourceModel.js';
|
|
3
3
|
export type { LoadResourceModelOptions } from './loadResourceModel.js';
|
|
4
4
|
export { route } from './route.js';
|
|
5
|
+
export { RequestRouter, landingPage } from './requestRouter.js';
|
|
6
|
+
export type { RequestRouterOptions } from './requestRouter.js';
|
|
5
7
|
export { deriveImportClosure, ClosureScopedRepository } from './closure.js';
|
|
6
8
|
export { UNIVERSAL_RENDER_BASE, resolveRenderContract, renderRefKey, } from './renderStack.js';
|
|
7
9
|
export type { RenderPackageRef } from './renderStack.js';
|
package/dist/server/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{c as L}from"../chunk-
|
|
1
|
+
import{c as L}from"../chunk-IL6VHYRU.js";import"../chunk-3NEUHF7E.js";import{a as J,d as K,f as X,g as Z}from"../chunk-CA2EATJR.js";import{a as Y,b as z,c as Q,d as F,e as V}from"../chunk-RSIZQAFL.js";import"../chunk-PEUTCG3B.js";import{a as re}from"../chunk-PEJALHXK.js";import"../chunk-SC5M74NM.js";import{c as N}from"../chunk-Q6QTQWR2.js";import"../chunk-H2LEQLVD.js";import{a as C}from"../chunk-ORFSMEMM.js";import{b as I}from"../chunk-N224PFBI.js";import"../chunk-Q4DKP5DO.js";import"../chunk-64TVBQFR.js";import{c as ee}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{c as M,g as G}from"../chunk-2ACBWC7K.js";import{readFileSync as ce,existsSync as le,readdirSync as pe,writeFileSync as ue,mkdirSync as de}from"fs";import{join as H}from"path";function te(s){let e=s.metadata?.namespace_;return e?`${e.publisher}/${e.package_}`:void 0}async function j(s,e){let n=new Set,r=[...s];for(;r.length>0;){let t=r.shift(),d=te(t);if(!d||n.has(d))continue;n.add(d);let m=t.metadata?.imports;if(m)for(let[l,g]of Object.entries(m))for(let y of g)try{let p=await e.getHighestCompatibleVersionAsync(l,y);p&&r.push(p)}catch{}}return n}var $=class{constructor(e,n){this.inner=e;this.scope=n}inner;scope;async getAllDocumentsAsync(){return(await this.inner.getAllDocumentsAsync()).filter(n=>{let r=te(n);return r!==void 0&&this.scope.has(r)})}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,n){return this.inner.getDocumentsByNamespaceAsync(e,n)}getHighestCompatibleVersionAsync(e,n){return this.inner.getHighestCompatibleVersionAsync(e,n)}saveDocumentAsync(e,n){return this.inner.saveDocumentAsync(e,n)}deleteDocumentAsync(e){return this.inner.deleteDocumentAsync(e)}clearNamespaceAsync(e,n){return this.inner.clearNamespaceAsync(e,n)}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};var ne=[{publisher:"kanonak.org",package_:"core-kanonak"},{publisher:"kanonak.org",package_:"site"},{publisher:"kanonak.org",package_:"link"},{publisher:"kanonak.org",package_:"look-tokens"},{publisher:"kanonak.org",package_:"look-styles"},{publisher:"kanonak.org",package_:"look"},{publisher:"kanonak.org",package_:"universal-look"}];function A(s){let e=s?.render;if(e&&e.length>0){let n=[];for(let r of e)try{let t=I(r);t.kind==="package"?n.push({publisher:t.publisher,package_:t.package_}):t.kind==="resource"&&n.push({publisher:t.uri.publisher,package_:t.uri.package_})}catch{}if(n.length>0)return n}return ne}function B(s){return`${s.publisher}/${s.package_}`}function E(s){let{publisher:e,availablePublishers:n,catalog:r,lookRenderer:t,localNamespaces:d,rawByNsKey:m}=s,l=new Map,g=new Map,y=new Map,p=new Set;for(let c of r){if(!(c instanceof ee))continue;let u=c.namespace||"";if(!d.has(u))continue;l.set(`${u}/${c.name}`,c);let h=u.split("/")[1]??"",[v,x]=h.split("@");if(!v||!x)continue;let a=G(x);a&&(p.has(h)||(p.add(h),g.has(v)||g.set(v,[]),g.get(v).push({verStr:x,version:a})),c.name===v&&y.set(h,c))}for(let c of g.values())c.sort((u,h)=>M(h.version,u.version));return{publisher:e,availablePublishers:n,catalog:r,lookRenderer:t,localNamespaces:d,rawByNsKey:m,bySubject:l,pkgVersions:g,pkgSelfByVer:y}}async function q(s,e={}){let n=new C,r=new Y(n),t=[],d=[];for(let a of Z(s)){let w;try{w=ce(a,"utf-8")}catch{continue}let b;try{b=n.parse(w).metadata?.namespace_}catch{continue}if(!b?.version)continue;let _=b.version;d.push({publisher:b.publisher,package_:b.package_,verStr:`${_.major}.${_.minor}.${_.patch}`,version:_,source:w})}d.sort((a,w)=>M(w.version,a.version));for(let a of d)await r.saveDocumentAsync(n.parse(a.source),`${a.publisher}/${a.package_}@${a.verStr}`),t.push({publisher:a.publisher,package_:a.package_,verStr:a.verStr,source:a.source});let m=[...new Set(t.map(a=>a.publisher))].sort(),l=e.publisher;if(l){if(!m.includes(l))throw new Error(`Publisher "${l}" not found in workspace. Available: ${m.join(", ")||"(none)"}`)}else if(m.length===1)l=m[0];else throw m.length===0?new Error(`No Kanonak packages found under ${s}`):new Error(`Workspace has multiple publishers (${m.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let g=new Set,y=new Map;for(let a of t)a.publisher===l&&(g.add(`${a.publisher}/${a.package_}@${a.verStr}`),y.set(`${a.package_}@${a.verStr}`,a.source));let p=new J(K(),!0,n),c=e.repository??new X(r,p,new V(e.httpCache?{getFromCache:e.httpCache.getFromCache,onFetch:e.httpCache.onFetch}:void 0)),u=A(void 0);if(!e.repository){let a=K(),w=o=>{let f=H(a,o);return le(f)?new Set(pe(f).filter(k=>k.endsWith(".kan.yml")).map(k=>k.split("@")[0])):new Set},b=(o,f)=>t.some(k=>k.publisher===o&&k.package_===f),_=new F,i=new Map;for(let o of u)if(i.has(o.publisher)||i.set(o.publisher,w(o.publisher)),!(i.get(o.publisher).has(o.package_)||b(o.publisher,o.package_)))try{let f=await _.getHighestVersion(o.publisher,o.package_);if(!f)continue;let k=await _.getPackageUrl(o.publisher,o.package_,f),D=await fetch(k);if(!D.ok)continue;let ie=await D.text(),W=H(a,o.publisher);de(W,{recursive:!0}),ue(H(W,`${o.package_}@${f}.kan.yml`),ie,"utf-8")}catch{}}let h=c;if(!e.repository){let a=(await r.getAllDocumentsAsync()).filter(b=>b.metadata.namespace_?.publisher===l),w=await j(a,c);for(let b of u)w.add(B(b));h=new $(c,w)}let v=await new N(n).parseKanonaks(h),x=new L(v);return E({publisher:l,availablePublishers:m,catalog:v,lookRenderer:x,localNamespaces:g,rawByNsKey:y})}import{existsSync as me,readFileSync as ge,writeFileSync as fe,mkdirSync as he}from"fs";import{join as oe}from"path";async function O(s,e={}){let n=new C,r=I(s),t=r.kind==="resource"?r.uri.publisher:r.publisher,d=e.cacheRoot??K(),m=(i,o,f)=>oe(d,i,`${o}@${f}.kan.yml`),l=new V({getFromCache:(i,o,f)=>{let k=m(i,o,f);return me(k)?ge(k,"utf-8"):null},onFetch:(i,o,f,k)=>{let D=oe(d,i);he(D,{recursive:!0}),fe(m(i,o,f),k,"utf-8")},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),g=new F(e.fetchFn?{fetchFn:e.fetchFn}:void 0),y;if(r.kind==="resource"){let i=r.uri.version;y=[i?{package_:r.uri.package_,version:`${i.major}.${i.minor}.${i.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let i=r.version;y=[i?{package_:r.package_,version:`${i.major}.${i.minor}.${i.patch}`}:{package_:r.package_}]}else y=(await g.listLatestPackages(t)).map(o=>({package_:o.packageName}));let p=async(i,o,f)=>{try{let k=f?n.buildImport(o,"=",f,i):n.buildImport(o,"*","0.0.0",i);return await l.getHighestCompatibleVersionAsync(i,k)}catch{return null}},c=[];for(let i of y){let o=await p(t,i.package_,i.version);o&&c.push(o)}if(c.length===0)throw new Error(`Could not fetch any package for address "${s}" from publisher "${t}".`);let u=await new Q().getConfig(t).catch(()=>{}),h=[];for(let i of A(u)){let o=await p(i.publisher,i.package_,void 0);o&&h.push(o)}let v=await j([...c,...h],l),x=new $(l,v),a=await new N(n).parseKanonaks(x),w=new L(a),b=new Set,_=new Map;for(let i of await l.getAllDocumentsAsync()){let o=i.metadata.namespace_;if(!o||o.publisher!==t)continue;let f=`${o.version.major}.${o.version.minor}.${o.version.patch}`,k=`${o.publisher}/${o.package_}@${f}`;b.add(k);let D=await l.getDocumentContentAsync(k);D!==null&&_.set(`${o.package_}@${f}`,D)}return E({publisher:t,availablePublishers:[t],catalog:a,lookRenderer:w,localNamespaces:b,rawByNsKey:_})}var R={".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"},S=(s,e,n,r)=>({status:s,headers:{"Content-Type":e,...r||{}},body:n}),P=s=>S(404,R[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${s}</p>`),ke=s=>({status:301,headers:{Location:s},body:""});function se(s,e,n){let r=s.pkgVersions.get(e);if(!r||r.length===0)return null;switch(n.kind){case"any":return r[0].verStr;case"major-pin":return r.find(t=>t.version.major===n.major)?.verStr??null;case"minor-pin":return r.find(t=>t.version.major===n.major&&t.version.minor===n.minor)?.verStr??null;case"exact":return r.find(t=>t.version.major===n.major&&t.version.minor===n.minor&&t.version.patch===n.patch)?.verStr??null;default:return null}}function T(s,e,n=""){let{lookRenderer:r,publisher:t}=s;if(e==="/.well-known/kanonak.json")return S(200,R[".json"],JSON.stringify(z(t),null,2));if(e==="/index.txt"){let c=[...s.localNamespaces].map(u=>u.split("/")[1].replace("@","/")).sort();return S(200,R[".txt"],c.join(`
|
|
2
2
|
`)+`
|
|
3
|
-
`)}if(e==="/"||e==="/index.html"||e==="/index.css"){let c=r.publisherSubject(
|
|
3
|
+
`)}if(e==="/"||e==="/index.html"||e==="/index.css"){let c=r.publisherSubject(t);return e==="/index.css"?S(200,R[".css"],r.renderStylesheet(c)):S(200,R[".html"],r.renderDocument(c,{rootIndex:!0}))}let d=".html",m=!1,l=e;for(let c of[".kan.yml",".css",".svg",".md",".html"])if(e.endsWith(c)){d=c,m=!0,l=e.slice(0,-c.length);break}let g=!m&&/application\/yaml|text\/yaml/i.test(n),y=l.endsWith("/");y&&l!=="/"&&(l=l.slice(0,-1));let p=re.parse(l,t);if(!p)return P(e);if(p.kind==="package"){let c=se(s,p.package_,p.versionSpec);if(!c)return P(e);if(d===".kan.yml"||g){let v=s.rawByNsKey.get(`${p.package_}@${c}`);return v!==void 0?S(200,R[".kan.yml"],v):P(e)}let u=s.pkgSelfByVer.get(`${p.package_}@${c}`);if(!u)return P(e);if(d===".css")return S(200,R[".css"],r.renderStylesheet(u));if(!y)return ke(l+"/");let h=p.versionSpec.kind==="any";if(h&&!r.hasDeclaredView(u)){let v=(s.pkgVersions.get(p.package_)||[]).map(x=>x.verStr);return S(200,R[".html"],r.renderPackageVersionList(p.package_,v,u))}return S(200,R[".html"],r.renderDocument(u,h?{bareOverview:!0}:void 0))}if(p.kind==="resource"){let c=se(s,p.package_,p.versionSpec);if(!c)return P(e);let u=s.bySubject.get(`${t}/${p.package_}@${c}/${p.name}`);if(!u)return P(e);switch(d){case".css":return S(200,R[".css"],r.renderStylesheet(u));case".svg":return S(200,R[".svg"],r.renderSvg(u));case".md":{let h=r.renderRawMarkdown(u);return h===void 0?P(e):S(200,R[".md"],h)}default:return S(200,R[".html"],r.renderDocument(u))}}return P(e)}var U=class{constructor(e={}){this.options=e}options;models=new Map;clearCache(){this.models.clear()}async modelFor(e){let n=this.models.get(e);if(n)return n;let r=this.options.fetchFn?{fetchFn:this.options.fetchFn}:{},t;if(this.options.root!==void 0)try{t=await q(this.options.root,{publisher:e})}catch(d){if(!/not found in workspace/i.test(d.message))throw d;t=await O(e,r)}else t=await O(e,r);return t.lookRenderer.setLinkMode("open-world"),this.models.set(e,t),t}async handle(e,n=""){let r=e.split("/").filter(Boolean);if(r.length===0)return{status:200,headers:{"Content-Type":"text/html; charset=utf-8"},body:ae()};let t=r[0];if(!t.includes("."))return{status:404,headers:{"Content-Type":"text/html; charset=utf-8"},body:"<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Expected a publisher domain as the first path segment: <code>/{publisher}/{package}/{version}/{resource}</code></p>"};let d=await this.modelFor(t),m=e.endsWith("/")&&r.length>1?"/":"",l="/"+r.slice(1).join("/")+m,g=T(d,l,n);return g.headers.Location?{...g,headers:{...g.headers,Location:`/${t}${g.headers.Location}`}}:g}};function ae(){return'<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Kanonak origin</title></head><body style="font-family:system-ui;max-width:40rem;margin:4rem auto;padding:0 1rem"><h1>Kanonak request-driven origin</h1><p>Open a resource by its address:</p><p><code>/{publisher}/{package}/{version}/{resource}</code></p><p>e.g. <code>/kanonak.org/capabilities/2.0.0/Capability</code></p></body></html>'}export{$ as ClosureScopedRepository,U as RequestRouter,ne as UNIVERSAL_RENDER_BASE,j as deriveImportClosure,ae as landingPage,O as loadResourceModel,q as loadServerModel,B as renderRefKey,A as resolveRenderContract,T as route};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ServerModel, RouteResponse } from './types.js';
|
|
2
|
+
import type { AuthenticatedFetchFn } from '../auth/index.js';
|
|
3
|
+
export interface RequestRouterOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Workspace root, for publishers that are LOCAL (served from disk with live
|
|
6
|
+
* edits). Omit for a pure remote router that fetches every publisher over
|
|
7
|
+
* HTTP.
|
|
8
|
+
*/
|
|
9
|
+
root?: string;
|
|
10
|
+
/** Authenticated fetch for remote publisher fetches (auth / testing). */
|
|
11
|
+
fetchFn?: AuthenticatedFetchFn;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The request-driven routing engine: maps a publisher-FIRST path
|
|
15
|
+
* (`/{publisher}/{package}/{version}/{resource}`) to a response by deriving the
|
|
16
|
+
* publisher from the first path segment and building a per-publisher
|
|
17
|
+
* {@link ServerModel} on demand — from the workspace if that publisher is local
|
|
18
|
+
* (when `root` is set), else fetched over HTTP via {@link loadResourceModel}.
|
|
19
|
+
* One model is cached per publisher.
|
|
20
|
+
*
|
|
21
|
+
* This is the canonical request-driven engine shared by `kanonak serve`
|
|
22
|
+
* (request-driven mode) and the VS Code extension's `EmbeddedServer`: both are
|
|
23
|
+
* thin HTTP listeners over it, exactly as they already share `route` and
|
|
24
|
+
* `loadServerModel`. It is pure of transport concerns — CORS, logging, the
|
|
25
|
+
* choice of status code for an upstream failure — which belong to the listener.
|
|
26
|
+
*/
|
|
27
|
+
export declare class RequestRouter {
|
|
28
|
+
private readonly options;
|
|
29
|
+
private readonly models;
|
|
30
|
+
constructor(options?: RequestRouterOptions);
|
|
31
|
+
/** Drop cached models — e.g. after a workspace `.kan.yml` change. */
|
|
32
|
+
clearCache(): void;
|
|
33
|
+
/**
|
|
34
|
+
* The model for one publisher, built on first use and cached. A local
|
|
35
|
+
* workspace publisher is served from disk; any other publisher is fetched
|
|
36
|
+
* over HTTP (its latest catalogue). Throws if neither resolves.
|
|
37
|
+
*/
|
|
38
|
+
modelFor(publisher: string): Promise<ServerModel>;
|
|
39
|
+
/**
|
|
40
|
+
* Route one publisher-first path:
|
|
41
|
+
* - `/` → a landing page (no single publisher to show);
|
|
42
|
+
* - a first segment that isn't a domain → 404;
|
|
43
|
+
* - otherwise → the resource rendered via {@link route} against the
|
|
44
|
+
* publisher's model, with any redirect `Location` re-prefixed with the
|
|
45
|
+
* publisher so navigation stays under `/{publisher}/…`.
|
|
46
|
+
*
|
|
47
|
+
* Throws only when a publisher's model can't be built (unreachable / no such
|
|
48
|
+
* publisher); the listener decides how to surface that (e.g. a 502).
|
|
49
|
+
*/
|
|
50
|
+
handle(pathname: string, accept?: string): Promise<RouteResponse>;
|
|
51
|
+
}
|
|
52
|
+
/** Minimal landing for the request-driven root, which has no single publisher. */
|
|
53
|
+
export declare function landingPage(): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as X,c as ye}from"../chunk-
|
|
1
|
+
import{b as X,c as ye}from"../chunk-IL6VHYRU.js";import{a as Ne}from"../chunk-IUCHSPLQ.js";import"../chunk-3NEUHF7E.js";import"../chunk-7JZUJ2K4.js";import"../chunk-PEJALHXK.js";import{c as Ue}from"../chunk-Q6QTQWR2.js";import{a as C,c as Ce}from"../chunk-H2LEQLVD.js";import{a as Re}from"../chunk-ORFSMEMM.js";import{b as E,c as F,d as f,f as M,l as Oe}from"../chunk-Q4DKP5DO.js";import"../chunk-64TVBQFR.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{g as Le}from"../chunk-2ACBWC7K.js";var yt="kanonak.org",kt="document-ast",m=t=>({publisher:yt,package_:kt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ie(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=ht(e.metadata,n),a=St(e.children),u=["---",...r,"---","",a].join(`
|
|
2
2
|
`);return n?.trailingNewline&&(u.endsWith(`
|
|
3
3
|
`)||(u+=`
|
|
4
4
|
`)),u}};function ht(t,e){if(!t)return[];let n=new Map;for(let c of t.entries)n.set(ue(c.key),c);let r=new Map;if(e?.metadataRenames)for(let[c,l]of e.metadataRenames)r.set(ue(c),l);let i=(e?.metadataKeys??t.entries.map(c=>c.key)).map(ue),u=[];for(let c of i){let l=n.get(c);if(!l)continue;let p=r.get(c),y=ue(p??c),h=Me(l.value,l.escapeHint);h!==void 0&&u.push(`${y}: ${h}`)}return u}function ue(t){let e=t.lastIndexOf(".");return e===-1?t:t.substring(e+1)||t}function Me(t,e){switch(t.kind){case"StringScalar":return bt(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let a=Me(r,e);a!==void 0&&n.push(a)}return n.join(", ")}case"StructuredMap":return;default:return}}function bt(t,e){return!e||Ie(e,k.ESC_RAW)?t:Ie(e,k.ESC_YAML_SAFE)?wt(t):t}function wt(t){return t.includes(`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanonak-protocol/sdk",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Kanonak Protocol
|
|
3
|
+
"version": "3.62.0",
|
|
4
|
+
"description": "TypeScript SDK for the Kanonak Protocol — parse, resolve, validate, reason over, and render .kan.yml packages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -108,6 +108,7 @@
|
|
|
108
108
|
"type": "git",
|
|
109
109
|
"url": "https://github.com/kanonak-protocol"
|
|
110
110
|
},
|
|
111
|
+
"homepage": "https://kanonak.org",
|
|
111
112
|
"publishConfig": {
|
|
112
113
|
"registry": "https://npm.pkg.github.com"
|
|
113
114
|
},
|
|
@@ -121,7 +122,7 @@
|
|
|
121
122
|
"yaml-parser"
|
|
122
123
|
],
|
|
123
124
|
"dependencies": {
|
|
124
|
-
"@kanonak-protocol/types": "^3.
|
|
125
|
+
"@kanonak-protocol/types": "^3.62.0",
|
|
125
126
|
"ignore": "^7.0.5",
|
|
126
127
|
"js-yaml": "^4.1.0",
|
|
127
128
|
"yaml": "^2.7.0"
|