@kanonak-protocol/sdk 5.26.0 → 5.28.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-BA4HAURJ.js +1 -0
- package/dist/{chunk-Q3TDDWKS.js → chunk-GJAYU443.js} +1 -1
- package/dist/{chunk-WVXOHCW2.js → chunk-KDMBMX3J.js} +1 -1
- package/dist/chunk-N3XODYH5.js +1 -0
- package/dist/{chunk-HND3PKKR.js → chunk-RJK6Y4HS.js} +1 -1
- package/dist/{chunk-ZUWSZQAJ.js → chunk-S2VGNHHF.js} +1 -1
- package/dist/chunk-SR6I5ZSI.js +68 -0
- package/dist/chunk-SUXSCSHO.js +1 -0
- package/dist/chunk-TW7NJDMW.js +152 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/kanonaks/walkDefinedKanonaks.d.ts +10 -1
- package/dist/look/LookRenderer.d.ts +36 -0
- package/dist/look/displayValue.d.ts +3 -5
- package/dist/parsing/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/resolution/index.js +1 -1
- package/dist/search/index.js +1 -1
- package/dist/server/index.js +18 -10
- package/dist/server/renderDiagnostics.d.ts +10 -0
- package/dist/transformations/index.js +2 -2
- package/dist/transformations/v3/CompiledTransformationV3.d.ts +17 -1
- package/dist/transformations/v3/TransformationUriConstantsV3.d.ts +5 -0
- package/dist/uri-helpers/UriHelpers.d.ts +19 -0
- package/dist/uri-helpers/index.d.ts +1 -1
- package/dist/uri-helpers/index.js +1 -1
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +1 -1
- package/dist/validation/rules/repository/TxExpressionCompilesRule.d.ts +62 -0
- package/dist/validation/rules/repository/index.d.ts +1 -0
- package/package.json +2 -2
- package/dist/chunk-AUXSXDZB.js +0 -152
- package/dist/chunk-CYXNYNE7.js +0 -63
- package/dist/chunk-EKSYQ6CU.js +0 -1
- package/dist/chunk-H6UAD2LP.js +0 -1
- package/dist/chunk-ITI65NHP.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Zt,b as Qt,c as eo,d as no,e as H}from"./chunk-Q3TDDWKS.js";import{a as Vn,b as Nn,c as On}from"./chunk-D66LUZDB.js";import{a as Xt,b as Yt,c as Jt,d as Xo,e as we,f as Yo,g as Jo,h as Zo,i as Qo,j as er,k as nr,l as tr,m as rr}from"./chunk-WVXOHCW2.js";import{a as or}from"./chunk-ZUWSZQAJ.js";import{a as mt,b as ft,c as kt,d as yt,e as ht,f as Ct,g as It,h as _t,i as At}from"./chunk-JFBPQN6T.js";import{a as gt,b as St,c as bt,d as Pt,e as Rt,f as Et,h as Kt,i as De,j as Me,k as He,l as Te,m as xt,n as vt}from"./chunk-P5VQEDBS.js";import{a as oo,b as ro,c as ao,d as io}from"./chunk-HND3PKKR.js";import{a as so}from"./chunk-PEB52US5.js";import{a as wt}from"./chunk-SC5M74NM.js";import{A as Oo,B as $o,C as Uo,D as Do,E as Mo,F as Bo,G as Wo,H as zo,K as Go,L as qo,a as uo,b as lo,c as po,d as mo,e as fo,f as ko,g as yo,h as ho,i as go,j as So,k as bo,l as Po,m as Ro,n as Eo,o as Ko,p as xo,q as wo,r as vo,s as Co,t as Io,u as _o,v as Ao,w as Lo,x as jo,y as Vo,z as No}from"./chunk-CYXNYNE7.js";import"./chunk-BRCVOR7A.js";import{a as Ho,c as xe,e as An,h as Ln,i as jn,j as To,k as Fo}from"./chunk-AUXSXDZB.js";import{a as me}from"./chunk-6VIUXP4N.js";import{a as E,b as D,c as ge,i as V,j as Ke,k as Gt,l as qt,m as A}from"./chunk-ITI65NHP.js";import{a as j}from"./chunk-KOWDHKBN.js";import{a as co}from"./chunk-PEJALHXK.js";import{$ as Re,A as tn,B as on,C as rn,D as an,E as sn,F as cn,G as un,H as ln,I as pn,J as dn,K as mn,L as fn,M as Pe,N as kn,O as yn,P as hn,Q as gn,R as Sn,S as bn,T as Pn,U as Rn,V as En,W as Kn,X as xn,Y as wn,Z as vn,_ as Cn,a as $t,b as Ut,c as Se,d as Dt,da as Ft,e as M,f as Mt,fa as Bt,g as Ht,ga as h,ha as ee,i as Tt,j as X,k as Y,l as Fe,m as J,ma as Wt,n as Be,na as zt,o as We,oa as ne,p as ze,q as Ge,r as qe,s as Xe,t as Ye,u as Je,v as be,w as Ze,x as Qe,y as en,z as nn}from"./chunk-EKSYQ6CU.js";import{a as Lt,b as jt,c as g,d as k,e as Nt,f as Ot,g as fe,h as ke,i as ye,j as G,k as he,l as q,m as u,p as In,r as K,t as _n,u as I,v as Z,w as y,x as Ee,y as _,z as Q}from"./chunk-H6UAD2LP.js";import{a as Vt}from"./chunk-FUUTGGJS.js";import{a as at,b as de,c as z,d as it,e as w,f as st,g as ct,h as ut,i as lt,j as pt,k as dt}from"./chunk-QILEJIFU.js";import{a as to}from"./chunk-ODIECDN7.js";async function $n(n){let e=await new A().parseKanonaks(n),o=await new H().reason(n);return{kind:"merged",catalog:e,reasoning:o}}function Un(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function Dn(n,e){let o=e??new me(new j);return{kind:"standalone",catalog:await new A().parseKanonaks(new Q(n,o))}}function $(n){return typeof n=="number"?n:void 0}function ar(n){if(!n)return;let e=u(n);if(e===u(dn))return"IRI";if(e===u(mn))return"BlankNode";if(e===u(fn))return"Literal"}function Mn(n){if(!n)return;let e=u(n);if(e===u(kn))return"Violation";if(e===u(yn))return"Warning";if(e===u(hn))return"Info"}function ve(n,e){let o=y(n,e);if(o)return[o];let t=[];for(let r of _(n,e))r instanceof k&&t.push(r.subject);return t}function ir(n,e){let o=y(n,Ge);if(!o)return;let t={path:o},r=$(I(n,qe)),a=$(I(n,Xe));r!==void 0&&(t.minCount=r),a!==void 0&&(t.maxCount=a);let s=$(I(n,en)),i=$(I(n,nn));s!==void 0&&(t.minLength=s),i!==void 0&&(t.maxLength=i);let c=$(I(n,tn)),p=$(I(n,on));c!==void 0&&(t.minInclusive=c),p!==void 0&&(t.maxInclusive=p);let d=Z(n,Ze);if(d!==void 0){let P=Z(n,Qe);t.pattern=P!==void 0?{regex:d,flags:P}:{regex:d}}if(_n(n,be)){let P=[],N=[];for(let O of _(n,be))O instanceof D?P.push(O.value):O instanceof k&&N.push(O.subject);P.length>0&&(t.inValues=P),N.length>0&&(t.inRefs=N)}let S=y(n,Ye);S&&(t.datatype=S);let b=y(n,Je);b&&(t.classRef=b);let l=ar(y(n,pn));l&&(t.nodeKind=l);let m=Z(n,rn);m!==void 0&&(t.message=m);let f=Mn(y(n,Pe))??e;return f&&(t.severity=f),t}function te(n){let e=[];for(let o of n){if(!(o instanceof g)||!In(o,J))continue;let t=Mn(y(o,Pe)),r={name:o.name,uri:h(o),targetClass:y(o,We),targetNodes:ve(o,an),targetSubjectsOf:ve(o,sn),targetObjectsOf:ve(o,cn),closed:I(o,un)===!0,ignoredProperties:[],severity:t,properties:[]};for(let a of _(o,ln))a instanceof k&&r.ignoredProperties.push(a.subject);for(let a of _(o,ze)){let s;if(a instanceof E?s=a:a instanceof k&&(s=K(n,a.subject)),!s)continue;let i=ir(s,t);i&&r.properties.push(i)}e.push(r)}return e}var x="kanonak.org/transformations",oe="values";var re="allowed",v=n=>({type:`${x}/VarRef`,varName:n}),Ce=n=>({type:`${x}/IntegerLiteral`,integerLiteral:n}),sr=n=>({type:`${x}/DecimalLiteral`,decimalLiteral:n}),Hn=n=>Number.isInteger(n)?Ce(n):sr(n),Tn=n=>({type:`${x}/Count`,source:n}),Fn=(n,e)=>({type:`${x}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),Bn=(n,e)=>({type:`${x}/LessThanOrEqual`,compareLeft:n,compareRight:e});function Ie(n,e){if(!e||e.length===0)return n;let o=new Set(["i","m","s"]),t=[...new Set(e.split(""))];if(t.filter(a=>!o.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${t.sort().join("")})${n}`}function ae(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Fn(Tn(v(oe)),Ce(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:Bn(Tn(v(oe)),Ce(n.maxCount))}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${x}/Contains`,haystack:v(re),needle:v("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:Ie(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Fn(v("v"),Hn(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:Bn(v("v"),Hn(n.maxInclusive))}),e}import{evaluate as ur,ExpressionError as lr}from"@kanonak-protocol/expression";function Gn(n,e){let o=pr(e)?e:te(e),t=[];for(let r of o)for(let a of dr(n,r))kr(n,r,a,t);return{conforms:!t.some(r=>r.severity==="Violation"),results:t}}function pr(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function ie(n){let e=n.predicate;return e instanceof k?e:void 0}function dr(n,e){let o=new Map,t=n.catalog.filter(a=>a instanceof g),r=a=>{let s=h(a);o.set(s?u(s):`${a.namespace}/${a.name}`,a)};if(e.targetClass){let a=u(e.targetClass);if(n.reasoning){let s=new Set(n.reasoning.getInstancesOfClass(e.targetClass));for(let i of t){let c=h(i);c&&s.has(u(c))&&r(i)}}else for(let s of t)ne(s).some(c=>u(c)===a||ee(n.catalog,c).some(p=>u(p)===a))&&r(s)}for(let a of e.targetNodes){let s=K(n.catalog,a);s instanceof g&&r(s)}for(let a of e.targetSubjectsOf){let s=u(a);for(let i of t)i.statement.some(c=>{let p=ie(c);return p&&u(p.subject)===s})&&r(i)}for(let a of e.targetObjectsOf){let s=u(a);for(let i of t)for(let c of i.statement){let p=ie(c);if(!(!p||u(p.subject)!==s))for(let d of mr(c)){let S=K(n.catalog,d);S instanceof g&&r(S)}}}return[...o.values()]}function mr(n){return n instanceof G?[n.object.subject]:n instanceof q?(n.object??[]).filter(e=>e instanceof k).map(e=>e.subject):[]}function fr(n,e,o){let t=[];for(let r of n.statement){let a=ie(r);if(!(!a||u(a.subject)!==e)){if(r instanceof fe||r instanceof ge)t.push({kernel:r.object,kind:"string",literal:r.object});else if(r instanceof ke)t.push({kernel:r.object,kind:"number",literal:r.object});else if(r instanceof ye)t.push({kernel:r.object?1:0,kind:"boolean",literal:r.object});else if(r instanceof G)t.push({kernel:{ref:u(r.object.subject)},kind:"reference",ref:r.object.subject});else if(r instanceof he)t.push(Wn(r.object,o,t.length));else if(r instanceof q){for(let s of r.object??[])if(s instanceof k)t.push({kernel:{ref:u(s.subject)},kind:"reference",ref:s.subject});else if(s instanceof E)t.push(Wn(s,o,t.length));else if(s instanceof D){let i=s.value;typeof i=="boolean"?t.push({kernel:i?1:0,kind:"boolean",literal:i}):t.push({kernel:i,kind:typeof i=="number"?"number":"string",literal:i})}}}}return t}function Wn(n,e,o){let t=n.name&&n.name.length>0?n.name:String(o);return{kernel:{ref:`${e}#${t}`},kind:"embedded"}}function kr(n,e,o,t){let r=h(o),a=r?u(r):`${o.namespace}/${o.name}`;for(let s of e.properties)hr(n,e,o,a,r,s,t);e.closed&&Rr(e,o,a,r,t)}function _e(n,e,o,t,r,a={},s){return{focusNode:e,focusUri:o,constraintComponent:t,severity:s??qn(n),message:r,sourceShape:n.name,sourceShapeUri:n.uri,...a}}function qn(n){return n.severity??"Violation"}var yr={minCount:gn,maxCount:Sn,in:Rn,pattern:En,minLength:Kn,maxLength:xn,minInclusive:wn,maxInclusive:vn};function hr(n,e,o,t,r,a,s){let i=u(a.path),c=fr(o,i,t),p=a.severity??qn(e),d=a.path.name,S=[...(a.inValues??[]).map(l=>typeof l=="boolean"?l?1:0:l),...(a.inRefs??[]).map(l=>({ref:u(l)}))],b=(l,m,f)=>{s.push(_e(e,t,r,l,a.message??m,{resultPath:a.path,value:f?.literal,valueRef:f?.ref},p))};for(let l of ae(a)){let m=yr[l.component];if(l.per==="node"){zn(l,{[oe]:c.map(P=>P.kernel),[re]:S})||b(m,l.component==="minCount"?`'${d}' has ${c.length} value(s); minCount is ${a.minCount}.`:`'${d}' has ${c.length} value(s); maxCount is ${a.maxCount}.`);continue}for(let f of c){if((l.component==="pattern"||l.component==="minLength"||l.component==="maxLength")&&f.kind!=="string"){b(m,`'${d}' value is not a string; ${l.component} applies to string values.`,f);continue}zn(l,{v:f.kernel,[re]:S})||b(m,gr(l,d,a,f),f)}}if(a.nodeKind)for(let l of c)Sr(a.nodeKind,l)||b(Cn,`'${d}' value is ${l.kind}; nodeKind requires ${a.nodeKind}.`,l);if(a.datatype)for(let l of c){let m=br(a.datatype,l);m&&b(bn,`'${d}' ${m}`,l)}if(a.classRef)for(let l of c){let m=Pr(n,a.classRef,l);m&&b(Pn,`'${d}' ${m}`,l)}}function gr(n,e,o,t){let r=t.ref?u(t.ref):JSON.stringify(t.literal);switch(n.component){case"in":return`'${e}' value ${r} is not in the permitted set.`;case"pattern":return`'${e}' value ${r} does not match pattern ${o.pattern?.regex}.`;case"minLength":return`'${e}' value ${r} is shorter than minLength ${o.minLength}.`;case"maxLength":return`'${e}' value ${r} is longer than maxLength ${o.maxLength}.`;case"minInclusive":return`'${e}' value ${r} is below minInclusive ${o.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${r} is above maxInclusive ${o.maxInclusive} (or not numeric).`;default:return`'${e}' value ${r} violates ${n.component}.`}}function zn(n,e){let o=t=>{let r=t.varName;if(t.type==="kanonak.org/transformations/VarRef"&&typeof r=="string"&&r in e)return e[r];throw new lr(`Conformance lowering produced an unexpected leaf '${t.type}'`)};return ur(n.expr,void 0,o)===1}function Sr(n,e){switch(n){case"IRI":return e.kind==="reference";case"BlankNode":return e.kind==="embedded";case"Literal":return e.kind==="string"||e.kind==="number"||e.kind==="boolean"}}function br(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let o=Ke(n);if(o!==void 0)switch(o){case V.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case V.Integer:return e.kind!=="number"?`value is not a number (${n.name}).`:Number.isInteger(e.literal)?void 0:`value is not an integer (${n.name}).`;case V.Decimal:case V.Double:case V.Float:return e.kind==="number"?void 0:`value is not a number (${n.name}).`;default:return e.kind==="string"?void 0:`value is not a string-carried literal (${n.name}).`}}function Pr(n,e,o){if(o.kind!=="reference"||!o.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;let t=u(e);if(n.reasoning)return n.reasoning.isInstanceOf(o.ref,e)?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`;let r=K(n.catalog,o.ref);return r instanceof g?ne(r).some(s=>u(s)===t||ee(n.catalog,s).some(i=>u(i)===t))?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`:`value ${u(o.ref)} does not resolve in this scope (sh:class ${e.name}).`}function Rr(n,e,o,t,r){let a=new Set([...n.properties.map(i=>u(i.path)),...n.ignoredProperties.map(i=>u(i))]),s=new Set;for(let i of e.statement){let c=ie(i);if(!c)continue;let p=u(c.subject);a.has(p)||s.has(p)||(s.add(p),r.push(_e(n,o,t,Re,`'${e.name}' carries undeclared property '${c.subject.name}' (closed shape).`,{resultPath:c.subject})))}for(let i of e.unresolvedPredicates)s.has(i.key)||(s.add(i.key),r.push(_e(n,o,t,Re,`'${e.name}' carries unresolvable property '${i.key}' (closed shape).`,{value:i.key})))}import*as Ae from"js-yaml";import{VersionOperator as Xn}from"@kanonak-protocol/types/document/models/enums";var Er="0.0.0",L=class{constructor(e,o=new j,t){this.repository=e;this.parser=o;this.objectParser=t??new A(this.parser)}repository;parser;objectParser;imports(){return new T}serializeValue(e,o){return Zn(e,o)}async buildContentAddressed(e){let o=e.book.toImports(),t=await this.hashBody(e.publisher,o,e.body),r=Le(t),a={type:"EphemeralPackage",publisher:e.publisher,imports:o};e.contentHashProperty&&(a[e.contentHashProperty]=t),Object.assign(a,e.header??{}),a.imports=o;let s={[r]:a,...e.body},i=this.dump(s);return{yaml:i,byteCount:Jn(i),contentHash:t,packageName:r,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let o=e.book.toImports(),t={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:o},r;e.contentHashProperty&&(r=await this.hashBody(e.publisher,o,e.body),t[e.contentHashProperty]=r),Object.assign(t,e.header??{}),t.imports=o;let a={[e.name]:t,...e.body},s=this.dump(a),i={yaml:s,byteCount:Jn(s),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return r!==void 0&&(i.contentHash=r),i}dump(e){return Ae.dump(e,{lineWidth:-1})}async hashBody(e,o,t){let r={[Yn]:{type:"EphemeralPackage",publisher:e,imports:o},...t},a=this.parser.parse(Ae.dump(r,{lineWidth:-1})),s=a.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new Q(a,this.repository))).filter(p=>p instanceof g&&p.namespace===s&&p.name!==Yn);for(let p of c)p.namespace="ephemeral";return we(c)}},Yn="__pkgbuilder_probe__";function Jn(n){return new TextEncoder().encode(n).length}function Le(n){let e="sha256:",o=n.startsWith(e)?e.length:0;return`q-${n.slice(o,o+16)}`}var T=class{byKey=new Map;aliases=new Set;ensure(e,o,t,r,a=Xn.Major){let s=`${e}/${o}@${t}`,i=this.byKey.get(s);if(i)return i.alias;let c=this.uniqueAlias(r);return this.byKey.set(s,{publisher:e,package_:o,version:t,alias:c,match:a}),c}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,w(e.version),e.package_)}.${e.name}`}refLatest(e,o,t,r){return`${this.ensure(e,o,Er,r??o,Xn.Any)}.${t}`}toImports(){let e=new Map;for(let t of this.byKey.values()){let r=e.get(t.publisher)??[];r.push(t),e.set(t.publisher,r)}return[...e.keys()].sort().map(t=>({publisher:t,packages:e.get(t).sort((r,a)=>r.package_<a.package_?-1:1).map(r=>({package:r.package_,match:de(r.match),version:r.version,alias:r.alias}))}))}uniqueAlias(e){let o=F(e)||"pkg",t=o,r=2;for(;this.aliases.has(t);)t=`${o}${r++}`;return this.aliases.add(t),t}};function Zn(n,e){if(n!=null){if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof k)return e.ref(n.subject);if(Array.isArray(n)){let o=n.map(t=>Zn(t,e)).filter(t=>t!==void 0);return o.length>0?o:void 0}if(n instanceof E)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(Kr(n))throw new Error(`Value produced a bare URI without a version (${n.publisher}/${n.package_}/${n.name}); cannot serialize it as a reference.`)}}function F(n){return n.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Kr(n){return typeof n=="object"&&n!==null&&typeof n.publisher=="string"&&typeof n.package_=="string"&&typeof n.name=="string"}var xr="1.1.0";async function Qn(n){let e=new L(n.repository),o=e.imports(),t=o.ensure(X,Y,xr,"sh"),r=(i,c)=>i&&i.version&&typeof i.version.major=="number"?`${o.ensure(i.publisher,i.package_,w(i.version),i.package_)}.${i.name}`:c,a={},s=[];return n.result.results.forEach((i,c)=>{let p=`result-${c+1}`;s.push(p);let d={type:`${t}.ValidationResult`,[`${t}.focusNode`]:r(i.focusUri,i.focusNode),[`${t}.resultMessage`]:i.message,[`${t}.resultSeverity`]:`${t}.${i.severity}`,[`${t}.sourceConstraintComponent`]:`${t}.${i.constraintComponent.name}`};i.resultPath&&(d[`${t}.resultPath`]=r(i.resultPath,u(i.resultPath))),i.sourceShapeUri&&(d[`${t}.sourceShape`]=r(i.sourceShapeUri,i.sourceShape)),i.valueRef?d[`${t}.value`]=r(i.valueRef,u(i.valueRef)):i.value!==void 0&&(d[`${t}.value`]=i.value),a[p]=d}),a.report={type:`${t}.ValidationReport`,[`${t}.conforms`]:n.result.conforms,...s.length>0?{[`${t}.result`]:s}:{}},e.buildContentAddressed({publisher:n.publisher,book:o,body:a,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as vi}from"@kanonak-protocol/types/document/models/enums";var se=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,o){return this.producers.find(t=>t.canProduce(e,o))}async produceCached(e,o,t,r){let a=`${o}/${t}@${w(r)}`,s=this.produced.get(a);if(s)return s;let{document:i}=await e.produce(o,t,r);return this.produced.set(a,i),i}async getHighestCompatibleVersionAsync(e,o){let t=this.producerFor(e,o.packageName);if(!t)return null;let r={operator:o.versionOperator,version:o.version},a=await t.resolveVersion(e,o.packageName,r);return a?this.produceCached(t,e,o.packageName,a):null}async getDocumentAsync(e){let o;try{o=Se(e)}catch{return null}if(o.kind!=="package"||!o.version)return null;let t=this.producerFor(o.publisher,o.package_);return t?this.produceCached(t,o.publisher,o.package_,o.version):null}async getDocumentsByNamespaceAsync(e,o){return Array.from(this.produced.values()).filter(t=>{let r=t.metadata.namespace_;return r!=null&&r.publisher===e&&r.package_===o})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var je={async authorize(){return{allowed:!0}}},Ve={async record(){}},B=class extends Error{constructor(o,t){let r=`${o.publisher}/${o.package_}${o.version?`@${o.version.major}.${o.version.minor}.${o.version.patch}`:""}`;super(`Not entitled to produce ${r}${t?`: ${t}`:""}`);this.address=o;this.reason=t;this.name="EntitlementDeniedError"}address;reason},ce=class{inner;ctx;policy;meter;constructor(e,o,t=je,r=Ve){this.inner=e,this.ctx=o,this.policy=t,this.meter=r}canProduce(e,o){return this.inner.canProduce(e,o)}async resolveVersion(e,o,t){return await this.assertAllowed({publisher:e,package_:o,version:t.version}),this.inner.resolveVersion(e,o,t)}async produce(e,o,t){let r={publisher:e,package_:o,version:t};await this.assertAllowed(r);let a=await this.inner.produce(e,o,t);return await this.meter.record(this.ctx,r,a),a}async assertAllowed(e){let o=await this.policy.authorize(this.ctx,e);if(!o.allowed)throw new B(e,o.reason)}};var R="kanonak.org",C="view",et="core-kanonak",wr={publisher:R,package_:C,name:"rootView"},vr={publisher:R,package_:C,name:"bind"},Cr={publisher:R,package_:C,name:"produces"},Ir={publisher:R,package_:C,name:"projections"},_r={publisher:R,package_:C,name:"where"},Ar={publisher:R,package_:C,name:"value"},Lr={publisher:R,package_:C,name:"as"},ue=class{constructor(e,o=new j){this.repository=e;this.parser=o;this.objectParser=new A(this.parser),this.builder=new L(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,o={}){let t=await this.objectParser.parseKanonaks(this.repository),r=this.resolveView(t,e),a=y(r,vr);if(!a)throw new Error(`View ${r.namespace}/${r.name} declares no view.bind; cannot materialize.`);let s=y(r,Cr);if(!s)throw new Error(`View ${r.namespace}/${r.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let i=jr(r),c=nt(t,R,et),p=nt(t,R,C),d=this.builder.imports(),S=d.ensure(R,et,c,"ck"),b=d.ensure(R,C,p,"v"),l=d.ref(s),m=new jn(this.repository,this.parser,this.objectParser),f=new An(m,t),P=this.readProjections(t,r),N=Or(r,_r),O=this.findInstances(t,a,await this.reason(o)),Ne={},ot=new Set;for(let W of O){if(!await this.passesWhere(f,t,N,W))continue;let pe={type:l};for(let $e of P){let rt=await this.evaluateValue(f,t,$e.value,W),Ue=this.builder.serializeValue(tt(rt),d);Ue!==void 0&&(pe[d.ref($e.as)]=Ue)}let Oe=h(W);Oe&&(pe[`${b}.derivedFrom`]=d.ref(Oe)),Ne[this.rowName(W,ot)]=pe}let le={};o.resolvedAt&&(le[`${S}.resolvedAt`]=o.resolvedAt),o.invocationId&&(le[`${S}.id`]=o.invocationId);let U=await this.builder.buildContentAddressed({publisher:i,book:d,body:Ne,contentHashProperty:`${S}.contentHash`,header:le});return{yaml:U.yaml,contentHash:U.contentHash,packageName:U.packageName,publisher:U.publisher,rowCount:U.resourceCount}}resolveView(e,o){let t=K(e,o);if(!t)throw new Error(`View ${o.publisher}/${o.package_}/${o.name} not found in the catalog.`);let r=y(t,wr);if(r){let a=K(e,r);if(!a)throw new Error(`ViewPackage ${o.name} names rootView ${r.name}, which is not in the catalog.`);return a}return t}readProjections(e,o){let t=[];for(let r of _(o,Ir)){let a=r instanceof E?r:r instanceof k?K(e,r.subject):void 0;if(!a)continue;let s=Ee(a,Ar),i=y(a,Lr);s&&i&&t.push({value:s,as:i})}return t}async reason(e){return new H({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,o,t){let r=Nr(e),a=[],s=new Set;for(let i of t.getInstancesOfClass(o)){if(s.has(i))continue;s.add(i);let c=r.get(i);c&&a.push(c)}return a.sort((i,c)=>{let p=M(h(i)),d=M(h(c));return p<d?-1:p>d?1:0}),a}async passesWhere(e,o,t,r){for(let a of t){let s=await this.evaluateValue(e,o,a,r);if(!$r(s))return!1}return!0}async evaluateValue(e,o,t,r){let a=Ln(t,"view-projection",{catalog:o,depth:0}),s=new Map([["input",r]]);return e.evaluate(a,s)}rowName(e,o){let t=F(e.name)||"row",r=t,a=2;for(;o.has(r);)r=`${t}-${a++}`;return o.add(r),r}};function tt(n){return xe(n)?n.value:Array.isArray(n)?n.map(tt):n}function jr(n){let e=h(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function nt(n,e,o){let t=Vr(n,e,o);if(!t)throw new Error(`Package ${e}/${o} is not in the catalog; it must be importable to materialize a view.`);return t}function Vr(n,e,o){let t;for(let r of n){if(!(r instanceof g))continue;let a=h(r);!a||a.publisher!==e||a.package_!==o||!a.version||(!t||z(a.version,t)>0)&&(t=a.version)}return t?w(t):void 0}function Nr(n){let e=new Map,o=new Map;for(let t of n){if(!(t instanceof g))continue;let r=h(t);if(!r||!r.version)continue;let a=M(r),s=o.get(a);(!s||z(r.version,s)>0)&&(o.set(a,r.version),e.set(a,t))}return e}function Or(n,e){let o=Ee(n,e);return o?[o]:_(n,e).filter(t=>t instanceof E)}function $r(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:xe(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{_o as AmbiguousReferenceRule,ye as BooleanStatement,Yo as CANONICAL_FORM_VERSION,V as Carrier,Oo as ClassDefinitionRule,Eo as ClassHierarchyCycleRule,kt as CompositeKanonakDocumentRepository,Zo as DEFAULT_CONSENT_BINDING_PARAM,jt as DefinedKanonak,Go as DiamondNameClashRule,Uo as DisplayLensScopeRule,ft as DocumentLocation,Yt as EdgeType,E as EmbeddedKanonak,bo as EmbeddedKanonakTypeRule,he as EmbeddedStatement,B as EntitlementDeniedError,ce as EntitlementProducer,mt as FileSystemKanonakDocumentRepository,to as GitIgnoreFilter,Jt as GraphBuilder,vt as HttpKanonakDocumentRepository,De as INTEGRITY_PREFIX,T as ImportBook,Po as ImportExistenceRule,me as InMemoryKanonakDocumentRepository,gt as KANONAK_USER_AGENT,Lt as Kanonak,ro as KanonakDocumentPositions,A as KanonakObjectParser,qo as KanonakObjectValidator,j as KanonakParser,Vt as KanonakUri,so as KanonakUriBuilder,co as KanonakUrlResolver,Ft as KanonakVocabulary,q as ListStatement,D as LiteralKanonak,Ct as LocalFirstRepository,It as LockAwareRepository,Mo as LookBandPathRule,To as LookRenderer,Do as LookSemanticSvgPathRule,$o as MarkdownLinkRule,ge as MarkdownStatement,Co as NamespaceImportCycleRule,ko as NamespacePrefixRule,Xt as NodeType,ke as NumberStatement,Qo as OAuthDiscovery,eo as OWL_RL_CLASSIFICATION_RULES,Lo as ObjectPropertyValueValidationRule,po as OntologyValidationError,uo as OntologyValidationResult,zo as OwlOneOfRule,L as PackageBuilder,So as PackageHeaderRule,se as ProducerRepository,jo as PropertyDomainRule,Ko as PropertyHierarchyCycleRule,Vo as PropertyKindRangeConsistencyRule,oo as PropertyMetadata,Ao as PropertyRangeReferenceRule,xo as PropertyRangeRequiredRule,ho as PropertyTypeSpecificityRule,Kt as PublisherConfigResolver,xt as PublisherIndex,Qt as RDFS_RULES,H as Reasoner,no as ReasoningResult,k as ReferenceKanonak,G as ReferenceStatement,ht as RepositoryFactory,No as ReservedNameShadowRule,yo as ResourceNamingRule,$t as ResourceResolver,Bt as ResourceTypeClassifier,Y as SHACL_PACKAGE,X as SHACL_PUBLISHER,J as SH_NODE_SHAPE,Be as SH_PROPERTY_SHAPE,Fe as SH_SHAPE,Ot as ScalarStatement,Wo as ShaclShapeRule,Nt as Statement,fe as StringStatement,wo as SubClassOfReferenceRule,vo as SubPropertyOfReferenceRule,g as SubjectKanonak,go as SubjectKanonakTypeRequiredRule,tr as TokenCredentialProvider,Zt as TripleStore,Bo as TxExpressionPathRule,Ut as TypeResolver,Io as UnresolvedPredicateRule,Ro as UnresolvedReferenceRule,fo as ValidationCache,mo as ValidationContext,lo as ValidationSeverity,vi as VersionOperator,ue as ViewMaterializer,je as allowAllPolicy,Pt as assertHttpsUrl,wt as assertPackageIdentity,At as buildLocalFirstRepository,rr as buildOntologyModel,Qn as buildReportPackageAsync,te as buildShapesModel,Xo as canonicalForm,we as canonicalHash,Ke as carrierOf,_t as collectKanonakFiles,z as compareVersions,On as computeIntegrity,Te as computeIntegrityAsync,Le as contentAddressedName,ne as contextTypesOf,nr as createCredentialedFetch,st as createVersion,Gn as evaluateConformance,qt as extractMarkdownLinks,or as findDerivation,Gt as findMalformedReferences,io as findMarkdownLinkAt,Ie as foldFlagsIntoPattern,Dt as formatKanonakAddress,w as formatVersion,yt as getGlobalCachePath,bt as getKanonakUserAgent,ut as isCompatibleVersion,lt as isMajorCompatible,Rt as kanonakFetch,Vn as loadLockFile,ae as lowerConstraint,Mt as makeUriKey,Ve as noopMeter,Jo as normalizeHost,er as parseAuthChallenge,Se as parseKanonakAddress,Me as parseLockFile,ct as parseVersionString,ao as parseWithPositions,dt as pickHighestDocument,Wt as propertiesInScope,Ho as resolveDisplayValue,zt as resolvePropertyStep,F as sanitizeName,pt as satisfiesVersionOperator,Nn as saveLockFile,Un as scopeFromCatalog,Dn as scopeFromDocumentAsync,$n as scopeFromRepositoryAsync,He as serializeLockFile,Et as setKanonakFetchRetries,St as setKanonakUserAgent,h as subjectUri,ee as superClassChain,Fo as supportedBandKeys,Ht as tripleKey,M as uriKey,Tt as uriTriple,at as versionOperatorFromChar,de as versionOperatorToChar,it as versionsEqual};
|
|
1
|
+
import{a as Zt,b as Qt,c as eo,d as no,e as H}from"./chunk-GJAYU443.js";import{a as Vn,b as Nn,c as On}from"./chunk-D66LUZDB.js";import{a as Xt,b as Yt,c as Jt,d as Yo,e as we,f as Jo,g as Zo,h as Qo,i as er,j as nr,k as tr,l as or,m as ar}from"./chunk-KDMBMX3J.js";import{a as rr}from"./chunk-S2VGNHHF.js";import{a as mt,b as ft,c as kt,d as yt,e as ht,f as Ct,g as It,h as _t,i as At}from"./chunk-JFBPQN6T.js";import{a as gt,b as St,c as bt,d as Pt,e as Rt,f as Et,h as Kt,i as De,j as Me,k as He,l as Te,m as xt,n as vt}from"./chunk-P5VQEDBS.js";import{a as oo,b as ro,c as ao,d as io}from"./chunk-RJK6Y4HS.js";import{a as so}from"./chunk-PEB52US5.js";import{a as wt}from"./chunk-SC5M74NM.js";import{A as Oo,B as $o,C as Uo,D as Do,E as Mo,F as Ho,G as Wo,H as zo,I as Go,L as qo,M as Xo,a as uo,b as lo,c as po,d as mo,e as fo,f as ko,g as yo,h as ho,i as go,j as So,k as bo,l as Po,m as Ro,n as Eo,o as Ko,p as xo,q as wo,r as vo,s as Co,t as Io,u as _o,v as Ao,w as Lo,x as jo,y as Vo,z as No}from"./chunk-SR6I5ZSI.js";import"./chunk-BRCVOR7A.js";import{c as An,d as To,f as xe,h as Ln,i as jn,j as Fo,k as Bo}from"./chunk-TW7NJDMW.js";import{a as me}from"./chunk-6VIUXP4N.js";import{a as E,b as D,c as ge,i as V,j as Ke,k as Gt,l as qt,m as A}from"./chunk-SUXSCSHO.js";import{a as j}from"./chunk-KOWDHKBN.js";import{a as co}from"./chunk-PEJALHXK.js";import{$ as Re,A as tn,B as on,C as rn,D as an,E as sn,F as cn,G as un,H as ln,I as pn,J as dn,K as mn,L as fn,M as Pe,N as kn,O as yn,P as hn,Q as gn,R as Sn,S as bn,T as Pn,U as Rn,V as En,W as Kn,X as xn,Y as wn,Z as vn,_ as Cn,a as $t,b as Ut,c as Se,d as Dt,da as Ft,e as M,f as Mt,fa as Bt,g as Ht,ga as h,ha as ee,i as Tt,j as X,k as Y,l as Fe,m as J,ma as Wt,n as Be,na as zt,o as We,oa as ne,p as ze,q as Ge,r as qe,s as Xe,t as Ye,u as Je,v as be,w as Ze,x as Qe,y as en,z as nn}from"./chunk-BA4HAURJ.js";import{A as _,B as Q,a as Lt,b as jt,c as g,d as k,e as Nt,f as Ot,g as fe,h as ke,i as ye,j as G,k as he,l as q,m as u,r as In,t as K,v as _n,w as I,x as Z,y,z as Ee}from"./chunk-N3XODYH5.js";import{a as Vt}from"./chunk-FUUTGGJS.js";import{a as at,b as de,c as z,d as it,e as w,f as st,g as ct,h as ut,i as lt,j as pt,k as dt}from"./chunk-QILEJIFU.js";import{a as to}from"./chunk-ODIECDN7.js";async function $n(n){let e=await new A().parseKanonaks(n),o=await new H().reason(n);return{kind:"merged",catalog:e,reasoning:o}}function Un(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function Dn(n,e){let o=e??new me(new j);return{kind:"standalone",catalog:await new A().parseKanonaks(new Q(n,o))}}function $(n){return typeof n=="number"?n:void 0}function ir(n){if(!n)return;let e=u(n);if(e===u(dn))return"IRI";if(e===u(mn))return"BlankNode";if(e===u(fn))return"Literal"}function Mn(n){if(!n)return;let e=u(n);if(e===u(kn))return"Violation";if(e===u(yn))return"Warning";if(e===u(hn))return"Info"}function ve(n,e){let o=y(n,e);if(o)return[o];let t=[];for(let r of _(n,e))r instanceof k&&t.push(r.subject);return t}function sr(n,e){let o=y(n,Ge);if(!o)return;let t={path:o},r=$(I(n,qe)),a=$(I(n,Xe));r!==void 0&&(t.minCount=r),a!==void 0&&(t.maxCount=a);let s=$(I(n,en)),i=$(I(n,nn));s!==void 0&&(t.minLength=s),i!==void 0&&(t.maxLength=i);let c=$(I(n,tn)),p=$(I(n,on));c!==void 0&&(t.minInclusive=c),p!==void 0&&(t.maxInclusive=p);let d=Z(n,Ze);if(d!==void 0){let P=Z(n,Qe);t.pattern=P!==void 0?{regex:d,flags:P}:{regex:d}}if(_n(n,be)){let P=[],N=[];for(let O of _(n,be))O instanceof D?P.push(O.value):O instanceof k&&N.push(O.subject);P.length>0&&(t.inValues=P),N.length>0&&(t.inRefs=N)}let S=y(n,Ye);S&&(t.datatype=S);let b=y(n,Je);b&&(t.classRef=b);let l=ir(y(n,pn));l&&(t.nodeKind=l);let m=Z(n,rn);m!==void 0&&(t.message=m);let f=Mn(y(n,Pe))??e;return f&&(t.severity=f),t}function te(n){let e=[];for(let o of n){if(!(o instanceof g)||!In(o,J))continue;let t=Mn(y(o,Pe)),r={name:o.name,uri:h(o),targetClass:y(o,We),targetNodes:ve(o,an),targetSubjectsOf:ve(o,sn),targetObjectsOf:ve(o,cn),closed:I(o,un)===!0,ignoredProperties:[],severity:t,properties:[]};for(let a of _(o,ln))a instanceof k&&r.ignoredProperties.push(a.subject);for(let a of _(o,ze)){let s;if(a instanceof E?s=a:a instanceof k&&(s=K(n,a.subject)),!s)continue;let i=sr(s,t);i&&r.properties.push(i)}e.push(r)}return e}var x="kanonak.org/transformations",oe="values";var re="allowed",v=n=>({type:`${x}/VarRef`,varName:n}),Ce=n=>({type:`${x}/IntegerLiteral`,integerLiteral:n}),cr=n=>({type:`${x}/DecimalLiteral`,decimalLiteral:n}),Hn=n=>Number.isInteger(n)?Ce(n):cr(n),Tn=n=>({type:`${x}/Count`,source:n}),Fn=(n,e)=>({type:`${x}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),Bn=(n,e)=>({type:`${x}/LessThanOrEqual`,compareLeft:n,compareRight:e});function Ie(n,e){if(!e||e.length===0)return n;let o=new Set(["i","m","s"]),t=[...new Set(e.split(""))];if(t.filter(a=>!o.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${t.sort().join("")})${n}`}function ae(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Fn(Tn(v(oe)),Ce(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:Bn(Tn(v(oe)),Ce(n.maxCount))}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${x}/Contains`,haystack:v(re),needle:v("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:Ie(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Fn(v("v"),Hn(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:Bn(v("v"),Hn(n.maxInclusive))}),e}import{evaluate as lr,ExpressionError as pr}from"@kanonak-protocol/expression";function Gn(n,e){let o=dr(e)?e:te(e),t=[];for(let r of o)for(let a of mr(n,r))yr(n,r,a,t);return{conforms:!t.some(r=>r.severity==="Violation"),results:t}}function dr(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function ie(n){let e=n.predicate;return e instanceof k?e:void 0}function mr(n,e){let o=new Map,t=n.catalog.filter(a=>a instanceof g),r=a=>{let s=h(a);o.set(s?u(s):`${a.namespace}/${a.name}`,a)};if(e.targetClass){let a=u(e.targetClass);if(n.reasoning){let s=new Set(n.reasoning.getInstancesOfClass(e.targetClass));for(let i of t){let c=h(i);c&&s.has(u(c))&&r(i)}}else for(let s of t)ne(s).some(c=>u(c)===a||ee(n.catalog,c).some(p=>u(p)===a))&&r(s)}for(let a of e.targetNodes){let s=K(n.catalog,a);s instanceof g&&r(s)}for(let a of e.targetSubjectsOf){let s=u(a);for(let i of t)i.statement.some(c=>{let p=ie(c);return p&&u(p.subject)===s})&&r(i)}for(let a of e.targetObjectsOf){let s=u(a);for(let i of t)for(let c of i.statement){let p=ie(c);if(!(!p||u(p.subject)!==s))for(let d of fr(c)){let S=K(n.catalog,d);S instanceof g&&r(S)}}}return[...o.values()]}function fr(n){return n instanceof G?[n.object.subject]:n instanceof q?(n.object??[]).filter(e=>e instanceof k).map(e=>e.subject):[]}function kr(n,e,o){let t=[];for(let r of n.statement){let a=ie(r);if(!(!a||u(a.subject)!==e)){if(r instanceof fe||r instanceof ge)t.push({kernel:r.object,kind:"string",literal:r.object});else if(r instanceof ke)t.push({kernel:r.object,kind:"number",literal:r.object});else if(r instanceof ye)t.push({kernel:r.object?1:0,kind:"boolean",literal:r.object});else if(r instanceof G)t.push({kernel:{ref:u(r.object.subject)},kind:"reference",ref:r.object.subject});else if(r instanceof he)t.push(Wn(r.object,o,t.length));else if(r instanceof q){for(let s of r.object??[])if(s instanceof k)t.push({kernel:{ref:u(s.subject)},kind:"reference",ref:s.subject});else if(s instanceof E)t.push(Wn(s,o,t.length));else if(s instanceof D){let i=s.value;typeof i=="boolean"?t.push({kernel:i?1:0,kind:"boolean",literal:i}):t.push({kernel:i,kind:typeof i=="number"?"number":"string",literal:i})}}}}return t}function Wn(n,e,o){let t=n.name&&n.name.length>0?n.name:String(o);return{kernel:{ref:`${e}#${t}`},kind:"embedded"}}function yr(n,e,o,t){let r=h(o),a=r?u(r):`${o.namespace}/${o.name}`;for(let s of e.properties)gr(n,e,o,a,r,s,t);e.closed&&Er(e,o,a,r,t)}function _e(n,e,o,t,r,a={},s){return{focusNode:e,focusUri:o,constraintComponent:t,severity:s??qn(n),message:r,sourceShape:n.name,sourceShapeUri:n.uri,...a}}function qn(n){return n.severity??"Violation"}var hr={minCount:gn,maxCount:Sn,in:Rn,pattern:En,minLength:Kn,maxLength:xn,minInclusive:wn,maxInclusive:vn};function gr(n,e,o,t,r,a,s){let i=u(a.path),c=kr(o,i,t),p=a.severity??qn(e),d=a.path.name,S=[...(a.inValues??[]).map(l=>typeof l=="boolean"?l?1:0:l),...(a.inRefs??[]).map(l=>({ref:u(l)}))],b=(l,m,f)=>{s.push(_e(e,t,r,l,a.message??m,{resultPath:a.path,value:f?.literal,valueRef:f?.ref},p))};for(let l of ae(a)){let m=hr[l.component];if(l.per==="node"){zn(l,{[oe]:c.map(P=>P.kernel),[re]:S})||b(m,l.component==="minCount"?`'${d}' has ${c.length} value(s); minCount is ${a.minCount}.`:`'${d}' has ${c.length} value(s); maxCount is ${a.maxCount}.`);continue}for(let f of c){if((l.component==="pattern"||l.component==="minLength"||l.component==="maxLength")&&f.kind!=="string"){b(m,`'${d}' value is not a string; ${l.component} applies to string values.`,f);continue}zn(l,{v:f.kernel,[re]:S})||b(m,Sr(l,d,a,f),f)}}if(a.nodeKind)for(let l of c)br(a.nodeKind,l)||b(Cn,`'${d}' value is ${l.kind}; nodeKind requires ${a.nodeKind}.`,l);if(a.datatype)for(let l of c){let m=Pr(a.datatype,l);m&&b(bn,`'${d}' ${m}`,l)}if(a.classRef)for(let l of c){let m=Rr(n,a.classRef,l);m&&b(Pn,`'${d}' ${m}`,l)}}function Sr(n,e,o,t){let r=t.ref?u(t.ref):JSON.stringify(t.literal);switch(n.component){case"in":return`'${e}' value ${r} is not in the permitted set.`;case"pattern":return`'${e}' value ${r} does not match pattern ${o.pattern?.regex}.`;case"minLength":return`'${e}' value ${r} is shorter than minLength ${o.minLength}.`;case"maxLength":return`'${e}' value ${r} is longer than maxLength ${o.maxLength}.`;case"minInclusive":return`'${e}' value ${r} is below minInclusive ${o.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${r} is above maxInclusive ${o.maxInclusive} (or not numeric).`;default:return`'${e}' value ${r} violates ${n.component}.`}}function zn(n,e){let o=t=>{let r=t.varName;if(t.type==="kanonak.org/transformations/VarRef"&&typeof r=="string"&&r in e)return e[r];throw new pr(`Conformance lowering produced an unexpected leaf '${t.type}'`)};return lr(n.expr,void 0,o)===1}function br(n,e){switch(n){case"IRI":return e.kind==="reference";case"BlankNode":return e.kind==="embedded";case"Literal":return e.kind==="string"||e.kind==="number"||e.kind==="boolean"}}function Pr(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let o=Ke(n);if(o!==void 0)switch(o){case V.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case V.Integer:return e.kind!=="number"?`value is not a number (${n.name}).`:Number.isInteger(e.literal)?void 0:`value is not an integer (${n.name}).`;case V.Decimal:case V.Double:case V.Float:return e.kind==="number"?void 0:`value is not a number (${n.name}).`;default:return e.kind==="string"?void 0:`value is not a string-carried literal (${n.name}).`}}function Rr(n,e,o){if(o.kind!=="reference"||!o.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;let t=u(e);if(n.reasoning)return n.reasoning.isInstanceOf(o.ref,e)?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`;let r=K(n.catalog,o.ref);return r instanceof g?ne(r).some(s=>u(s)===t||ee(n.catalog,s).some(i=>u(i)===t))?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`:`value ${u(o.ref)} does not resolve in this scope (sh:class ${e.name}).`}function Er(n,e,o,t,r){let a=new Set([...n.properties.map(i=>u(i.path)),...n.ignoredProperties.map(i=>u(i))]),s=new Set;for(let i of e.statement){let c=ie(i);if(!c)continue;let p=u(c.subject);a.has(p)||s.has(p)||(s.add(p),r.push(_e(n,o,t,Re,`'${e.name}' carries undeclared property '${c.subject.name}' (closed shape).`,{resultPath:c.subject})))}for(let i of e.unresolvedPredicates)s.has(i.key)||(s.add(i.key),r.push(_e(n,o,t,Re,`'${e.name}' carries unresolvable property '${i.key}' (closed shape).`,{value:i.key})))}import*as Ae from"js-yaml";import{VersionOperator as Xn}from"@kanonak-protocol/types/document/models/enums";var Kr="0.0.0",L=class{constructor(e,o=new j,t){this.repository=e;this.parser=o;this.objectParser=t??new A(this.parser)}repository;parser;objectParser;imports(){return new T}serializeValue(e,o){return Zn(e,o)}async buildContentAddressed(e){let o=e.book.toImports(),t=await this.hashBody(e.publisher,o,e.body),r=Le(t),a={type:"EphemeralPackage",publisher:e.publisher,imports:o};e.contentHashProperty&&(a[e.contentHashProperty]=t),Object.assign(a,e.header??{}),a.imports=o;let s={[r]:a,...e.body},i=this.dump(s);return{yaml:i,byteCount:Jn(i),contentHash:t,packageName:r,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let o=e.book.toImports(),t={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:o},r;e.contentHashProperty&&(r=await this.hashBody(e.publisher,o,e.body),t[e.contentHashProperty]=r),Object.assign(t,e.header??{}),t.imports=o;let a={[e.name]:t,...e.body},s=this.dump(a),i={yaml:s,byteCount:Jn(s),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return r!==void 0&&(i.contentHash=r),i}dump(e){return Ae.dump(e,{lineWidth:-1})}async hashBody(e,o,t){let r={[Yn]:{type:"EphemeralPackage",publisher:e,imports:o},...t},a=this.parser.parse(Ae.dump(r,{lineWidth:-1})),s=a.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new Q(a,this.repository))).filter(p=>p instanceof g&&p.namespace===s&&p.name!==Yn);for(let p of c)p.namespace="ephemeral";return we(c)}},Yn="__pkgbuilder_probe__";function Jn(n){return new TextEncoder().encode(n).length}function Le(n){let e="sha256:",o=n.startsWith(e)?e.length:0;return`q-${n.slice(o,o+16)}`}var T=class{byKey=new Map;aliases=new Set;ensure(e,o,t,r,a=Xn.Major){let s=`${e}/${o}@${t}`,i=this.byKey.get(s);if(i)return i.alias;let c=this.uniqueAlias(r);return this.byKey.set(s,{publisher:e,package_:o,version:t,alias:c,match:a}),c}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,w(e.version),e.package_)}.${e.name}`}refLatest(e,o,t,r){return`${this.ensure(e,o,Kr,r??o,Xn.Any)}.${t}`}toImports(){let e=new Map;for(let t of this.byKey.values()){let r=e.get(t.publisher)??[];r.push(t),e.set(t.publisher,r)}return[...e.keys()].sort().map(t=>({publisher:t,packages:e.get(t).sort((r,a)=>r.package_<a.package_?-1:1).map(r=>({package:r.package_,match:de(r.match),version:r.version,alias:r.alias}))}))}uniqueAlias(e){let o=F(e)||"pkg",t=o,r=2;for(;this.aliases.has(t);)t=`${o}${r++}`;return this.aliases.add(t),t}};function Zn(n,e){if(n!=null){if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof k)return e.ref(n.subject);if(Array.isArray(n)){let o=n.map(t=>Zn(t,e)).filter(t=>t!==void 0);return o.length>0?o:void 0}if(n instanceof E)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(xr(n))throw new Error(`Value produced a bare URI without a version (${n.publisher}/${n.package_}/${n.name}); cannot serialize it as a reference.`)}}function F(n){return n.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function xr(n){return typeof n=="object"&&n!==null&&typeof n.publisher=="string"&&typeof n.package_=="string"&&typeof n.name=="string"}var wr="1.1.0";async function Qn(n){let e=new L(n.repository),o=e.imports(),t=o.ensure(X,Y,wr,"sh"),r=(i,c)=>i&&i.version&&typeof i.version.major=="number"?`${o.ensure(i.publisher,i.package_,w(i.version),i.package_)}.${i.name}`:c,a={},s=[];return n.result.results.forEach((i,c)=>{let p=`result-${c+1}`;s.push(p);let d={type:`${t}.ValidationResult`,[`${t}.focusNode`]:r(i.focusUri,i.focusNode),[`${t}.resultMessage`]:i.message,[`${t}.resultSeverity`]:`${t}.${i.severity}`,[`${t}.sourceConstraintComponent`]:`${t}.${i.constraintComponent.name}`};i.resultPath&&(d[`${t}.resultPath`]=r(i.resultPath,u(i.resultPath))),i.sourceShapeUri&&(d[`${t}.sourceShape`]=r(i.sourceShapeUri,i.sourceShape)),i.valueRef?d[`${t}.value`]=r(i.valueRef,u(i.valueRef)):i.value!==void 0&&(d[`${t}.value`]=i.value),a[p]=d}),a.report={type:`${t}.ValidationReport`,[`${t}.conforms`]:n.result.conforms,...s.length>0?{[`${t}.result`]:s}:{}},e.buildContentAddressed({publisher:n.publisher,book:o,body:a,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as Ci}from"@kanonak-protocol/types/document/models/enums";var se=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,o){return this.producers.find(t=>t.canProduce(e,o))}async produceCached(e,o,t,r){let a=`${o}/${t}@${w(r)}`,s=this.produced.get(a);if(s)return s;let{document:i}=await e.produce(o,t,r);return this.produced.set(a,i),i}async getHighestCompatibleVersionAsync(e,o){let t=this.producerFor(e,o.packageName);if(!t)return null;let r={operator:o.versionOperator,version:o.version},a=await t.resolveVersion(e,o.packageName,r);return a?this.produceCached(t,e,o.packageName,a):null}async getDocumentAsync(e){let o;try{o=Se(e)}catch{return null}if(o.kind!=="package"||!o.version)return null;let t=this.producerFor(o.publisher,o.package_);return t?this.produceCached(t,o.publisher,o.package_,o.version):null}async getDocumentsByNamespaceAsync(e,o){return Array.from(this.produced.values()).filter(t=>{let r=t.metadata.namespace_;return r!=null&&r.publisher===e&&r.package_===o})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var je={async authorize(){return{allowed:!0}}},Ve={async record(){}},B=class extends Error{constructor(o,t){let r=`${o.publisher}/${o.package_}${o.version?`@${o.version.major}.${o.version.minor}.${o.version.patch}`:""}`;super(`Not entitled to produce ${r}${t?`: ${t}`:""}`);this.address=o;this.reason=t;this.name="EntitlementDeniedError"}address;reason},ce=class{inner;ctx;policy;meter;constructor(e,o,t=je,r=Ve){this.inner=e,this.ctx=o,this.policy=t,this.meter=r}canProduce(e,o){return this.inner.canProduce(e,o)}async resolveVersion(e,o,t){return await this.assertAllowed({publisher:e,package_:o,version:t.version}),this.inner.resolveVersion(e,o,t)}async produce(e,o,t){let r={publisher:e,package_:o,version:t};await this.assertAllowed(r);let a=await this.inner.produce(e,o,t);return await this.meter.record(this.ctx,r,a),a}async assertAllowed(e){let o=await this.policy.authorize(this.ctx,e);if(!o.allowed)throw new B(e,o.reason)}};var R="kanonak.org",C="view",et="core-kanonak",vr={publisher:R,package_:C,name:"rootView"},Cr={publisher:R,package_:C,name:"bind"},Ir={publisher:R,package_:C,name:"produces"},_r={publisher:R,package_:C,name:"projections"},Ar={publisher:R,package_:C,name:"where"},Lr={publisher:R,package_:C,name:"value"},jr={publisher:R,package_:C,name:"as"},ue=class{constructor(e,o=new j){this.repository=e;this.parser=o;this.objectParser=new A(this.parser),this.builder=new L(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,o={}){let t=await this.objectParser.parseKanonaks(this.repository),r=this.resolveView(t,e),a=y(r,Cr);if(!a)throw new Error(`View ${r.namespace}/${r.name} declares no view.bind; cannot materialize.`);let s=y(r,Ir);if(!s)throw new Error(`View ${r.namespace}/${r.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let i=Vr(r),c=nt(t,R,et),p=nt(t,R,C),d=this.builder.imports(),S=d.ensure(R,et,c,"ck"),b=d.ensure(R,C,p,"v"),l=d.ref(s),m=new jn(this.repository,this.parser,this.objectParser),f=new Ln(m,t),P=this.readProjections(t,r),N=$r(r,Ar),O=this.findInstances(t,a,await this.reason(o)),Ne={},ot=new Set;for(let W of O){if(!await this.passesWhere(f,t,N,W))continue;let pe={type:l};for(let $e of P){let rt=await this.evaluateValue(f,t,$e.value,W),Ue=this.builder.serializeValue(tt(rt),d);Ue!==void 0&&(pe[d.ref($e.as)]=Ue)}let Oe=h(W);Oe&&(pe[`${b}.derivedFrom`]=d.ref(Oe)),Ne[this.rowName(W,ot)]=pe}let le={};o.resolvedAt&&(le[`${S}.resolvedAt`]=o.resolvedAt),o.invocationId&&(le[`${S}.id`]=o.invocationId);let U=await this.builder.buildContentAddressed({publisher:i,book:d,body:Ne,contentHashProperty:`${S}.contentHash`,header:le});return{yaml:U.yaml,contentHash:U.contentHash,packageName:U.packageName,publisher:U.publisher,rowCount:U.resourceCount}}resolveView(e,o){let t=K(e,o);if(!t)throw new Error(`View ${o.publisher}/${o.package_}/${o.name} not found in the catalog.`);let r=y(t,vr);if(r){let a=K(e,r);if(!a)throw new Error(`ViewPackage ${o.name} names rootView ${r.name}, which is not in the catalog.`);return a}return t}readProjections(e,o){let t=[];for(let r of _(o,_r)){let a=r instanceof E?r:r instanceof k?K(e,r.subject):void 0;if(!a)continue;let s=Ee(a,Lr),i=y(a,jr);s&&i&&t.push({value:s,as:i})}return t}async reason(e){return new H({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,o,t){let r=Or(e),a=[],s=new Set;for(let i of t.getInstancesOfClass(o)){if(s.has(i))continue;s.add(i);let c=r.get(i);c&&a.push(c)}return a.sort((i,c)=>{let p=M(h(i)),d=M(h(c));return p<d?-1:p>d?1:0}),a}async passesWhere(e,o,t,r){for(let a of t){let s=await this.evaluateValue(e,o,a,r);if(!Ur(s))return!1}return!0}async evaluateValue(e,o,t,r){let a=An(t,"view-projection",{catalog:o,depth:0}),s=new Map([["input",r]]);return e.evaluate(a,s)}rowName(e,o){let t=F(e.name)||"row",r=t,a=2;for(;o.has(r);)r=`${t}-${a++}`;return o.add(r),r}};function tt(n){return xe(n)?n.value:Array.isArray(n)?n.map(tt):n}function Vr(n){let e=h(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function nt(n,e,o){let t=Nr(n,e,o);if(!t)throw new Error(`Package ${e}/${o} is not in the catalog; it must be importable to materialize a view.`);return t}function Nr(n,e,o){let t;for(let r of n){if(!(r instanceof g))continue;let a=h(r);!a||a.publisher!==e||a.package_!==o||!a.version||(!t||z(a.version,t)>0)&&(t=a.version)}return t?w(t):void 0}function Or(n){let e=new Map,o=new Map;for(let t of n){if(!(t instanceof g))continue;let r=h(t);if(!r||!r.version)continue;let a=M(r),s=o.get(a);(!s||z(r.version,s)>0)&&(o.set(a,r.version),e.set(a,t))}return e}function $r(n,e){let o=Ee(n,e);return o?[o]:_(n,e).filter(t=>t instanceof E)}function Ur(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:xe(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{_o as AmbiguousReferenceRule,ye as BooleanStatement,Jo as CANONICAL_FORM_VERSION,V as Carrier,Oo as ClassDefinitionRule,Eo as ClassHierarchyCycleRule,kt as CompositeKanonakDocumentRepository,Qo as DEFAULT_CONSENT_BINDING_PARAM,jt as DefinedKanonak,qo as DiamondNameClashRule,Uo as DisplayLensScopeRule,ft as DocumentLocation,Yt as EdgeType,E as EmbeddedKanonak,bo as EmbeddedKanonakTypeRule,he as EmbeddedStatement,B as EntitlementDeniedError,ce as EntitlementProducer,mt as FileSystemKanonakDocumentRepository,to as GitIgnoreFilter,Jt as GraphBuilder,vt as HttpKanonakDocumentRepository,De as INTEGRITY_PREFIX,T as ImportBook,Po as ImportExistenceRule,me as InMemoryKanonakDocumentRepository,gt as KANONAK_USER_AGENT,Lt as Kanonak,ro as KanonakDocumentPositions,A as KanonakObjectParser,Xo as KanonakObjectValidator,j as KanonakParser,Vt as KanonakUri,so as KanonakUriBuilder,co as KanonakUrlResolver,Ft as KanonakVocabulary,q as ListStatement,D as LiteralKanonak,Ct as LocalFirstRepository,It as LockAwareRepository,Ho as LookBandPathRule,Fo as LookRenderer,Do as LookSemanticSvgPathRule,$o as MarkdownLinkRule,ge as MarkdownStatement,Co as NamespaceImportCycleRule,ko as NamespacePrefixRule,Xt as NodeType,ke as NumberStatement,er as OAuthDiscovery,eo as OWL_RL_CLASSIFICATION_RULES,Lo as ObjectPropertyValueValidationRule,po as OntologyValidationError,uo as OntologyValidationResult,Go as OwlOneOfRule,L as PackageBuilder,So as PackageHeaderRule,se as ProducerRepository,jo as PropertyDomainRule,Ko as PropertyHierarchyCycleRule,Vo as PropertyKindRangeConsistencyRule,oo as PropertyMetadata,Ao as PropertyRangeReferenceRule,xo as PropertyRangeRequiredRule,ho as PropertyTypeSpecificityRule,Kt as PublisherConfigResolver,xt as PublisherIndex,Qt as RDFS_RULES,H as Reasoner,no as ReasoningResult,k as ReferenceKanonak,G as ReferenceStatement,ht as RepositoryFactory,No as ReservedNameShadowRule,yo as ResourceNamingRule,$t as ResourceResolver,Bt as ResourceTypeClassifier,Y as SHACL_PACKAGE,X as SHACL_PUBLISHER,J as SH_NODE_SHAPE,Be as SH_PROPERTY_SHAPE,Fe as SH_SHAPE,Ot as ScalarStatement,zo as ShaclShapeRule,Nt as Statement,fe as StringStatement,wo as SubClassOfReferenceRule,vo as SubPropertyOfReferenceRule,g as SubjectKanonak,go as SubjectKanonakTypeRequiredRule,or as TokenCredentialProvider,Zt as TripleStore,Mo as TxExpressionCompilesRule,Wo as TxExpressionPathRule,Ut as TypeResolver,Io as UnresolvedPredicateRule,Ro as UnresolvedReferenceRule,fo as ValidationCache,mo as ValidationContext,lo as ValidationSeverity,Ci as VersionOperator,ue as ViewMaterializer,je as allowAllPolicy,Pt as assertHttpsUrl,wt as assertPackageIdentity,At as buildLocalFirstRepository,ar as buildOntologyModel,Qn as buildReportPackageAsync,te as buildShapesModel,Yo as canonicalForm,we as canonicalHash,Ke as carrierOf,_t as collectKanonakFiles,z as compareVersions,On as computeIntegrity,Te as computeIntegrityAsync,Le as contentAddressedName,ne as contextTypesOf,tr as createCredentialedFetch,st as createVersion,Gn as evaluateConformance,qt as extractMarkdownLinks,rr as findDerivation,Gt as findMalformedReferences,io as findMarkdownLinkAt,Ie as foldFlagsIntoPattern,Dt as formatKanonakAddress,w as formatVersion,yt as getGlobalCachePath,bt as getKanonakUserAgent,ut as isCompatibleVersion,lt as isMajorCompatible,Rt as kanonakFetch,Vn as loadLockFile,ae as lowerConstraint,Mt as makeUriKey,Ve as noopMeter,Zo as normalizeHost,nr as parseAuthChallenge,Se as parseKanonakAddress,Me as parseLockFile,ct as parseVersionString,ao as parseWithPositions,dt as pickHighestDocument,Wt as propertiesInScope,To as resolveDisplayValue,zt as resolvePropertyStep,F as sanitizeName,pt as satisfiesVersionOperator,Nn as saveLockFile,Un as scopeFromCatalog,Dn as scopeFromDocumentAsync,$n as scopeFromRepositoryAsync,He as serializeLockFile,Et as setKanonakFetchRetries,St as setKanonakUserAgent,h as subjectUri,ee as superClassChain,Bo as supportedBandKeys,Ht as tripleKey,M as uriKey,Tt as uriTriple,at as versionOperatorFromChar,de as versionOperatorToChar,it as versionsEqual};
|
|
@@ -3,7 +3,16 @@ import type { DefinedKanonak } from './DefinedKanonak.js';
|
|
|
3
3
|
/** A DefinedKanonak visited during a walk, with a human-facing locator path. */
|
|
4
4
|
export interface WalkNode {
|
|
5
5
|
readonly kanonak: DefinedKanonak;
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Authored locator: `subjectName` for a subject, then a dotted PROPERTY
|
|
8
|
+
* path into the embeddeds — `Position.look.bands[0].stats[0]`.
|
|
9
|
+
*
|
|
10
|
+
* Named by the predicate that carries each embedded rather than the
|
|
11
|
+
* embedded's own name, because an expression node (and most embeddeds)
|
|
12
|
+
* is anonymous: naming those `<embedded>/<embedded>/<embedded>` located
|
|
13
|
+
* nothing. Matches the path format the property-shaped rules already
|
|
14
|
+
* build by hand.
|
|
15
|
+
*/
|
|
7
16
|
readonly path: string;
|
|
8
17
|
}
|
|
9
18
|
/**
|
|
@@ -92,6 +92,13 @@ export interface StylesheetExplanation {
|
|
|
92
92
|
/** Human-readable warnings: condition, consequence, and fix. */
|
|
93
93
|
readonly warnings: readonly string[];
|
|
94
94
|
}
|
|
95
|
+
/** An expression carrier that failed to compile during a render (#107 A1). */
|
|
96
|
+
export interface ExpressionCarrierFailure {
|
|
97
|
+
/** Which carrier slot it was — e.g. `look.semanticSvg tier`. */
|
|
98
|
+
readonly carrier: string;
|
|
99
|
+
/** The loader's own message, naming the unrecognized node. */
|
|
100
|
+
readonly reason: string;
|
|
101
|
+
}
|
|
95
102
|
export declare class LookRenderer {
|
|
96
103
|
private readonly catalog;
|
|
97
104
|
constructor(catalog: Kanonak[]);
|
|
@@ -117,6 +124,35 @@ export declare class LookRenderer {
|
|
|
117
124
|
private linkMode;
|
|
118
125
|
/** Set the link style (see {@link linkMode}). Returns `this` for chaining. */
|
|
119
126
|
setLinkMode(mode: 'single-publisher' | 'open-world'): this;
|
|
127
|
+
/**
|
|
128
|
+
* Expression carriers that FAILED TO COMPILE during rendering, in
|
|
129
|
+
* encounter order (typescript#107 A1).
|
|
130
|
+
*
|
|
131
|
+
* A `tx.Expression` whose node class no runner implements — a
|
|
132
|
+
* `math.Round` in a `semanticSvg` tier, say — used to be swallowed by a
|
|
133
|
+
* bare `catch` here and render as nothing, or collapse its whole tier
|
|
134
|
+
* when the undefined propagated through a parent. The loader's error was
|
|
135
|
+
* already precise; only this renderer discarded it. Now every failure is
|
|
136
|
+
* kept, emitted as a comment at the point of failure, and reported by
|
|
137
|
+
* `/.well-known/kanonak-render` — the endpoint publishers self-diagnose
|
|
138
|
+
* from. Compilation is NOT retried per render, so the list is the set of
|
|
139
|
+
* distinct failures, deduplicated by message.
|
|
140
|
+
*/
|
|
141
|
+
private readonly expressionFailureList;
|
|
142
|
+
private readonly expressionFailureSeen;
|
|
143
|
+
/**
|
|
144
|
+
* Every expression carrier that failed to compile so far. Read by the
|
|
145
|
+
* render-diagnostics endpoint; append-only for the life of the renderer,
|
|
146
|
+
* so a caller rendering many pages sees the union.
|
|
147
|
+
*/
|
|
148
|
+
expressionFailures(): readonly ExpressionCarrierFailure[];
|
|
149
|
+
/**
|
|
150
|
+
* Record a carrier compile failure and return the comment to emit in its
|
|
151
|
+
* place. Visible three ways: in the page (View Source), in the render
|
|
152
|
+
* diagnostics, and — because the message names the carrier and the reason
|
|
153
|
+
* — actionable without a debugger.
|
|
154
|
+
*/
|
|
155
|
+
private noteExpressionFailure;
|
|
120
156
|
/** Whether links are emitted publisher-first (open-world consumer mode). */
|
|
121
157
|
private get publisherFirst();
|
|
122
158
|
/** Root-anchored link prefix for `publisher`: `/{publisher}` open-world, else ``. */
|
|
@@ -18,10 +18,8 @@ export interface DisplayValue {
|
|
|
18
18
|
* off the instance; the label falls back to the instance's local name so
|
|
19
19
|
* it is never empty.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* `uri-helpers`; relies on built-in URIs already canonicalized at parse
|
|
25
|
-
* time (see KanonakVocabulary.canonicalizeBuiltinUri).
|
|
21
|
+
* Built entirely on the canonical object-model helpers in `uri-helpers`;
|
|
22
|
+
* relies on built-in URIs already canonicalized at parse time (see
|
|
23
|
+
* KanonakVocabulary.canonicalizeBuiltinUri).
|
|
26
24
|
*/
|
|
27
25
|
export declare function resolveDisplayValue(catalog: Kanonak[], instance: SubjectKanonak): DisplayValue;
|
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-RJK6Y4HS.js";import{m as b}from"../chunk-SUXSCSHO.js";import{a}from"../chunk-KOWDHKBN.js";import"../chunk-BA4HAURJ.js";import"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.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-GJAYU443.js";import"../chunk-SUXSCSHO.js";import"../chunk-KOWDHKBN.js";import{ca as e,da as f,e as a,f as b,g as c,i as d}from"../chunk-BA4HAURJ.js";import"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.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/resolution/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C}from"../chunk-PEB52US5.js";import{a as l}from"../chunk-SC5M74NM.js";import{a as D}from"../chunk-PEJALHXK.js";import{a as n,b as o,c as p,d as q,ea as r,fa as s,ga as t,ha as u,ia as v,ja as w,ka as x,la as y,ma as z,na as A,oa as B}from"../chunk-
|
|
1
|
+
import{a as C}from"../chunk-PEB52US5.js";import{a as l}from"../chunk-SC5M74NM.js";import{a as D}from"../chunk-PEJALHXK.js";import{a as n,b as o,c as p,d as q,ea as r,fa as s,ga as t,ha as u,ia as v,ja as w,ka as x,la as y,ma as z,na as A,oa as B}from"../chunk-BA4HAURJ.js";import"../chunk-N3XODYH5.js";import{a as m}from"../chunk-FUUTGGJS.js";import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-QILEJIFU.js";export{m as KanonakUri,C as KanonakUriBuilder,D as KanonakUrlResolver,n as ResourceResolver,s as ResourceTypeClassifier,o as TypeResolver,l as assertPackageIdentity,c as compareVersions,B as contextTypesOf,r as corePropertyClassOf,f as createVersion,q as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,y as isDatatypePropertySubject,i as isMajorCompatible,x as isObjectPropertySubject,w as isPropertySubject,p as parseKanonakAddress,g as parseVersionString,k as pickHighestDocument,z as propertiesInScope,v as propertyClassOf,A as resolvePropertyStep,j as satisfiesVersionOperator,t as subjectUri,u as superClassChain,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
|
package/dist/search/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../chunk-PEB52US5.js";import"../chunk-SC5M74NM.js";import{
|
|
1
|
+
import"../chunk-PEB52US5.js";import"../chunk-SC5M74NM.js";import{d as g}from"../chunk-TW7NJDMW.js";import"../chunk-6VIUXP4N.js";import"../chunk-SUXSCSHO.js";import"../chunk-KOWDHKBN.js";import"../chunk-PEJALHXK.js";import{ga as m,oa as S}from"../chunk-BA4HAURJ.js";import{c as v,m as p,t as E}from"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.js";import{c as x}from"../chunk-QILEJIFU.js";import{homedir as P}from"os";import{join as d}from"path";import{existsSync as M,mkdirSync as D,readFileSync as j,writeFileSync as O}from"fs";import{createHash as C}from"crypto";import{pathToFileURL as B}from"url";var h="Xenova/all-MiniLM-L6-v2",w="q8",b=32;async function F(r){let{pipeline:e,env:t}=r.transformers;t.cacheDir=r.modelCacheDir??d(P(),".kanonak","models");let n=await e("feature-extraction",h,{dtype:w});return async s=>(await n(s,{pooling:"mean",normalize:!0})).tolist()}async function z(r){let e=d(r,"node_modules","@huggingface","transformers"),t=JSON.parse(j(d(e,"package.json"),"utf-8")),n=I(t);if(!n)throw new Error(`@huggingface/transformers at ${e} exposes no resolvable ESM entry.`);let s=await import(B(d(e,n)).href);return typeof s.pipeline=="function"?s:s.default}function I(r){let e=r.exports,t=n=>typeof n=="string"?n:n?.default;return typeof e=="string"?e:t(e?.node?.import)??t(e?.import)??t(e?.default)??r.module??r.main}var y=null;async function U(){return y||(y=(async()=>{let r;try{r=await import("@huggingface/transformers")}catch(e){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: ${e.message})`)}return F({transformers:r})})()),y}function H(r,e){let t=0;for(let n=0;n<r.length;n++)t+=r[n]*e[n];return t}function R(r,e){return e?r.version?e.version?x(r.version,e.version)>0:!0:!1:!0}function K(r,e){let t=g(r,e),n=[t.label],s=S(e);if(s.length>0){let i=E(r,s[0]),a=i?g(r,i).label:s[0].name;a&&n.push(`\u2014 a ${a}.`)}return t.summary&&n.push(t.summary),n.join(" ")}function q(r){let e=new Map;for(let t of r){if(!(t instanceof v))continue;let n=m(t);if(!n)continue;let s=p(n),i=e.get(s);(!i||R(n,m(i)))&&e.set(s,t)}return[...e.values()].sort((t,n)=>{let s=m(t)?p(m(t)):t.name,i=m(n)?p(m(n)):n.name;return s.localeCompare(i)})}var k=class{entries=[];embedder;constructor(e={}){this.embedder=e.embedder}resolveEmbedder(){return this.embedder?Promise.resolve(this.embedder):U()}get size(){return this.entries.length}async build(e,t={}){let n=q(e);if(t.include&&(n=n.filter(t.include)),n.length===0)return this.entries=[],{size:0,cached:!1};let s=n.map(o=>K(e,o)),i=t.cacheDir,a;if(i){let o=C("sha256").update(h+"|"+w+`
|
package/dist/server/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import{c as Pe}from"../chunk-D66LUZDB.js";import{a as be,d as X,f as Se,h as ee}from"../chunk-JFBPQN6T.js";import{e as ve,g as $e,m as U,n as Z}from"../chunk-P5VQEDBS.js";import"../chunk-PEB52US5.js";import"../chunk-SC5M74NM.js";import{a as H,b as G}from"../chunk-BRCVOR7A.js";import{j as te}from"../chunk-AUXSXDZB.js";import{a as ye}from"../chunk-6VIUXP4N.js";import{m as oe}from"../chunk-ITI65NHP.js";import{a as O}from"../chunk-KOWDHKBN.js";import{a as xe}from"../chunk-PEJALHXK.js";import{c as Re}from"../chunk-EKSYQ6CU.js";import{c as we,s as re}from"../chunk-H6UAD2LP.js";import"../chunk-FUUTGGJS.js";import{c as V,e as K,f as W,g as ke}from"../chunk-QILEJIFU.js";import{readFileSync as de,writeFileSync as Ce,mkdirSync as Me}from"fs";import{join as se}from"path";import Fe from"js-yaml";var _e=[{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 q(o){return _e}function N(o){return`${o.publisher}/${o.package_}`}function z(o,e=[]){let c={"kanonak.org/look-styles":"pages render UNSTYLED \u2014 generated CSS stops at the :root token block","kanonak.org/look-tokens":"the :root block loses the universal design-token floor (colors, fonts, spacing)","kanonak.org/universal-look":"resources without their own look render as an empty HTML comment","kanonak.org/look":"band vocabulary (Hero, PropertyList, \u2026) is unresolvable \u2014 declared looks cannot render","kanonak.org/site":"the site vocabulary (content, navigation) is unresolvable \u2014 the base stylesheet cannot bind","kanonak.org/core-kanonak":"the Package/Publisher classes are unresolvable \u2014 package and publisher pages degrade","kanonak.org/link":"link vocabulary is unresolvable \u2014 cross-reference styling degrades"},r=[];for(let t of o)if(t.origin==="missing"){let s=N(t),m=c[s]??"whatever this package contributes to rendering is lost";r.push(`Render-stack package ${s} is MISSING (${t.reason??"unknown reason"}) \u2014 ${m}. Fix: kanonak install ${s} (as the user running the render), or restore network access to ${t.publisher}.`)}else t.resolvedButNotInCatalog&&r.push(`Render-stack package ${N(t)} resolved (${t.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);for(let t of e)r.push(`Import edge ${t.fromNamespace} \u2192 ${t.publisher}/${t.packageName} ${t.constraint} did NOT resolve (${t.reason==="no-compatible-version"?"no compatible version in the repository":"resolution threw"}) \u2014 every statement ${t.fromNamespace} authors against ${t.publisher}/${t.packageName} entities is dropped from the parse as an unresolved predicate (a look declaration loses its bands and pages render empty; see typescript#91). Fix: add a ${t.constraint}-compatible version of ${t.publisher}/${t.packageName} to the workspace or cache (kanonak install ${t.publisher}/${t.packageName}), or bump the import in ${t.fromNamespace}.`);return r}function ne(o){let{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:s,rawByNsKey:m,renderStack:d,producers:f,lockSource:l,configSource:h}=o,a=new Map,g=new Map,S=new Map,v=new Set;for(let $ of r){if(!($ instanceof we))continue;let w=$.namespace||"";if(!s.has(w))continue;a.set(`${w}/${$.name}`,$);let P=w.split("/")[1]??"",[_,F]=P.split("@");if(!_||!F)continue;let D=ke(F);D&&(v.has(P)||(v.add(P),g.has(_)||g.set(_,[]),g.get(_).push({verStr:F,version:D})),$.name===_&&S.set(P,$))}for(let $ of g.values())$.sort((w,P)=>V(P.version,w.version));return{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:s,rawByNsKey:m,bySubject:a,pkgVersions:g,pkgSelfByVer:S,renderStack:d,...f?{producers:f}:{},...l?{lockSource:l}:{},...h?{configSource:h}:{}}}async function pe(o,e={}){let c=new O,r=new ye(c),t=[],s=[];for(let i of ee(o)){let u;try{u=de(i,"utf-8")}catch{continue}let n;try{n=c.parse(u).metadata?.namespace_}catch{continue}if(!n?.version)continue;let p=n.version;s.push({publisher:n.publisher,package_:n.package_,verStr:K(p),version:p,source:u})}s.sort((i,u)=>V(u.version,i.version));for(let i of s)await r.saveDocumentAsync(c.parse(i.source),`${i.publisher}/${i.package_}@${i.verStr}`),t.push({publisher:i.publisher,package_:i.package_,verStr:i.verStr,source:i.source});let m=[...new Set(t.map(i=>i.publisher))].sort(),d=e.publisher;if(d){if(!m.includes(d))throw new Error(`Publisher "${d}" not found in workspace. Available: ${m.join(", ")||"(none)"}`)}else if(m.length===1)d=m[0];else throw m.length===0?new Error(`No Kanonak packages found under ${o}`):new Error(`Workspace has multiple publishers (${m.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let f=new Set,l=new Map;for(let i of t)i.publisher===d&&(f.add(`${i.publisher}/${i.package_}@${i.verStr}`),l.set(`${i.package_}@${i.verStr}`,i.source));let h=X(),a=new be(h,!0,c),g={};e.httpCache&&(g.getFromCache=e.httpCache.getFromCache,g.onFetch=e.httpCache.onFetch),e.fetchFn&&(g.fetchFn=e.fetchFn);let S=e.repository??new Se(r,a,new Z(g)),v=e.log??(()=>{}),$=q(void 0),w=[],P=i=>i.map(u=>u.metadata.namespace_?.version).filter(u=>u!==void 0).sort((u,n)=>V(n,u)).map(K);if(!e.repository){v(`[render-stack] resolving ${$.length} ambient look-stack package(s); cache: ${h}`);let i=e.fetchFn?new U({fetchFn:e.fetchFn}):new U;for(let u of $){let n=N(u),p=await r.getDocumentsByNamespaceAsync(u.publisher,u.package_);if(p.length>0){let y=P(p);w.push({...u,origin:"workspace",versions:y}),v(`[render-stack] ${n} \u2014 workspace (${y.join(", ")})`);continue}let k=await a.getDocumentsByNamespaceAsync(u.publisher,u.package_);if(k.length>0){let y=P(k);w.push({...u,origin:"cache",versions:y}),v(`[render-stack] ${n} \u2014 cache (${y.join(", ")})`);continue}try{let b=(await i.getLock(u.publisher))?.packages[`${u.publisher}/${u.package_}`];if(!b){let j=`publisher ${u.publisher} reachable but its lock does not pin ${u.package_}`;w.push({...u,origin:"missing",reason:j}),v(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let C=b.version,T=b.resolved,Q=await(e.fetchFn?e.fetchFn(T,u.publisher):ve(T));if(!Q.ok){let j=`fetch ${T} failed: HTTP ${Q.status} ${Q.statusText}`;w.push({...u,origin:"missing",reason:j}),v(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let fe=await Q.text();await r.saveDocumentAsync(c.parse(fe),`${u.publisher}/${u.package_}@${C}`);try{let j=se(h,u.publisher);Me(j,{recursive:!0}),Ce(se(j,`${u.package_}@${C}.kan.yml`),fe,"utf-8"),w.push({...u,origin:"fetched",versions:[C]}),v(`[render-stack] ${n}@${C} \u2014 fetched from ${T}, installed to cache`)}catch(j){w.push({...u,origin:"fetched",versions:[C]}),v(`[render-stack] ${n}@${C} \u2014 fetched from ${T}, but cache ${h} is NOT WRITABLE (${j.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(y){let b=`fetch failed: ${y.message}`;w.push({...u,origin:"missing",reason:b}),v(`[render-stack] ${n} \u2014 MISSING: ${b}`)}}}let _=(await r.getAllDocumentsAsync()).filter(i=>i.metadata.namespace_?.publisher===d);for(let i of $)_.push(...await S.getDocumentsByNamespaceAsync(i.publisher,i.package_));let F=[],D=await H(_,S,{onUnresolvedEdge:i=>F.push(i)}),A=S;if(!e.repository){for(let i of $)D.add(N(i));A=new G(S,D)}let B=await new oe(c).parseKanonaks(A),ce=new te(B),le=(i,u)=>re(B,{publisher:i,package_:u,name:u}).length>0,I;if(e.repository){I=[];for(let i of $){let u=await S.getDocumentsByNamespaceAsync(i.publisher,i.package_);I.push(u.length>0?{...i,origin:"repository",versions:P(u)}:{...i,origin:"missing",reason:"not present in the caller-supplied repository"})}}else I=w.map(i=>i.origin==="missing"||le(i.publisher,i.package_)?i:{...i,resolvedButNotInCatalog:!0});let Y=z(I,F);for(let i of Y)v(`[render-stack] WARNING: ${i}`);let J={contractSource:"universal-default",cachePath:h,packages:I,warnings:Y},E;try{E=de(se(o,"kanonak.lock"),"utf-8")}catch{E=De(d,t,c)}let L;try{L=de(se(o,".well-known","kanonak.json"),"utf-8")}catch{L=void 0}return ne({publisher:d,availablePublishers:m,catalog:B,lookRenderer:ce,localNamespaces:f,rawByNsKey:l,renderStack:J,...E?{lockSource:E}:{},...L?{configSource:L}:{}})}function De(o,e,c){let r=new Map;for(let s of e)s.publisher===o&&(r.has(s.package_)||r.set(s.package_,{verStr:s.verStr,source:s.source}));if(r.size===0)return;let t={};for(let s of[...r.keys()].sort()){let{verStr:m,source:d}=r.get(s),f={},l;try{l=c.parse(d).metadata?.imports}catch{l=void 0}for(let a of l?.[o]??[]){let g=r.get(a.packageName);g&&(f[`${o}/${a.packageName}`]=g.verStr)}let h={};for(let a of Object.keys(f).sort())h[a]=f[a];t[`${o}/${s}`]={version:m,resolved:`https://${o}/${s}/${m}.kan.yml`,integrity:Pe(d),dependencies:h}}return Fe.dump({version:"1",lastUpdated:"",packages:t},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as Ke,readFileSync as Ee,writeFileSync as Ve,mkdirSync as Ae}from"fs";import{join as je}from"path";async function ue(o,e={}){let c=new O,r=Re(o),t=r.kind==="resource"?r.uri.publisher:r.publisher,s=e.log??(()=>{}),m=e.cacheRoot??X(),d=(n,p,k)=>je(m,n,`${p}@${k}.kan.yml`),f=new Set,l=new Set,h=new Map,a=new Z({getFromCache:(n,p,k)=>{let y=d(n,p,k),b=Ke(y)?Ee(y,"utf-8"):null;return b!==null&&f.add(`${n}/${p}`),b},onFetch:(n,p,k,y)=>{l.add(`${n}/${p}`);try{let b=je(m,n);Ae(b,{recursive:!0}),Ve(d(n,p,k),y,"utf-8")}catch(b){h.set(`${n}/${p}`,b.message),s(`[render] fetched ${n}/${p}@${k} but cache ${m} is NOT WRITABLE (${b.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),g=new U(e.fetchFn?{fetchFn:e.fetchFn}:void 0),S;if(r.kind==="resource"){let n=r.uri.version;S=[n?{package_:r.uri.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let n=r.version;S=[n?{package_:r.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.package_}]}else S=((await g.getConfig(t)).featured_packages??[]).map(p=>({package_:p}));let v=async(n,p,k)=>{try{let y=k?c.buildImport(p,"=",k,n):c.buildImport(p,"*","0.0.0",n),b=await a.getHighestCompatibleVersionAsync(n,y);return b?{doc:b}:{doc:null,error:`${n} did not resolve ${p}${k?`@${k}`:""} (not in its index, or unreachable)`}}catch(y){return{doc:null,error:y.message}}},$=[],w=[];for(let n of S){let{doc:p,error:k}=await v(t,n.package_,n.version);p?$.push(p):k&&w.push(k)}if($.length===0)throw new Error(`Could not fetch any package for address "${o}" from publisher "${t}".`+(w.length>0?` Reasons: ${w.join("; ")}`:""));let P=q(),_="universal-default",F=n=>n.map(p=>p.metadata.namespace_?.version).filter(p=>p!==void 0).sort((p,k)=>V(k,p)).map(K);s(`[render-stack] resolving ${P.length} ambient look-stack package(s) (contract: ${_}); cache: ${m}`);let D=[],A=[];for(let n of P){let p=N(n),{doc:k,error:y}=await v(n.publisher,n.package_,void 0);if(k){D.push(k);let b=F([k]),C=l.has(p)?"fetched":f.has(p)?"cache":"fetched";A.push({...n,origin:C,versions:b}),s(`[render-stack] ${p} \u2014 ${C} (${b.join(", ")})`+(h.has(p)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else A.push({...n,origin:"missing",reason:y??"unresolved"}),s(`[render-stack] ${p} \u2014 MISSING: ${y??"unresolved"}`)}let B=[],ce=await H([...$,...D],a,{onUnresolvedEdge:n=>B.push(n)}),le=new G(a,ce),I=await new oe(c).parseKanonaks(le),Y=new te(I),J=A.map(n=>n.origin==="missing"||re(I,{publisher:n.publisher,package_:n.package_,name:n.package_}).length>0?n:{...n,resolvedButNotInCatalog:!0}),E=z(J,B);for(let n of E)s(`[render-stack] WARNING: ${n}`);let L={contractSource:_,cachePath:m,packages:J,warnings:E},i=new Set,u=new Map;for(let n of await a.getAllDocumentsAsync()){let p=n.metadata.namespace_;if(!p?.version||p.publisher!==t)continue;let k=K(p.version),y=`${p.publisher}/${p.package_}@${k}`;i.add(y);let b=await a.getDocumentContentAsync(y);b!==null&&u.set(`${p.package_}@${k}`,b)}return ne({publisher:t,availablePublishers:[t],catalog:I,lookRenderer:Y,localNamespaces:i,rawByNsKey:u,renderStack:L})}import{VersionOperator as ie}from"@kanonak-protocol/types/document/models/enums";function ae(o){let{lookRenderer:e,publisher:c,renderStack:r,catalog:t}=o,s=e.explainStylesheet(e.publisherSubject(c)),m=[...s.tokens.entries()].map(([a,g])=>({name:a,value:g.value,source:`${g.sourceNamespace}/${g.sourceName}`,level:g.level})),d=s.baseStylesheet,f={present:d.css!==void 0,...d.sourceNamespace!==void 0?{source:d.sourceNamespace}:{},...d.scope!==void 0?{scope:d.scope}:{},...d.css!==void 0?{bytes:d.css.length}:{},...d.problem!==void 0?{problem:d.problem}:{},candidates:d.candidates},l=new Map;for(let a of t){let g=a.namespace;g&&l.set(g,(l.get(g)??0)+1)}let h=[...l.entries()].map(([a,g])=>({namespace:a,resources:g})).sort((a,g)=>a.namespace.localeCompare(g.namespace));return{publisher:c,renderStack:{contractSource:r.contractSource,cachePath:r.cachePath,packages:r.packages.map(a=>({package_:N(a),origin:a.origin,...a.versions!==void 0?{versions:a.versions}:{},...a.reason!==void 0?{reason:a.reason}:{},...a.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:a.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:m,baseStylesheet:f,...s.look?{look:{sourceClass:`${s.look.sourceClass.publisher}/${s.look.sourceClass.package_}/${s.look.sourceClass.name}`}}:{}},catalog:h,warnings:[...r.warnings,...s.warnings.filter(a=>!r.warnings.includes(a))]}}function Be(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ge(o){let e=Be,c=o.warnings.length===0,r=o.warnings.length===0?'<p class="ok">\u2713 No problems detected \u2014 the render stack is fully resolved and pages should be styled.</p>':o.warnings.map(l=>`<div class="warn">\u26A0 ${e(l)}</div>`).join(`
|
|
2
|
-
`),t=o.
|
|
3
|
-
`),
|
|
4
|
-
`),
|
|
1
|
+
import{c as Pe}from"../chunk-D66LUZDB.js";import{a as be,d as X,f as Se,h as ee}from"../chunk-JFBPQN6T.js";import{e as ve,g as $e,m as U,n as Z}from"../chunk-P5VQEDBS.js";import"../chunk-PEB52US5.js";import"../chunk-SC5M74NM.js";import{a as H,b as G}from"../chunk-BRCVOR7A.js";import{j as te}from"../chunk-TW7NJDMW.js";import{a as ye}from"../chunk-6VIUXP4N.js";import{m as oe}from"../chunk-SUXSCSHO.js";import{a as O}from"../chunk-KOWDHKBN.js";import{a as xe}from"../chunk-PEJALHXK.js";import{c as Re}from"../chunk-BA4HAURJ.js";import{c as we,u as re}from"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.js";import{c as V,e as E,f as W,g as ke}from"../chunk-QILEJIFU.js";import{readFileSync as de,writeFileSync as Ie,mkdirSync as Me}from"fs";import{join as se}from"path";import Fe from"js-yaml";var _e=[{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 q(o){return _e}function C(o){return`${o.publisher}/${o.package_}`}function z(o,e=[]){let c={"kanonak.org/look-styles":"pages render UNSTYLED \u2014 generated CSS stops at the :root token block","kanonak.org/look-tokens":"the :root block loses the universal design-token floor (colors, fonts, spacing)","kanonak.org/universal-look":"resources without their own look render as an empty HTML comment","kanonak.org/look":"band vocabulary (Hero, PropertyList, \u2026) is unresolvable \u2014 declared looks cannot render","kanonak.org/site":"the site vocabulary (content, navigation) is unresolvable \u2014 the base stylesheet cannot bind","kanonak.org/core-kanonak":"the Package/Publisher classes are unresolvable \u2014 package and publisher pages degrade","kanonak.org/link":"link vocabulary is unresolvable \u2014 cross-reference styling degrades"},r=[];for(let t of o)if(t.origin==="missing"){let a=C(t),u=c[a]??"whatever this package contributes to rendering is lost";r.push(`Render-stack package ${a} is MISSING (${t.reason??"unknown reason"}) \u2014 ${u}. Fix: kanonak install ${a} (as the user running the render), or restore network access to ${t.publisher}.`)}else t.resolvedButNotInCatalog&&r.push(`Render-stack package ${C(t)} resolved (${t.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);for(let t of e)r.push(`Import edge ${t.fromNamespace} \u2192 ${t.publisher}/${t.packageName} ${t.constraint} did NOT resolve (${t.reason==="no-compatible-version"?"no compatible version in the repository":"resolution threw"}) \u2014 every statement ${t.fromNamespace} authors against ${t.publisher}/${t.packageName} entities is dropped from the parse as an unresolved predicate (a look declaration loses its bands and pages render empty; see typescript#91). Fix: add a ${t.constraint}-compatible version of ${t.publisher}/${t.packageName} to the workspace or cache (kanonak install ${t.publisher}/${t.packageName}), or bump the import in ${t.fromNamespace}.`);return r}function ne(o){let{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,renderStack:d,producers:k,lockSource:y,configSource:s}=o,l=new Map,f=new Map,p=new Map,m=new Set;for(let S of r){if(!(S instanceof we))continue;let w=S.namespace||"";if(!a.has(w))continue;l.set(`${w}/${S.name}`,S);let P=w.split("/")[1]??"",[_,F]=P.split("@");if(!_||!F)continue;let D=ke(F);D&&(m.has(P)||(m.add(P),f.has(_)||f.set(_,[]),f.get(_).push({verStr:F,version:D})),S.name===_&&p.set(P,S))}for(let S of f.values())S.sort((w,P)=>V(P.version,w.version));return{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,bySubject:l,pkgVersions:f,pkgSelfByVer:p,renderStack:d,...k?{producers:k}:{},...y?{lockSource:y}:{},...s?{configSource:s}:{}}}async function pe(o,e={}){let c=new O,r=new ye(c),t=[],a=[];for(let i of ee(o)){let h;try{h=de(i,"utf-8")}catch{continue}let n;try{n=c.parse(h).metadata?.namespace_}catch{continue}if(!n?.version)continue;let g=n.version;a.push({publisher:n.publisher,package_:n.package_,verStr:E(g),version:g,source:h})}a.sort((i,h)=>V(h.version,i.version));for(let i of a)await r.saveDocumentAsync(c.parse(i.source),`${i.publisher}/${i.package_}@${i.verStr}`),t.push({publisher:i.publisher,package_:i.package_,verStr:i.verStr,source:i.source});let u=[...new Set(t.map(i=>i.publisher))].sort(),d=e.publisher;if(d){if(!u.includes(d))throw new Error(`Publisher "${d}" not found in workspace. Available: ${u.join(", ")||"(none)"}`)}else if(u.length===1)d=u[0];else throw u.length===0?new Error(`No Kanonak packages found under ${o}`):new Error(`Workspace has multiple publishers (${u.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let k=new Set,y=new Map;for(let i of t)i.publisher===d&&(k.add(`${i.publisher}/${i.package_}@${i.verStr}`),y.set(`${i.package_}@${i.verStr}`,i.source));let s=X(),l=new be(s,!0,c),f={};e.httpCache&&(f.getFromCache=e.httpCache.getFromCache,f.onFetch=e.httpCache.onFetch),e.fetchFn&&(f.fetchFn=e.fetchFn);let p=e.repository??new Se(r,l,new Z(f)),m=e.log??(()=>{}),S=q(void 0),w=[],P=i=>i.map(h=>h.metadata.namespace_?.version).filter(h=>h!==void 0).sort((h,n)=>V(n,h)).map(E);if(!e.repository){m(`[render-stack] resolving ${S.length} ambient look-stack package(s); cache: ${s}`);let i=e.fetchFn?new U({fetchFn:e.fetchFn}):new U;for(let h of S){let n=C(h),g=await r.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(g.length>0){let v=P(g);w.push({...h,origin:"workspace",versions:v}),m(`[render-stack] ${n} \u2014 workspace (${v.join(", ")})`);continue}let b=await l.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(b.length>0){let v=P(b);w.push({...h,origin:"cache",versions:v}),m(`[render-stack] ${n} \u2014 cache (${v.join(", ")})`);continue}try{let $=(await i.getLock(h.publisher))?.packages[`${h.publisher}/${h.package_}`];if(!$){let j=`publisher ${h.publisher} reachable but its lock does not pin ${h.package_}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let I=$.version,T=$.resolved,Q=await(e.fetchFn?e.fetchFn(T,h.publisher):ve(T));if(!Q.ok){let j=`fetch ${T} failed: HTTP ${Q.status} ${Q.statusText}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let fe=await Q.text();await r.saveDocumentAsync(c.parse(fe),`${h.publisher}/${h.package_}@${I}`);try{let j=se(s,h.publisher);Me(j,{recursive:!0}),Ie(se(j,`${h.package_}@${I}.kan.yml`),fe,"utf-8"),w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, installed to cache`)}catch(j){w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, but cache ${s} is NOT WRITABLE (${j.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(v){let $=`fetch failed: ${v.message}`;w.push({...h,origin:"missing",reason:$}),m(`[render-stack] ${n} \u2014 MISSING: ${$}`)}}}let _=(await r.getAllDocumentsAsync()).filter(i=>i.metadata.namespace_?.publisher===d);for(let i of S)_.push(...await p.getDocumentsByNamespaceAsync(i.publisher,i.package_));let F=[],D=await H(_,p,{onUnresolvedEdge:i=>F.push(i)}),A=p;if(!e.repository){for(let i of S)D.add(C(i));A=new G(p,D)}let B=await new oe(c).parseKanonaks(A),ce=new te(B),le=(i,h)=>re(B,{publisher:i,package_:h,name:h}).length>0,N;if(e.repository){N=[];for(let i of S){let h=await p.getDocumentsByNamespaceAsync(i.publisher,i.package_);N.push(h.length>0?{...i,origin:"repository",versions:P(h)}:{...i,origin:"missing",reason:"not present in the caller-supplied repository"})}}else N=w.map(i=>i.origin==="missing"||le(i.publisher,i.package_)?i:{...i,resolvedButNotInCatalog:!0});let Y=z(N,F);for(let i of Y)m(`[render-stack] WARNING: ${i}`);let J={contractSource:"universal-default",cachePath:s,packages:N,warnings:Y},K;try{K=de(se(o,"kanonak.lock"),"utf-8")}catch{K=De(d,t,c)}let L;try{L=de(se(o,".well-known","kanonak.json"),"utf-8")}catch{L=void 0}return ne({publisher:d,availablePublishers:u,catalog:B,lookRenderer:ce,localNamespaces:k,rawByNsKey:y,renderStack:J,...K?{lockSource:K}:{},...L?{configSource:L}:{}})}function De(o,e,c){let r=new Map;for(let a of e)a.publisher===o&&(r.has(a.package_)||r.set(a.package_,{verStr:a.verStr,source:a.source}));if(r.size===0)return;let t={};for(let a of[...r.keys()].sort()){let{verStr:u,source:d}=r.get(a),k={},y;try{y=c.parse(d).metadata?.imports}catch{y=void 0}for(let l of y?.[o]??[]){let f=r.get(l.packageName);f&&(k[`${o}/${l.packageName}`]=f.verStr)}let s={};for(let l of Object.keys(k).sort())s[l]=k[l];t[`${o}/${a}`]={version:u,resolved:`https://${o}/${a}/${u}.kan.yml`,integrity:Pe(d),dependencies:s}}return Fe.dump({version:"1",lastUpdated:"",packages:t},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as Ee,readFileSync as Ke,writeFileSync as Ve,mkdirSync as Ae}from"fs";import{join as je}from"path";async function ue(o,e={}){let c=new O,r=Re(o),t=r.kind==="resource"?r.uri.publisher:r.publisher,a=e.log??(()=>{}),u=e.cacheRoot??X(),d=(n,g,b)=>je(u,n,`${g}@${b}.kan.yml`),k=new Set,y=new Set,s=new Map,l=new Z({getFromCache:(n,g,b)=>{let v=d(n,g,b),$=Ee(v)?Ke(v,"utf-8"):null;return $!==null&&k.add(`${n}/${g}`),$},onFetch:(n,g,b,v)=>{y.add(`${n}/${g}`);try{let $=je(u,n);Ae($,{recursive:!0}),Ve(d(n,g,b),v,"utf-8")}catch($){s.set(`${n}/${g}`,$.message),a(`[render] fetched ${n}/${g}@${b} but cache ${u} is NOT WRITABLE (${$.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),f=new U(e.fetchFn?{fetchFn:e.fetchFn}:void 0),p;if(r.kind==="resource"){let n=r.uri.version;p=[n?{package_:r.uri.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let n=r.version;p=[n?{package_:r.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.package_}]}else p=((await f.getConfig(t)).featured_packages??[]).map(g=>({package_:g}));let m=async(n,g,b)=>{try{let v=b?c.buildImport(g,"=",b,n):c.buildImport(g,"*","0.0.0",n),$=await l.getHighestCompatibleVersionAsync(n,v);return $?{doc:$}:{doc:null,error:`${n} did not resolve ${g}${b?`@${b}`:""} (not in its index, or unreachable)`}}catch(v){return{doc:null,error:v.message}}},S=[],w=[];for(let n of p){let{doc:g,error:b}=await m(t,n.package_,n.version);g?S.push(g):b&&w.push(b)}if(S.length===0)throw new Error(`Could not fetch any package for address "${o}" from publisher "${t}".`+(w.length>0?` Reasons: ${w.join("; ")}`:""));let P=q(),_="universal-default",F=n=>n.map(g=>g.metadata.namespace_?.version).filter(g=>g!==void 0).sort((g,b)=>V(b,g)).map(E);a(`[render-stack] resolving ${P.length} ambient look-stack package(s) (contract: ${_}); cache: ${u}`);let D=[],A=[];for(let n of P){let g=C(n),{doc:b,error:v}=await m(n.publisher,n.package_,void 0);if(b){D.push(b);let $=F([b]),I=y.has(g)?"fetched":k.has(g)?"cache":"fetched";A.push({...n,origin:I,versions:$}),a(`[render-stack] ${g} \u2014 ${I} (${$.join(", ")})`+(s.has(g)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else A.push({...n,origin:"missing",reason:v??"unresolved"}),a(`[render-stack] ${g} \u2014 MISSING: ${v??"unresolved"}`)}let B=[],ce=await H([...S,...D],l,{onUnresolvedEdge:n=>B.push(n)}),le=new G(l,ce),N=await new oe(c).parseKanonaks(le),Y=new te(N),J=A.map(n=>n.origin==="missing"||re(N,{publisher:n.publisher,package_:n.package_,name:n.package_}).length>0?n:{...n,resolvedButNotInCatalog:!0}),K=z(J,B);for(let n of K)a(`[render-stack] WARNING: ${n}`);let L={contractSource:_,cachePath:u,packages:J,warnings:K},i=new Set,h=new Map;for(let n of await l.getAllDocumentsAsync()){let g=n.metadata.namespace_;if(!g?.version||g.publisher!==t)continue;let b=E(g.version),v=`${g.publisher}/${g.package_}@${b}`;i.add(v);let $=await l.getDocumentContentAsync(v);$!==null&&h.set(`${g.package_}@${b}`,$)}return ne({publisher:t,availablePublishers:[t],catalog:N,lookRenderer:Y,localNamespaces:i,rawByNsKey:h,renderStack:L})}import{VersionOperator as ie}from"@kanonak-protocol/types/document/models/enums";function ae(o){let{lookRenderer:e,publisher:c,renderStack:r,catalog:t}=o,a=e.explainStylesheet(e.publisherSubject(c)),u=[...a.tokens.entries()].map(([p,m])=>({name:p,value:m.value,source:`${m.sourceNamespace}/${m.sourceName}`,level:m.level})),d=a.baseStylesheet,k={present:d.css!==void 0,...d.sourceNamespace!==void 0?{source:d.sourceNamespace}:{},...d.scope!==void 0?{scope:d.scope}:{},...d.css!==void 0?{bytes:d.css.length}:{},...d.problem!==void 0?{problem:d.problem}:{},candidates:d.candidates},y=new Map;for(let p of t){let m=p.namespace;m&&y.set(m,(y.get(m)??0)+1)}let s=[...y.entries()].map(([p,m])=>({namespace:p,resources:m})).sort((p,m)=>p.namespace.localeCompare(m.namespace)),l=e.expressionFailures().map(p=>({carrier:p.carrier,reason:p.reason})),f=l.map(p=>`Expression carrier "${p.carrier}" did not compile: ${p.reason} Consequence: that value renders as nothing (and a parent operation consuming it may drop its whole tier). Fix: use a tx.Expression node class the runner implements, or remove the carrier.`);return{publisher:c,renderStack:{contractSource:r.contractSource,cachePath:r.cachePath,packages:r.packages.map(p=>({package_:C(p),origin:p.origin,...p.versions!==void 0?{versions:p.versions}:{},...p.reason!==void 0?{reason:p.reason}:{},...p.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:p.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:u,baseStylesheet:k,...a.look?{look:{sourceClass:`${a.look.sourceClass.publisher}/${a.look.sourceClass.package_}/${a.look.sourceClass.name}`}}:{}},expressionCarriers:l,catalog:s,warnings:[...r.warnings,...a.warnings.filter(p=>!r.warnings.includes(p)),...f]}}function Be(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function ge(o){let e=Be,c=o.warnings.length===0,r=o.expressionCarriers.map(s=>`<tr><td><code>${e(s.carrier)}</code></td><td>${e(s.reason)}</td></tr>`).join(`
|
|
2
|
+
`),t=o.warnings.length===0?'<p class="ok">\u2713 No problems detected \u2014 the render stack is fully resolved and pages should be styled.</p>':o.warnings.map(s=>`<div class="warn">\u26A0 ${e(s)}</div>`).join(`
|
|
3
|
+
`),a=o.renderStack.packages.map(s=>{let l=s.origin!=="missing"&&!s.resolvedButNotInCatalog,f=s.origin==="missing"?'<span class="bad">MISSING</span>':s.resolvedButNotInCatalog?`<span class="bad">${e(s.origin)} (not in catalog)</span>`:`<span class="good">${e(s.origin)}</span>`,p=s.reason?e(s.reason):e((s.versions??[]).join(", "));return`<tr class="${l?"":"row-bad"}"><td><code>${e(s.package_)}</code></td><td>${f}</td><td>${p}</td></tr>`}).join(`
|
|
4
|
+
`),u=o.stylesheet.baseStylesheet,d=u.present?`<p><span class="good">\u2713 present</span> \u2014 <code>${e(u.source??"")}</code> (${u.bytes} bytes, ${e(u.scope??"")})</p>`:`<p><span class="bad">\u2717 MISSING</span>${u.problem?` \u2014 ${e(u.problem)}`:""}${u.candidates.length>0?`<br>candidates considered: ${u.candidates.map(s=>`<code>${e(s)}</code>`).join(", ")}`:""}</p><p>Without the base stylesheet, generated CSS stops at the <code>:root</code> token block and pages appear unstyled.</p>`,k=o.stylesheet.tokens.map(s=>`<tr><td><code>--kan-${e(s.name)}</code></td><td><code>${e(s.value)}</code></td><td><code>${e(s.source)}</code></td><td>${e(s.level)}</td></tr>`).join(`
|
|
5
|
+
`),y=o.catalog.map(s=>`<tr><td><code>${e(s.namespace)}</code></td><td>${s.resources}</td></tr>`).join(`
|
|
5
6
|
`);return`<!doctype html>
|
|
6
7
|
<html lang="en">
|
|
7
8
|
<head>
|
|
@@ -30,35 +31,42 @@ import{c as Pe}from"../chunk-D66LUZDB.js";import{a as be,d as X,f as Se,h as ee}
|
|
|
30
31
|
<p class="meta">Machine-readable version: <a href="/.well-known/kanonak-render.json"><code>/.well-known/kanonak-render.json</code></a></p>
|
|
31
32
|
|
|
32
33
|
<h2>Problems</h2>
|
|
33
|
-
${
|
|
34
|
+
${t}
|
|
34
35
|
|
|
35
36
|
<h2>Ambient render stack</h2>
|
|
36
37
|
<p class="meta">The look stack is discovered, not imported \u2014 these packages must be resolvable for any publisher's pages to render styled.
|
|
37
38
|
Contract: <code>${e(o.renderStack.contractSource)}</code> \xB7 Package cache: <code>${e(o.renderStack.cachePath)}</code></p>
|
|
38
39
|
<table>
|
|
39
40
|
<tr><th>Package</th><th>Origin</th><th>Versions / reason</th></tr>
|
|
40
|
-
${
|
|
41
|
+
${a}
|
|
41
42
|
</table>
|
|
42
43
|
|
|
43
44
|
<h2>Base stylesheet</h2>
|
|
44
45
|
<p class="meta">Everything after the <code>:root</code> block in generated CSS comes from a <code>look-styles/base-stylesheet</code> asset in the render catalog.</p>
|
|
45
|
-
${
|
|
46
|
+
${d}
|
|
46
47
|
|
|
47
48
|
<h2>Design tokens (:root)</h2>
|
|
48
49
|
<p class="meta">Resolved for the publisher landing page. Each token shows which resource in the cascade supplied it.</p>
|
|
49
50
|
${o.stylesheet.tokens.length===0?'<p><span class="bad">\u2717 No tokens resolved</span></p>':`<table>
|
|
50
51
|
<tr><th>Token</th><th>Value</th><th>Declared by</th><th>Cascade level</th></tr>
|
|
51
|
-
${
|
|
52
|
+
${k}
|
|
52
53
|
</table>`}
|
|
53
54
|
|
|
54
55
|
<h2>Look (page body)</h2>
|
|
55
56
|
${o.stylesheet.look?`<p><span class="good">\u2713</span> Bands resolve from <code>${e(o.stylesheet.look.sourceClass)}</code></p>`:'<p><span class="bad">\u2717 No look resolved</span> \u2014 the page body renders as an empty comment.</p>'}
|
|
56
57
|
|
|
58
|
+
<h2>Expression carriers</h2>
|
|
59
|
+
<p class="meta">Authored <code>tx.Expression</code> carriers (band paths, <code>semanticSvg</code> tiers) that failed to compile while rendering this page. A carrier that does not compile contributes nothing to the output.</p>
|
|
60
|
+
${o.expressionCarriers.length===0?'<p><span class="good">\u2713</span> Every expression carrier on this page compiled.</p>':`<table>
|
|
61
|
+
<tr><th>Carrier</th><th>Reason</th></tr>
|
|
62
|
+
${r}
|
|
63
|
+
</table>`}
|
|
64
|
+
|
|
57
65
|
<h2>Render catalog (${o.catalog.length} package version(s))</h2>
|
|
58
66
|
<p class="meta">Everything the renderer can see for this publisher \u2014 the served packages, their import closure, and the ambient render stack.</p>
|
|
59
67
|
<table>
|
|
60
68
|
<tr><th>Package version</th><th>Resources</th></tr>
|
|
61
|
-
${
|
|
69
|
+
${y}
|
|
62
70
|
</table>
|
|
63
71
|
</body>
|
|
64
|
-
</html>`}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"},x=(o,e,c,r)=>({status:o,headers:{"Content-Type":e,...r||{}},body:c}),M=o=>x(404,R[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${o}</p>`),Le=o=>({status:301,headers:{Location:o},body:""}),Oe=o=>({status:302,headers:{Location:o},body:""});function Te(o){switch(o.kind){case"exact":return{operator:ie.Exact,version:W(o.major,o.minor,o.patch)};case"minor-pin":return{operator:ie.Compatible,version:W(o.major,o.minor,0)};case"major-pin":return{operator:ie.Major,version:W(o.major,0,0)};default:return{operator:ie.Any,version:W(0,0,0)}}}async function We(o,e,c,r){if(!r)return null;let t=o.producers?.find(
|
|
72
|
+
</html>`}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"},x=(o,e,c,r)=>({status:o,headers:{"Content-Type":e,...r||{}},body:c}),M=o=>x(404,R[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${o}</p>`),Le=o=>({status:301,headers:{Location:o},body:""}),Oe=o=>({status:302,headers:{Location:o},body:""});function Te(o){switch(o.kind){case"exact":return{operator:ie.Exact,version:W(o.major,o.minor,o.patch)};case"minor-pin":return{operator:ie.Compatible,version:W(o.major,o.minor,0)};case"major-pin":return{operator:ie.Major,version:W(o.major,0,0)};default:return{operator:ie.Any,version:W(0,0,0)}}}async function We(o,e,c,r){if(!r)return null;let t=o.producers?.find(k=>k.canProduce(o.publisher,e));if(!t)return null;let a=await t.resolveVersion(o.publisher,e,Te(c));if(!a)return null;let u=E(a);if(c.kind!=="exact")return Oe(`/${e}/${u}.kan.yml`);let{source:d}=await t.produce(o.publisher,e,a);return x(200,R[".kan.yml"],d)}function Ce(o,e,c){let r=o.pkgVersions.get(e);if(!r||r.length===0)return null;switch(c.kind){case"any":return r[0].verStr;case"major-pin":return r.find(t=>t.version.major===c.major)?.verStr??null;case"minor-pin":return r.find(t=>t.version.major===c.major&&t.version.minor===c.minor)?.verStr??null;case"exact":return r.find(t=>t.version.major===c.major&&t.version.minor===c.minor&&t.version.patch===c.patch)?.verStr??null;default:return null}}async function he(o,e,c=""){let{lookRenderer:r,publisher:t}=o;if(e==="/.well-known/kanonak.json")return o.configSource?x(200,R[".json"],o.configSource):x(200,R[".json"],JSON.stringify($e(),null,2));if(e==="/kanonak.lock")return o.lockSource?x(200,R[".kan.yml"],o.lockSource):M(e);if(e==="/.well-known/kanonak-render.json")return x(200,R[".json"],JSON.stringify(ae(o),null,2));if(e==="/.well-known/kanonak-render")return x(200,R[".html"],ge(ae(o)));if(e==="/"||e==="/index.html"||e==="/index.css"){let l=r.publisherSubject(t);return e==="/index.css"?x(200,R[".css"],r.renderStylesheet(l)):x(200,R[".html"],await r.renderDocument(l,{rootIndex:!0}))}let a=".html",u=!1,d=e;for(let l of[".kan.yml",".css",".svg",".md",".html"])if(e.endsWith(l)){a=l,u=!0,d=e.slice(0,-l.length);break}let k=!u&&/application\/yaml|text\/yaml/i.test(c),y=d.endsWith("/");y&&d!=="/"&&(d=d.slice(0,-1));let s=xe.parse(d,t);if(!s)return M(e);if(s.kind==="package"){let l=Ce(o,s.package_,s.versionSpec);if(!l)return await We(o,s.package_,s.versionSpec,a===".kan.yml"||k)??M(e);if(a===".kan.yml"||k){let m=o.rawByNsKey.get(`${s.package_}@${l}`);return m!==void 0?x(200,R[".kan.yml"],m):M(e)}let f=o.pkgSelfByVer.get(`${s.package_}@${l}`);if(!f)return M(e);if(a===".css")return x(200,R[".css"],r.renderStylesheet(f));if(!y)return Le(d+"/");let p=s.versionSpec.kind==="any";if(p&&!r.hasDeclaredView(f)){let m=(o.pkgVersions.get(s.package_)||[]).map(S=>S.verStr);return x(200,R[".html"],r.renderPackageVersionList(s.package_,m,f))}return x(200,R[".html"],await r.renderDocument(f,p?{bareOverview:!0}:void 0))}if(s.kind==="resource"){let l=Ce(o,s.package_,s.versionSpec);if(!l)return M(e);let f=o.bySubject.get(`${t}/${s.package_}@${l}/${s.name}`);if(!f)return M(e);switch(a){case".css":return x(200,R[".css"],r.renderStylesheet(f));case".svg":return x(200,R[".svg"],await r.renderSvg(f));case".md":{let p=r.renderRawMarkdown(f);return p===void 0?M(e):x(200,R[".md"],p)}default:return x(200,R[".html"],await r.renderDocument(f))}}return M(e)}import{readFileSync as Ue}from"fs";var me=class{constructor(e={}){this.options=e}options;models=new Map;workspaceIndex;clearCache(){this.models.clear(),this.workspaceIndex=void 0}getWorkspaceIndex(){if(this.workspaceIndex)return this.workspaceIndex;let e=new Set,c=new Set;if(this.options.root!==void 0){let r=new O;for(let t of ee(this.options.root))try{let a=r.parse(Ue(t,"utf-8")).metadata?.namespace_;if(!a?.version)continue;let u=a.version;e.add(`${a.publisher}/${a.package_}@${u.major}.${u.minor}.${u.patch}`),c.add(`${a.publisher}/${a.package_}`)}catch{}}return this.workspaceIndex={exact:e,pkgs:c},this.workspaceIndex}async modelFor(e,c,r){let t=this.getWorkspaceIndex(),a={...this.options.fetchFn?{fetchFn:this.options.fetchFn}:{},...this.options.log?{log:this.options.log}:{}},u=c?r?t.exact.has(`${e}/${c}@${r}`):t.pkgs.has(`${e}/${c}`):[...t.pkgs].some(l=>l.startsWith(`${e}/`)),d,k;if(u&&this.options.root!==void 0){let l=this.options.root;d=`ws:${e}`,k=()=>pe(l,{publisher:e,...this.options.log?{log:this.options.log}:{}})}else{let l=c?r?`${e}/${c}@${r}`:`${e}/${c}`:e;d=`rm:${l}`,k=()=>ue(l,a)}let y=this.models.get(d);if(y)return y;let s=await k();return s.lookRenderer.setLinkMode("open-world"),this.models.set(d,s),s}async handle(e,c=""){let r=e.split("/").filter(Boolean);if(r.length===0)return{status:200,headers:{"Content-Type":"text/html; charset=utf-8"},body:Ne()};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 a=r.length>=2&&(r[1]==="index.html"||r[1]==="index.css"||r[1]==="kanonak.lock"||r[1]===".well-known"),u=!a&&r.length>=2?r[1]:void 0,d=!a&&r.length>=3&&/^\d+\.\d+\.\d+$/.test(r[2])?r[2]:void 0,k=await this.modelFor(t,u,d),y=e.endsWith("/")&&r.length>1?"/":"",s="/"+r.slice(1).join("/")+y,l=await he(k,s,c);return l.headers.Location?{...l,headers:{...l.headers,Location:`/${t}${l.headers.Location}`}}:l}};function Ne(){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{G as ClosureScopedRepository,me as RequestRouter,_e as UNIVERSAL_RENDER_BASE,ae as buildRenderDiagnostics,z as buildRenderStackWarnings,H as deriveImportClosure,Ne as landingPage,ue as loadResourceModel,pe as loadServerModel,ge as renderDiagnosticsHtml,C as renderRefKey,q as resolveRenderContract,he as route};
|
|
@@ -52,6 +52,16 @@ export interface RenderDiagnostics {
|
|
|
52
52
|
readonly sourceClass: string;
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Expression carriers that failed to compile while rendering the landing
|
|
57
|
+
* page (typescript#107 A1). Empty is the healthy state. A non-empty entry
|
|
58
|
+
* means an authored `tx.Expression` names a node class no runner
|
|
59
|
+
* implements — the page renders without it.
|
|
60
|
+
*/
|
|
61
|
+
readonly expressionCarriers: readonly {
|
|
62
|
+
readonly carrier: string;
|
|
63
|
+
readonly reason: string;
|
|
64
|
+
}[];
|
|
55
65
|
/** Every package namespace in the parsed render catalog + its resource count. */
|
|
56
66
|
readonly catalog: readonly {
|
|
57
67
|
readonly namespace: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as pe}from"../chunk-
|
|
1
|
+
import{a as pe}from"../chunk-S2VGNHHF.js";import"../chunk-RJK6Y4HS.js";import{a as ve,b as M,c as Un,e as X,f as Vn,g as Rn,h as le,i as q,j as G}from"../chunk-TW7NJDMW.js";import"../chunk-6VIUXP4N.js";import{a as ce,b as ue,c as de,e as $n,f as Tn,g as Bn,h as xn,m as fe}from"../chunk-SUXSCSHO.js";import{a as se}from"../chunk-KOWDHKBN.js";import"../chunk-PEJALHXK.js";import{e as U}from"../chunk-BA4HAURJ.js";import{b as Y,c as D,d as E,g as $,h as T,i as B,j as w,k as me,l as x,n as N,o as S,t as A}from"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.js";import{g as ie}from"../chunk-QILEJIFU.js";var Le="kanonak.org",Oe="document-ast",i=e=>({publisher:Le,package_:Oe,name:e}),m={Document:i("Document"),Block:i("Block"),Inline:i("Inline"),StructuredValue:i("StructuredValue"),Heading:i("Heading"),Paragraph:i("Paragraph"),RawBlock:i("RawBlock"),Text:i("Text"),StructuredMap:i("StructuredMap"),StructuredEntry:i("StructuredEntry"),StructuredList:i("StructuredList"),StringScalar:i("StringScalar"),IntegerScalar:i("IntegerScalar"),EscapeHint:i("EscapeHint"),MediaType:i("MediaType"),metadata:i("metadata"),children:i("children"),level:i("level"),inlines:i("inlines"),text:i("text"),entries:i("entries"),key:i("key"),value:i("value"),escapeHint:i("escapeHint"),items:i("items"),stringValue:i("stringValue"),integerValue:i("integerValue"),rawContent:i("rawContent"),mediaType:i("mediaType"),mimeType:i("mimeType"),ESC_RAW:i("esc-raw"),ESC_YAML_SAFE:i("esc-yaml-safe"),ESC_TOML_STRING:i("esc-toml-string"),ESC_TOML_MULTILINE:i("esc-toml-multiline"),ESC_JSON:i("esc-json"),ESC_DYNAMODB_BOOL:i("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:i("esc-dynamodb-number"),ESC_DYNAMODB_NULL:i("esc-dynamodb-null"),TEXT_PLAIN:i("text-plain"),TEXT_MARKDOWN:i("text-markdown"),TEXT_HTML:i("text-html"),TEXT_CSS:i("text-css"),APPLICATION_JSON:i("application-json"),TEXT_YAML:i("text-yaml"),IMAGE_SVG_XML:i("image-svg-xml"),ResourceLink:i("ResourceLink"),target:i("target"),linkLabel:i("linkLabel"),PropertyList:i("PropertyList"),propertyEntries:i("propertyEntries"),PropertyEntry:i("PropertyEntry"),propertyKey:i("propertyKey"),propertyValue:i("propertyValue"),Table:i("Table"),tableColumnLabels:i("tableColumnLabels"),tableRows:i("tableRows"),TableRow:i("TableRow"),tableCells:i("tableCells")};function ge(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var V=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(n,t){let r=Ie(n.metadata,t),o=Ke(n.children),s=["---",...r,"---","",o].join(`
|
|
2
2
|
`);return t?.trailingNewline&&(s.endsWith(`
|
|
3
3
|
`)||(s+=`
|
|
4
4
|
`)),s}};function Ie(e,n){if(!e)return[];let t=new Map;for(let c of e.entries)t.set(P(c.key),c);let r=new Map;if(n?.metadataRenames)for(let[c,u]of n.metadataRenames)r.set(P(c),u);let a=(n?.metadataKeys??e.entries.map(c=>c.key)).map(P),s=[];for(let c of a){let u=t.get(c);if(!u)continue;let f=r.get(c),l=P(f??c),d=ye(u.value,u.escapeHint);d!==void 0&&s.push(`${l}: ${d}`)}return s}function P(e){let n=e.lastIndexOf(".");return n===-1?e:e.substring(n+1)||e}function ye(e,n){switch(e.kind){case"StringScalar":return _e(e.stringValue,n);case"IntegerScalar":return String(e.integerValue);case"StructuredList":{let t=[];for(let r of e.items){let o=ye(r,n);o!==void 0&&t.push(o)}return t.join(", ")}case"StructuredMap":return;default:return}}function _e(e,n){return!n||ge(n,m.ESC_RAW)?e:ge(n,m.ESC_YAML_SAFE)?Ce(e):e}function Ce(e){return e.includes(`
|
|
@@ -88,4 +88,4 @@ ${e.rawContent}
|
|
|
88
88
|
`)&&(o+=`
|
|
89
89
|
`),o}};function C(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var K=class{backendUri="kanonak.org/transformations/dynamodb-json";render(n,t){if(!n.metadata)throw new Error("dynamodb-json backend: Document has no `metadata` channel. This backend serializes Document.metadata into DynamoDB attribute-value JSON \u2014 the transformation must populate that channel. (No silent empty artifact.)");let r=Ae(n.metadata,t),o=JSON.stringify(r,null,2);return t?.trailingNewline&&!o.endsWith(`
|
|
90
90
|
`)&&(o+=`
|
|
91
|
-
`),o}};function Ae(e,n){let t=new Map;for(let a of e.entries)t.set(a.key,a);let r=n?.metadataKeys??e.entries.map(a=>a.key),o={};for(let a of r){let s=t.get(a);if(!s)continue;let c=n?.metadataRenames.get(a)??a;o[c]=je(s.value,s.escapeHint)}return{M:o}}function je(e,n){switch(e.kind){case"StructuredMap":return Ae(e);case"StructuredList":return{L:e.items.map(t=>je(t,void 0))};case"StringScalar":return dn(e.stringValue,n??e.escapeHint);case"IntegerScalar":return fn(e.integerValue,n??e.escapeHint)}}function dn(e,n){if(n&&C(n,m.ESC_DYNAMODB_BOOL)){if(e==="true")return{BOOL:!0};if(e==="false")return{BOOL:!1};throw new Error(`dynamodb-json backend: a StringScalar hinted esc-dynamodb-bool must have the value "true" or "false"; got ${JSON.stringify(e)}.`)}if(n&&C(n,m.ESC_DYNAMODB_NULL))return{NULL:!0};if(n&&C(n,m.ESC_DYNAMODB_NUMBER)){if(e.trim()===""||Number.isNaN(Number(e)))throw new Error(`dynamodb-json backend: a StringScalar hinted esc-dynamodb-number must hold a numeric literal; got ${JSON.stringify(e)}.`);return{N:e}}return{S:e}}function fn(e,n){if(n&&C(n,m.ESC_DYNAMODB_BOOL))throw new Error(`dynamodb-json backend: esc-dynamodb-bool cannot apply to an IntegerScalar (value ${e}). Use a StringScalar "true"/"false".`);if(n&&C(n,m.ESC_DYNAMODB_NULL))throw new Error(`dynamodb-json backend: esc-dynamodb-null cannot apply to an IntegerScalar (value ${e}). Use a StringScalar hinted esc-dynamodb-null.`);return{N:String(e)}}var ln={"markdown-with-frontmatter":{formatUri:"kanonak.org/transformations/markdown-with-frontmatter",extension:".md"},"plain-markdown":{formatUri:"kanonak.org/transformations/plain-markdown",extension:".md"},toml:{formatUri:"kanonak.org/transformations/toml",extension:".toml"},json:{formatUri:"kanonak.org/transformations/json",extension:".json"},html:{formatUri:"kanonak.org/transformations/html",extension:".html"},svg:{formatUri:"kanonak.org/transformations/svg",extension:".svg"},stylesheet:{formatUri:"kanonak.org/transformations/stylesheet",extension:".css"},yaml:{formatUri:"kanonak.org/transformations/yaml",extension:".yaml"},"dynamodb-json":{formatUri:"kanonak.org/transformations/dynamodb-json",extension:".json"}},h=class extends Error{},H=class{backends=new Map;constructor(){this.register(new V),this.register(new R),this.register(new v),this.register(new L),this.register(new O),this.register(new I),this.register(new _),this.register(new K)}register(n){this.backends.set(n.backendUri,n)}async run(n){let t=n.transformationKanonaks??n.allKanonaks,r=M(n.transformation,t);if(!r.outputs.has(n.outputFormat))throw new h(`Transformation "${r.name}" does not declare output format "${n.outputFormat}". Declared: ${Array.from(r.outputs).join(", ")}`);let o=this.findBackend(n.outputFormat);if(!o)throw new h(`No backend registered for OutputFormat "${n.outputFormat}".`);let a=new q(n.repository,n.parser,n.objectParser),s=new le(a,n.allKanonaks,r.fragments);return r.kind==="instance"?this.runInstance(r,n,o,s):this.runSet(r,n,o,s)}async runInstance(n,t,r,o){let a=Ee(t.instances,n.inputPattern.requires),s=$e(a,n.inputPattern.sortBy),c=[];for(let u of s){let f=new Map;f.set("input",u);let l=await o.evaluate(n.rule,f);ee(l,n.name,`input "${u.name}"`);let d=ne(await o.evaluate(n.artifactName,f),n.name,`input "${u.name}"`),g=te(n.overrides.get(t.outputFormat),t.runtimeOverride),k=r.render(l,g);c.push({fileName:d,format:t.outputFormat,content:k,source:{kind:"instance",sourceName:u.name}})}return c}async runSet(n,t,r,o){let a=Ee(t.instances,n.inputPattern.requires),s=$e(a,n.inputPattern.sortBy);return n.partitionBy?this.runSetWithPartition(n,s,t,r,o):this.runSetSingle(n,s,t,r,o)}async runSetSingle(n,t,r,o,a){let s=new Map;s.set("inputs",t);let c=await a.evaluate(n.rule,s);ee(c,n.name,"set");let u=ne(await a.evaluate(n.artifactName,s),n.name,"set"),f=te(n.overrides.get(r.outputFormat),r.runtimeOverride),l=o.render(c,f);return[{fileName:u,format:r.outputFormat,content:l,source:{kind:"set",memberCount:t.length}}]}async runSetWithPartition(n,t,r,o,a){let s=n.partitionBy,c=new Map,u=[];for(let l of t){let d=yn(l,s);if(d==null)continue;let g=kn(d),k=c.get(g);k||(k={keyValue:d,keyDisplay:bn(d),members:[]},c.set(g,k),u.push(g)),k.members.push(l)}let f=[];for(let l of u){let d=c.get(l),g=new Map;g.set("inputs",d.members),g.set("key",d.keyValue);let k=await a.evaluate(n.rule,g);ee(k,n.name,`partition "${d.keyDisplay}"`);let Ue=ne(await a.evaluate(n.artifactName,g),n.name,`partition "${d.keyDisplay}"`),Ve=te(n.overrides.get(r.outputFormat),r.runtimeOverride),Re=o.render(k,Ve);f.push({fileName:Ue,format:r.outputFormat,content:Re,source:{kind:"set",memberCount:d.members.length,partitionKey:d.keyDisplay}})}return f}findBackend(n){let t=ln[n];if(t)return this.backends.get(t.formatUri)}};function Ee(e,n){return n.length===0?e:e.filter(t=>{for(let r of n)if(!gn(t,r))return!1;return!0})}function $e(e,n){if(n.length===0)return e;let t=[...e];return t.sort((r,o)=>{for(let a of n){let s=Te(r,a.byProperty),c=Te(o,a.byProperty),u=pn(s,c,a.order);if(u!==0)return u}return 0}),t}function Te(e,n){for(let t of e.statement){let r=re(t);if(!(!r||!N(r,n))){if(t instanceof $||t instanceof T||t instanceof B)return t.object;if(t instanceof x)throw new h(`Sort property "${n.name}" on instance "${e.name??"?"}" resolves to a list \u2014 list-typed properties are not sortable. Use a scalar property.`);if(t instanceof w)throw new h(`Sort property "${n.name}" on instance "${e.name??"?"}" resolves to a reference \u2014 reference-typed properties don't have a natural total order. Use a scalar property.`)}}}function pn(e,n,t){if(e===void 0&&n===void 0)return 0;if(e===void 0)return t==="ascending"?1:-1;if(n===void 0)return t==="ascending"?-1:1;let r;return typeof e=="number"&&typeof n=="number"?r=e-n:r=String(e).localeCompare(String(n)),t==="ascending"?r:-r}function gn(e,n){for(let t of e.statement){let r=re(t);if(!r||!N(r,n))continue;let o=t.object;if(o!=null&&!(typeof o=="string"&&o.length===0)&&!(Array.isArray(o)&&o.length===0))return!0}return!1}function yn(e,n){for(let t of e.statement){let r=re(t);if(!(!r||!N(r,n))&&(t instanceof $||t instanceof T||t instanceof B||t instanceof w||t instanceof x))return t.object}}function re(e){return e.predicate?.subject}function kn(e){if(e===void 0)return" undef";if(e===null)return" null";if(typeof e=="string")return`s:${e}`;if(typeof e=="number")return`n:${e}`;if(typeof e=="boolean")return`b:${e}`;if(e instanceof E){let n=e.subject;return`r:${n.publisher}/${n.package_}/${n.name}`}if(e instanceof Y){let n=e.name??"";return`k:${e.namespace??""}/${n}`}if(typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.publisher=="string"){let n=e;return`u:${n.publisher}/${n.package_}/${n.name}`}return`o:${JSON.stringify(e)}`}function bn(e){return e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):e instanceof E?e.subject.name:e instanceof Y?e.name??"":typeof e=="object"&&e!==null&&typeof e.name=="string"?e.name:""}function ee(e,n,t){if(typeof e!="object"||e===null||e.kind!=="Document")throw new h(`Transformation "${n}" rule did not yield a Document for ${t}. Got: ${Be(e)}`)}function ne(e,n,t){if(typeof e=="string")return e;if(Array.isArray(e)&&e.every(hn))return e.map(r=>String(r)).join("");throw new h(`Transformation "${n}" artifactName did not yield a string for ${t}. Got: ${Be(e)}`)}function hn(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Be(e){if(e===void 0)return"undefined";if(e===null)return"null";if(Array.isArray(e))return`array(${e.length})`;if(typeof e=="object"){let n=e.kind;return n?`object(kind=${n})`:"object"}return typeof e}function te(e,n){if(!e&&!n)return;let t={metadataRenames:n?.metadataRenames??e?.metadataRenames??new Map},r=n?.metadataKeys??e?.metadataKeys;r!==void 0&&(t.metadataKeys=r);let o=n?.trailingNewline??e?.trailingNewline;o!==void 0&&(t.trailingNewline=o);let a=n?.omitWrapper??e?.omitWrapper;return a!==void 0&&(t.omitWrapper=a),t}var p=class extends Error{constructor(t,r){super(t);this.cause=r;this.name="RenderError"}cause},xe={publisher:"kanonak.org",package_:"derivation",name:"default"},oe=class{constructor(n,t=new se,r=new fe){this.repository=n;this.parser=t;this.objectParser=r}repository;parser;objectParser;runner=new H;cachedCatalog=void 0;invalidate(){this.cachedCatalog=void 0}async renderViaLook(n){let t=await this.getCatalog(),r=A(t,n.resource);if(!(r instanceof D))throw new p(`Resource not found: ${b(n.resource)}`);let o=new G(t),a;if(n.format.name==="html")a=await o.renderHtml(r);else if(n.format.name==="stylesheet")a=o.renderStylesheet(r);else throw new p(`LookRenderer does not support format ${b(n.format)} \u2014 only formats.html and formats.stylesheet are implemented in v0.1.`);return{content:a,format:n.format,filename:r.name}}async findDerivation(n){let t=await this.getCatalog(),r=A(t,n.resource);if(!(r instanceof D))return;let o=n.variant??xe;return pe(r,n.format,o,t)}async render(n){if(n.format.name==="html"||n.format.name==="stylesheet"){let a=await this.getCatalog(),s=A(a,n.resource);if(s instanceof D){let u=new G(a).findCascadedLook(s);if(u&&!wn(u.sourceClass)){let f=await this.findDerivation(n);if(!f||Dn(f))return this.renderViaLook({resource:n.resource,format:n.format})}}}let t=await this.findDerivation(n);if(!t)throw new p(`No derivation found for ${b(n.resource)} \u2192 format ${b(n.format)}`+(n.variant?` variant ${b(n.variant)}`:""));let r=ie(t.transformation.version),o={transformation:{publisher:t.transformation.publisher,package_:t.transformation.package_,name:t.transformation.name,...r?{version:r}:{}},input:n.resource,format:n.format};return n.omitWrapper!==void 0&&(o.omitWrapper=n.omitWrapper),this.runTransformation(o)}async runTransformation(n){let t=await this.getCatalog(),r=A(t,n.transformation);if(!(r instanceof D))throw new p(`Transformation not found: ${b(n.transformation)}`);let o=A(t,n.input);if(!(o instanceof D))throw new p(`Input resource not found: ${b(n.input)}`);let a=M(r,t),s=Sn(a.outputs,n.format);if(!s)throw new p(`Transformation ${b(n.transformation)} declares outputs [${[...a.outputs].join(", ")}], none of which corresponds to format ${b(n.format)}`);let c;try{c=await this.runner.run({transformation:r,instances:[o],allKanonaks:t,repository:this.repository,parser:this.parser,objectParser:this.objectParser,outputFormat:s,...n.omitWrapper!==void 0?{runtimeOverride:{metadataRenames:new Map,omitWrapper:n.omitWrapper}}:{}})}catch(u){throw new p(`Transformation execution failed: ${u.message}`,u)}if(c.length===0)throw new p("Transformation produced no artifacts");return{content:c[0].content,format:n.format,filename:c[0].fileName}}async getCatalog(){return this.cachedCatalog||(this.cachedCatalog=await this.objectParser.parseKanonaks(this.repository)),this.cachedCatalog}};function b(e){return`${e.publisher}/${e.package_}/${e.name}`}function Dn(e){return typeof e.source=="string"?!1:e.source.publisher==="kanonak.org"&&e.source.package_==="core-rdf"&&e.source.name==="Resource"}function wn(e){return e.publisher==="kanonak.org"&&e.package_==="core-rdf"&&e.name==="Resource"}function Sn(e,n){let t=n.name;if(e.has(t))return t;for(let r of e)if(r.startsWith(t+"-")||r===t)return r}var An="kanonak.org/core-rdf/type";function ae(e){let n=En(e),t,r={type:""};for(let o of e.statement){let a=o.predicate?.subject;if(!a)throw new Error(`Expression node ${n} has a statement with no resolved predicate`);if(U(a)===An){if(!(o instanceof w))throw new Error(`Expression node ${n} has a non-reference 'type' statement`);if(t!==void 0)throw new Error(`Expression node ${n} declares more than one type \u2014 a runtime tree node is exactly one operator/literal/leaf class`);t=U(o.object.subject);continue}let s=a.name;if(s in r)throw new Error(`Expression node ${n} declares operand '${s}' more than once`);r[s]=jn(o,n,s)}if(t===void 0)throw new Error(`Expression node ${n} declares no type \u2014 the runtime dispatches on it`);return r.type=t,r}function jn(e,n,t){if(e instanceof $||e instanceof de||e instanceof T||e instanceof B)return e.object;if(e instanceof w)return U(e.object.subject);if(e instanceof me)return ae(e.object);if(e instanceof x)return(e.object??[]).map((r,o)=>{if(r instanceof E)return U(r.subject);if(r instanceof ce)return ae(r);if(r instanceof ue)return r.value;throw new Error(`Expression node ${n}: '${t}'[${o}] is not a serializable list item`)});throw new Error(`Expression node ${n}: operand '${t}' has an unserializable statement kind`)}function En(e){let n=e;return n.name?`'${n.name}'`:"(embedded)"}export{I as CssBackend,xe as DEFAULT_VARIANT,m as DOCAST,Oe as DOCAST_PKG,Le as DOCAST_PUB,K as DynamoDbBackend,le as ExpressionEngineV3,Vn as ExpressionEvalErrorV3,L as HtmlBackend,v as JsonBackend,V as MarkdownFrontmatterBackend,q as ReferenceResolver,p as RenderError,ln as SUPPORTED_FORMATS_V3,O as SvgBackend,xn as TX_V3,Tn as TX_V3_PKG,$n as TX_V3_PUB,Bn as TX_V3_VERSION_MAJOR,R as TomlBackend,oe as TransformationEngine,ve as TransformationLoadErrorV3,h as TransformationRunnerErrorV3,H as TransformationRunnerV3,_ as YamlBackend,Rn as compileExpression,M as compileTransformationV3,Un as isRawStringV3,X as renderMarkdownToHtml,ae as toExpressionRuntimeTree};
|
|
91
|
+
`),o}};function Ae(e,n){let t=new Map;for(let a of e.entries)t.set(a.key,a);let r=n?.metadataKeys??e.entries.map(a=>a.key),o={};for(let a of r){let s=t.get(a);if(!s)continue;let c=n?.metadataRenames.get(a)??a;o[c]=je(s.value,s.escapeHint)}return{M:o}}function je(e,n){switch(e.kind){case"StructuredMap":return Ae(e);case"StructuredList":return{L:e.items.map(t=>je(t,void 0))};case"StringScalar":return dn(e.stringValue,n??e.escapeHint);case"IntegerScalar":return fn(e.integerValue,n??e.escapeHint)}}function dn(e,n){if(n&&C(n,m.ESC_DYNAMODB_BOOL)){if(e==="true")return{BOOL:!0};if(e==="false")return{BOOL:!1};throw new Error(`dynamodb-json backend: a StringScalar hinted esc-dynamodb-bool must have the value "true" or "false"; got ${JSON.stringify(e)}.`)}if(n&&C(n,m.ESC_DYNAMODB_NULL))return{NULL:!0};if(n&&C(n,m.ESC_DYNAMODB_NUMBER)){if(e.trim()===""||Number.isNaN(Number(e)))throw new Error(`dynamodb-json backend: a StringScalar hinted esc-dynamodb-number must hold a numeric literal; got ${JSON.stringify(e)}.`);return{N:e}}return{S:e}}function fn(e,n){if(n&&C(n,m.ESC_DYNAMODB_BOOL))throw new Error(`dynamodb-json backend: esc-dynamodb-bool cannot apply to an IntegerScalar (value ${e}). Use a StringScalar "true"/"false".`);if(n&&C(n,m.ESC_DYNAMODB_NULL))throw new Error(`dynamodb-json backend: esc-dynamodb-null cannot apply to an IntegerScalar (value ${e}). Use a StringScalar hinted esc-dynamodb-null.`);return{N:String(e)}}var ln={"markdown-with-frontmatter":{formatUri:"kanonak.org/transformations/markdown-with-frontmatter",extension:".md"},"plain-markdown":{formatUri:"kanonak.org/transformations/plain-markdown",extension:".md"},toml:{formatUri:"kanonak.org/transformations/toml",extension:".toml"},json:{formatUri:"kanonak.org/transformations/json",extension:".json"},html:{formatUri:"kanonak.org/transformations/html",extension:".html"},svg:{formatUri:"kanonak.org/transformations/svg",extension:".svg"},stylesheet:{formatUri:"kanonak.org/transformations/stylesheet",extension:".css"},yaml:{formatUri:"kanonak.org/transformations/yaml",extension:".yaml"},"dynamodb-json":{formatUri:"kanonak.org/transformations/dynamodb-json",extension:".json"}},h=class extends Error{},H=class{backends=new Map;constructor(){this.register(new V),this.register(new R),this.register(new v),this.register(new L),this.register(new O),this.register(new I),this.register(new _),this.register(new K)}register(n){this.backends.set(n.backendUri,n)}async run(n){let t=n.transformationKanonaks??n.allKanonaks,r=M(n.transformation,t);if(!r.outputs.has(n.outputFormat))throw new h(`Transformation "${r.name}" does not declare output format "${n.outputFormat}". Declared: ${Array.from(r.outputs).join(", ")}`);let o=this.findBackend(n.outputFormat);if(!o)throw new h(`No backend registered for OutputFormat "${n.outputFormat}".`);let a=new q(n.repository,n.parser,n.objectParser),s=new le(a,n.allKanonaks,r.fragments);return r.kind==="instance"?this.runInstance(r,n,o,s):this.runSet(r,n,o,s)}async runInstance(n,t,r,o){let a=Ee(t.instances,n.inputPattern.requires),s=$e(a,n.inputPattern.sortBy),c=[];for(let u of s){let f=new Map;f.set("input",u);let l=await o.evaluate(n.rule,f);ee(l,n.name,`input "${u.name}"`);let d=ne(await o.evaluate(n.artifactName,f),n.name,`input "${u.name}"`),g=te(n.overrides.get(t.outputFormat),t.runtimeOverride),k=r.render(l,g);c.push({fileName:d,format:t.outputFormat,content:k,source:{kind:"instance",sourceName:u.name}})}return c}async runSet(n,t,r,o){let a=Ee(t.instances,n.inputPattern.requires),s=$e(a,n.inputPattern.sortBy);return n.partitionBy?this.runSetWithPartition(n,s,t,r,o):this.runSetSingle(n,s,t,r,o)}async runSetSingle(n,t,r,o,a){let s=new Map;s.set("inputs",t);let c=await a.evaluate(n.rule,s);ee(c,n.name,"set");let u=ne(await a.evaluate(n.artifactName,s),n.name,"set"),f=te(n.overrides.get(r.outputFormat),r.runtimeOverride),l=o.render(c,f);return[{fileName:u,format:r.outputFormat,content:l,source:{kind:"set",memberCount:t.length}}]}async runSetWithPartition(n,t,r,o,a){let s=n.partitionBy,c=new Map,u=[];for(let l of t){let d=yn(l,s);if(d==null)continue;let g=kn(d),k=c.get(g);k||(k={keyValue:d,keyDisplay:bn(d),members:[]},c.set(g,k),u.push(g)),k.members.push(l)}let f=[];for(let l of u){let d=c.get(l),g=new Map;g.set("inputs",d.members),g.set("key",d.keyValue);let k=await a.evaluate(n.rule,g);ee(k,n.name,`partition "${d.keyDisplay}"`);let Ue=ne(await a.evaluate(n.artifactName,g),n.name,`partition "${d.keyDisplay}"`),Ve=te(n.overrides.get(r.outputFormat),r.runtimeOverride),Re=o.render(k,Ve);f.push({fileName:Ue,format:r.outputFormat,content:Re,source:{kind:"set",memberCount:d.members.length,partitionKey:d.keyDisplay}})}return f}findBackend(n){let t=ln[n];if(t)return this.backends.get(t.formatUri)}};function Ee(e,n){return n.length===0?e:e.filter(t=>{for(let r of n)if(!gn(t,r))return!1;return!0})}function $e(e,n){if(n.length===0)return e;let t=[...e];return t.sort((r,o)=>{for(let a of n){let s=Te(r,a.byProperty),c=Te(o,a.byProperty),u=pn(s,c,a.order);if(u!==0)return u}return 0}),t}function Te(e,n){for(let t of e.statement){let r=re(t);if(!(!r||!N(r,n))){if(t instanceof $||t instanceof T||t instanceof B)return t.object;if(t instanceof x)throw new h(`Sort property "${n.name}" on instance "${e.name??"?"}" resolves to a list \u2014 list-typed properties are not sortable. Use a scalar property.`);if(t instanceof w)throw new h(`Sort property "${n.name}" on instance "${e.name??"?"}" resolves to a reference \u2014 reference-typed properties don't have a natural total order. Use a scalar property.`)}}}function pn(e,n,t){if(e===void 0&&n===void 0)return 0;if(e===void 0)return t==="ascending"?1:-1;if(n===void 0)return t==="ascending"?-1:1;let r;return typeof e=="number"&&typeof n=="number"?r=e-n:r=String(e).localeCompare(String(n)),t==="ascending"?r:-r}function gn(e,n){for(let t of e.statement){let r=re(t);if(!r||!N(r,n))continue;let o=t.object;if(o!=null&&!(typeof o=="string"&&o.length===0)&&!(Array.isArray(o)&&o.length===0))return!0}return!1}function yn(e,n){for(let t of e.statement){let r=re(t);if(!(!r||!N(r,n))&&(t instanceof $||t instanceof T||t instanceof B||t instanceof w||t instanceof x))return t.object}}function re(e){return e.predicate?.subject}function kn(e){if(e===void 0)return" undef";if(e===null)return" null";if(typeof e=="string")return`s:${e}`;if(typeof e=="number")return`n:${e}`;if(typeof e=="boolean")return`b:${e}`;if(e instanceof E){let n=e.subject;return`r:${n.publisher}/${n.package_}/${n.name}`}if(e instanceof Y){let n=e.name??"";return`k:${e.namespace??""}/${n}`}if(typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.publisher=="string"){let n=e;return`u:${n.publisher}/${n.package_}/${n.name}`}return`o:${JSON.stringify(e)}`}function bn(e){return e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):e instanceof E?e.subject.name:e instanceof Y?e.name??"":typeof e=="object"&&e!==null&&typeof e.name=="string"?e.name:""}function ee(e,n,t){if(typeof e!="object"||e===null||e.kind!=="Document")throw new h(`Transformation "${n}" rule did not yield a Document for ${t}. Got: ${Be(e)}`)}function ne(e,n,t){if(typeof e=="string")return e;if(Array.isArray(e)&&e.every(hn))return e.map(r=>String(r)).join("");throw new h(`Transformation "${n}" artifactName did not yield a string for ${t}. Got: ${Be(e)}`)}function hn(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Be(e){if(e===void 0)return"undefined";if(e===null)return"null";if(Array.isArray(e))return`array(${e.length})`;if(typeof e=="object"){let n=e.kind;return n?`object(kind=${n})`:"object"}return typeof e}function te(e,n){if(!e&&!n)return;let t={metadataRenames:n?.metadataRenames??e?.metadataRenames??new Map},r=n?.metadataKeys??e?.metadataKeys;r!==void 0&&(t.metadataKeys=r);let o=n?.trailingNewline??e?.trailingNewline;o!==void 0&&(t.trailingNewline=o);let a=n?.omitWrapper??e?.omitWrapper;return a!==void 0&&(t.omitWrapper=a),t}var p=class extends Error{constructor(t,r){super(t);this.cause=r;this.name="RenderError"}cause},xe={publisher:"kanonak.org",package_:"derivation",name:"default"},oe=class{constructor(n,t=new se,r=new fe){this.repository=n;this.parser=t;this.objectParser=r}repository;parser;objectParser;runner=new H;cachedCatalog=void 0;invalidate(){this.cachedCatalog=void 0}async renderViaLook(n){let t=await this.getCatalog(),r=A(t,n.resource);if(!(r instanceof D))throw new p(`Resource not found: ${b(n.resource)}`);let o=new G(t),a;if(n.format.name==="html")a=await o.renderHtml(r);else if(n.format.name==="stylesheet")a=o.renderStylesheet(r);else throw new p(`LookRenderer does not support format ${b(n.format)} \u2014 only formats.html and formats.stylesheet are implemented in v0.1.`);return{content:a,format:n.format,filename:r.name}}async findDerivation(n){let t=await this.getCatalog(),r=A(t,n.resource);if(!(r instanceof D))return;let o=n.variant??xe;return pe(r,n.format,o,t)}async render(n){if(n.format.name==="html"||n.format.name==="stylesheet"){let a=await this.getCatalog(),s=A(a,n.resource);if(s instanceof D){let u=new G(a).findCascadedLook(s);if(u&&!wn(u.sourceClass)){let f=await this.findDerivation(n);if(!f||Dn(f))return this.renderViaLook({resource:n.resource,format:n.format})}}}let t=await this.findDerivation(n);if(!t)throw new p(`No derivation found for ${b(n.resource)} \u2192 format ${b(n.format)}`+(n.variant?` variant ${b(n.variant)}`:""));let r=ie(t.transformation.version),o={transformation:{publisher:t.transformation.publisher,package_:t.transformation.package_,name:t.transformation.name,...r?{version:r}:{}},input:n.resource,format:n.format};return n.omitWrapper!==void 0&&(o.omitWrapper=n.omitWrapper),this.runTransformation(o)}async runTransformation(n){let t=await this.getCatalog(),r=A(t,n.transformation);if(!(r instanceof D))throw new p(`Transformation not found: ${b(n.transformation)}`);let o=A(t,n.input);if(!(o instanceof D))throw new p(`Input resource not found: ${b(n.input)}`);let a=M(r,t),s=Sn(a.outputs,n.format);if(!s)throw new p(`Transformation ${b(n.transformation)} declares outputs [${[...a.outputs].join(", ")}], none of which corresponds to format ${b(n.format)}`);let c;try{c=await this.runner.run({transformation:r,instances:[o],allKanonaks:t,repository:this.repository,parser:this.parser,objectParser:this.objectParser,outputFormat:s,...n.omitWrapper!==void 0?{runtimeOverride:{metadataRenames:new Map,omitWrapper:n.omitWrapper}}:{}})}catch(u){throw new p(`Transformation execution failed: ${u.message}`,u)}if(c.length===0)throw new p("Transformation produced no artifacts");return{content:c[0].content,format:n.format,filename:c[0].fileName}}async getCatalog(){return this.cachedCatalog||(this.cachedCatalog=await this.objectParser.parseKanonaks(this.repository)),this.cachedCatalog}};function b(e){return`${e.publisher}/${e.package_}/${e.name}`}function Dn(e){return typeof e.source=="string"?!1:e.source.publisher==="kanonak.org"&&e.source.package_==="core-rdf"&&e.source.name==="Resource"}function wn(e){return e.publisher==="kanonak.org"&&e.package_==="core-rdf"&&e.name==="Resource"}function Sn(e,n){let t=n.name;if(e.has(t))return t;for(let r of e)if(r.startsWith(t+"-")||r===t)return r}var An="kanonak.org/core-rdf/type";function ae(e){let n=En(e),t,r={type:""};for(let o of e.statement){let a=o.predicate?.subject;if(!a)throw new Error(`Expression node ${n} has a statement with no resolved predicate`);if(U(a)===An){if(!(o instanceof w))throw new Error(`Expression node ${n} has a non-reference 'type' statement`);if(t!==void 0)throw new Error(`Expression node ${n} declares more than one type \u2014 a runtime tree node is exactly one operator/literal/leaf class`);t=U(o.object.subject);continue}let s=a.name;if(s in r)throw new Error(`Expression node ${n} declares operand '${s}' more than once`);r[s]=jn(o,n,s)}if(t===void 0)throw new Error(`Expression node ${n} declares no type \u2014 the runtime dispatches on it`);return r.type=t,r}function jn(e,n,t){if(e instanceof $||e instanceof de||e instanceof T||e instanceof B)return e.object;if(e instanceof w)return U(e.object.subject);if(e instanceof me)return ae(e.object);if(e instanceof x)return(e.object??[]).map((r,o)=>{if(r instanceof E)return U(r.subject);if(r instanceof ce)return ae(r);if(r instanceof ue)return r.value;throw new Error(`Expression node ${n}: '${t}'[${o}] is not a serializable list item`)});throw new Error(`Expression node ${n}: operand '${t}' has an unserializable statement kind`)}function En(e){let n=e;return n.name?`'${n.name}'`:"(embedded)"}export{I as CssBackend,xe as DEFAULT_VARIANT,m as DOCAST,Oe as DOCAST_PKG,Le as DOCAST_PUB,K as DynamoDbBackend,le as ExpressionEngineV3,Rn as ExpressionEvalErrorV3,L as HtmlBackend,v as JsonBackend,V as MarkdownFrontmatterBackend,q as ReferenceResolver,p as RenderError,ln as SUPPORTED_FORMATS_V3,O as SvgBackend,xn as TX_V3,Tn as TX_V3_PKG,$n as TX_V3_PUB,Bn as TX_V3_VERSION_MAJOR,R as TomlBackend,oe as TransformationEngine,ve as TransformationLoadErrorV3,h as TransformationRunnerErrorV3,H as TransformationRunnerV3,_ as YamlBackend,Un as compileExpression,M as compileTransformationV3,Vn as isRawStringV3,X as renderMarkdownToHtml,ae as toExpressionRuntimeTree};
|