@@ -9,8 +9,7 @@ import { jsonObjectHas, jsonObjectKeys, jsonValue, pointerGet, pointerStep } fro
99import { mimeMatch } from "./utilities.js" ;
1010
1111/**
12- * @import { JrefJrefNode, JrefNode } from "../jref/jref-ast.js"
13- * @import { JsonNode } from "../json/jsonast.js"
12+ * @import { JrefNode } from "../jref/jref-ast.js"
1413 * @import { UriSchemePlugin } from "./uri-schemes/uri-scheme-plugin.js"
1514 * @import { DocumentNode, MediaTypePlugin } from "./media-types/media-type-plugin.js"
1615 * @import * as API from "./hyperjump.d.ts"
@@ -21,20 +20,19 @@ import { mimeMatch } from "./utilities.js";
2120// TODO: Support filters
2221
2322/**
24- * @template {JrefNode<unknown>} [T=JrefJrefNode]
25- * @implements API.Hyperjump<T>
23+ * @implements API.Hyperjump<JrefNode>
2624 */
2725export class Hyperjump {
2826 // TODO: Add config to enable schemes and media types
2927 #config;
3028
31- /** @type Record<string, DocumentNode<T> > */
29+ /** @type Record<string, DocumentNode> */
3230 #cache;
3331
3432 /** @type Record<string, UriSchemePlugin> */
3533 #uriSchemePlugins;
3634
37- /** @type Record<string, MediaTypePlugin<DocumentNode<T> >> */
35+ /** @type Record<string, MediaTypePlugin<DocumentNode>> */
3836 #mediaTypePlugins;
3937
4038 /** @type API.GetOptions */
@@ -62,7 +60,7 @@ export class Hyperjump {
6260 this . addMediaTypePlugin ( new JsonMediaTypePlugin ( ) ) ;
6361 }
6462
65- /** @type API.Hyperjump<T >["get"] */
63+ /** @type API.Hyperjump<JrefNode >["get"] */
6664 async get ( uri , options = this . #defaultGetOptions) {
6765 uri = resolveIri ( uri , contextUri ( ) ) ;
6866 const id = toAbsoluteIri ( uri ) ;
@@ -95,28 +93,28 @@ export class Hyperjump {
9593 return await this . #followReferences( node ) ;
9694 }
9795
98- /** @type (node: JrefNode<T> ) => Promise<JsonNode<T> > */
96+ /** @type (node: JrefNode) => Promise<JrefNode > */
9997 async #followReferences( node ) {
100- if ( node . jrefType === "reference" ) {
98+ if ( node . type === "reference" ) {
10199 return this . get ( node . href , { referencedFrom : toAbsoluteIri ( node . location ) } ) ;
102100 } else {
103- return /** @type JsonNode<T> */ ( node ) ;
101+ return node ;
104102 }
105103 }
106104
107- /** @type API.Hyperjump<T >["addUriSchemePlugin"] */
105+ /** @type API.Hyperjump<JrefNode >["addUriSchemePlugin"] */
108106 addUriSchemePlugin ( plugin ) {
109107 for ( const scheme of plugin . schemes ) {
110108 this . #uriSchemePlugins[ scheme ] = plugin ;
111109 }
112110 }
113111
114- /** @type API.Hyperjump<T >["removeUriSchemePlugin"] */
112+ /** @type API.Hyperjump<JrefNode >["removeUriSchemePlugin"] */
115113 removeUriSchemePlugin ( scheme ) {
116114 delete this . #uriSchemePlugins[ scheme ] ;
117115 }
118116
119- /** @type API.Hyperjump<T >["retrieve"] */
117+ /** @type API.Hyperjump<JrefNode >["retrieve"] */
120118 async retrieve ( uri , options ) {
121119 const { scheme } = parseIri ( uri ) ;
122120
@@ -127,7 +125,7 @@ export class Hyperjump {
127125 return this . #uriSchemePlugins[ scheme ] . retrieve ( uri , options ) ;
128126 }
129127
130- /** @type API.Hyperjump<T >["acceptableMediaTypes"] */
128+ /** @type API.Hyperjump<JrefNode >["acceptableMediaTypes"] */
131129 acceptableMediaTypes ( ) {
132130 let accept = "" ;
133131
@@ -151,7 +149,7 @@ export class Hyperjump {
151149 return accept ;
152150 }
153151
154- /** @type API.Hyperjump<T >["getMediaType"] */
152+ /** @type API.Hyperjump<JrefNode >["getMediaType"] */
155153 getMediaType ( uri ) {
156154 for ( const contentType in this . #mediaTypePlugins) {
157155 for ( const extension of this . #mediaTypePlugins[ contentType ] . extensions ) {
@@ -166,22 +164,22 @@ export class Hyperjump {
166164 throw new UnknownMediaTypeError ( `The media type of the file at '${ uri } ' could not be determined. Use the 'addMediaTypePlugin' function to add support for this media type.` ) ;
167165 }
168166
169- /** @type API.Hyperjump<T >["addMediaTypePlugin"] */
167+ /** @type API.Hyperjump<JrefNode >["addMediaTypePlugin"] */
170168 addMediaTypePlugin ( plugin ) {
171169 this . #mediaTypePlugins[ plugin . mediaType ] = plugin ;
172170 }
173171
174- /** @type API.Hyperjump<T >["removeMediaTypePlugin"] */
172+ /** @type API.Hyperjump<JrefNode >["removeMediaTypePlugin"] */
175173 removeMediaTypePlugin ( contentType ) {
176174 delete this . #mediaTypePlugins[ contentType ] ;
177175 }
178176
179- /** @type API.Hyperjump<T >["setMediaTypeQuality"] */
177+ /** @type API.Hyperjump<JrefNode >["setMediaTypeQuality"] */
180178 setMediaTypeQuality ( contentType , quality ) {
181179 this . #mediaTypePlugins[ contentType ] . quality = quality ;
182180 }
183181
184- /** @type (response: Response) => Promise<DocumentNode<T> > */
182+ /** @type (response: Response) => Promise<DocumentNode> */
185183 #parseResponse( response ) {
186184 const contentTypeText = response . headers . get ( "content-type" ) ;
187185 if ( contentTypeText === null ) {
@@ -201,12 +199,12 @@ export class Hyperjump {
201199 value = jsonValue ;
202200 has = jsonObjectHas ;
203201
204- /** @type API.Hyperjump<T >["step"] */
202+ /** @type API.Hyperjump<JrefNode >["step"] */
205203 async step ( key , node ) {
206204 return await this . #followReferences( pointerStep ( key , node ) ) ;
207205 }
208206
209- /** @type API.Hyperjump<T >["iter"] */
207+ /** @type API.Hyperjump<JrefNode >["iter"] */
210208 async * iter ( node ) {
211209 if ( node . jsonType === "array" ) {
212210 for ( const itemNode of node . children ) {
@@ -217,7 +215,7 @@ export class Hyperjump {
217215
218216 keys = jsonObjectKeys ;
219217
220- /** @type API.Hyperjump<T >["values"] */
218+ /** @type API.Hyperjump<JrefNode >["values"] */
221219 async * values ( node ) {
222220 if ( node . jsonType === "object" ) {
223221 for ( const propertyNode of node . children ) {
@@ -226,7 +224,7 @@ export class Hyperjump {
226224 }
227225 }
228226
229- /** @type API.Hyperjump<T >["entries"] */
227+ /** @type API.Hyperjump<JrefNode >["entries"] */
230228 async * entries ( node ) {
231229 if ( node . jsonType === "object" ) {
232230 for ( const propertyNode of node . children ) {
0 commit comments