@@ -64,7 +64,8 @@ async function* generateProperty(
6464 contextLoader?: DocumentLoader,
6565 suppressError?: boolean,
6666 tracerProvider?: TracerProvider,
67- } = {}
67+ baseUrl?: URL
68+ } = {},
6869 ): Promise<${ getTypeNames ( property . range , types ) } | null> {
6970 const documentLoader =
7071 options.documentLoader ?? this._documentLoader ?? getDocumentLoader();
@@ -76,6 +77,7 @@ async function* generateProperty(
7677 ${ JSON . stringify ( metadata . name ) } ,
7778 ${ JSON . stringify ( metadata . version ) } ,
7879 );
80+ const baseUrl = options.baseUrl;
7981 return await tracer.startActiveSpan("activitypub.lookup_object", async (span) => {
8082 let fetchResult: RemoteDocument;
8183 try {
@@ -99,7 +101,7 @@ async function* generateProperty(
99101 try {
100102 const obj = await this.#${ property . singularName } _fromJsonLd(
101103 document,
102- { documentLoader, contextLoader, tracerProvider }
104+ { documentLoader, contextLoader, tracerProvider, baseUrl }
103105 );
104106 span.setAttribute("activitypub.object.id", (obj.id ?? url).href);
105107 span.setAttribute(
@@ -133,6 +135,7 @@ async function* generateProperty(
133135 documentLoader?: DocumentLoader,
134136 contextLoader?: DocumentLoader,
135137 tracerProvider?: TracerProvider,
138+ baseUrl?: URL
136139 }
137140 ): Promise<${ getTypeNames ( property . range , types ) } > {
138141 const documentLoader =
@@ -141,6 +144,7 @@ async function* generateProperty(
141144 options.contextLoader ?? this._contextLoader ?? getDocumentLoader();
142145 const tracerProvider = options.tracerProvider ??
143146 this._tracerProvider ?? trace.getTracerProvider();
147+ const baseUrl = options.baseUrl;
144148 ` ;
145149 for ( const range of property . range ) {
146150 if ( ! ( range in types ) ) continue ;
@@ -149,7 +153,7 @@ async function* generateProperty(
149153 try {
150154 return await ${ rangeType . name } .fromJsonLd(
151155 jsonLd,
152- { documentLoader, contextLoader, tracerProvider },
156+ { documentLoader, contextLoader, tracerProvider, baseUrl },
153157 );
154158 } catch (e) {
155159 if (!(e instanceof TypeError)) throw e;
@@ -190,6 +194,7 @@ async function* generateProperty(
190194 contextLoader?: DocumentLoader,
191195 suppressError?: boolean,
192196 tracerProvider?: TracerProvider,
197+ baseUrl?: URL
193198 } = {}
194199 ): Promise<${ getTypeNames ( property . range , types ) } | null> {
195200 if (this._warning != null) {
@@ -221,7 +226,7 @@ async function* generateProperty(
221226 ${ JSON . stringify ( property . compactName ) } ];
222227 const obj = Array.isArray(prop) ? prop[0] : prop;
223228 if (obj != null && typeof obj === "object" && "@context" in obj) {
224- return await this.#${ property . singularName } _fromJsonLd(obj, options);
229+ return await this.#${ property . singularName } _fromJsonLd(obj, {... options, baseUrl: options.baseUrl} );
225230 }
226231 }
227232 ` ;
@@ -258,6 +263,7 @@ async function* generateProperty(
258263 contextLoader?: DocumentLoader,
259264 suppressError?: boolean,
260265 tracerProvider?: TracerProvider,
266+ baseUrl?: URL
261267 } = {}
262268 ): AsyncIterable<${ getTypeNames ( property . range , types ) } > {
263269 if (this._warning != null) {
@@ -272,7 +278,7 @@ async function* generateProperty(
272278 if (v instanceof URL) {
273279 const fetched =
274280 await this.#fetch${ pascalCase ( property . singularName ) } (
275- v, options);
281+ v, {... options, baseUrl: options.baseUrl} );
276282 if (fetched == null) continue;
277283 vs[i] = fetched;
278284 this._cachedJsonLd = undefined;
@@ -292,7 +298,8 @@ async function* generateProperty(
292298 ${ JSON . stringify ( property . compactName ) } ];
293299 const obj = Array.isArray(prop) ? prop[i] : prop;
294300 if (obj != null && typeof obj === "object" && "@context" in obj) {
295- yield await this.#${ property . singularName } _fromJsonLd(obj, options);
301+ yield await this.#${ property . singularName } _fromJsonLd(obj, {...options, baseUrl: options.baseUrl
302+ });
296303 continue;
297304 }
298305 }
0 commit comments