@fedify/vocab-runtime 2.4.0-pr.936.41 → 2.4.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.
Files changed (138) hide show
  1. package/deno.json +4 -2
  2. package/dist/{tests/docloader-Ck8bcBir.mjs → contexts-BK1CqBR5.cjs} +164 -275
  3. package/dist/{tests/docloader-S_gQZ2tt.cjs → contexts-DPuJ4UYL.js} +160 -294
  4. package/dist/{docloader-C_dir7Xb.d.ts → docloader-CYwqh5Df.d.cts} +66 -2
  5. package/dist/{docloader-D2DTRiyA.d.cts → docloader-CYwqh5Df.d.ts} +66 -2
  6. package/dist/internal/jsonld-cache.cjs +70 -1
  7. package/dist/internal/jsonld-cache.d.cts +35 -2
  8. package/dist/internal/jsonld-cache.d.ts +35 -2
  9. package/dist/internal/jsonld-cache.js +67 -2
  10. package/dist/internal/portable-dereference.cjs +721 -0
  11. package/dist/internal/portable-dereference.d.cts +349 -0
  12. package/dist/internal/portable-dereference.d.ts +349 -0
  13. package/dist/internal/portable-dereference.js +702 -0
  14. package/dist/internal/signed-representation.cjs +378 -0
  15. package/dist/internal/signed-representation.d.cts +144 -0
  16. package/dist/internal/signed-representation.d.ts +144 -0
  17. package/dist/internal/signed-representation.js +371 -0
  18. package/dist/jsonld.cjs +2 -2
  19. package/dist/mod.cjs +711 -4527
  20. package/dist/mod.d.cts +400 -8
  21. package/dist/mod.d.ts +400 -9
  22. package/dist/mod.js +692 -4522
  23. package/dist/portable-DqtfLy_1.d.cts +160 -0
  24. package/dist/portable-DtWsu2yU.d.ts +160 -0
  25. package/dist/tests/body-CYiu9CO-.mjs +130 -0
  26. package/dist/tests/body-CkEwROsn.cjs +153 -0
  27. package/dist/tests/body.test.cjs +89 -0
  28. package/dist/tests/body.test.d.cts +1 -0
  29. package/dist/tests/body.test.d.mts +1 -0
  30. package/dist/tests/body.test.mjs +90 -0
  31. package/dist/tests/contexts-CIKsin4e.mjs +4512 -0
  32. package/dist/tests/contexts-DizzBjz4.cjs +4523 -0
  33. package/dist/tests/decimal.test.cjs +8 -7
  34. package/dist/tests/decimal.test.mjs +8 -6
  35. package/dist/tests/digest-3FeH2Y-Q.cjs +176 -0
  36. package/dist/tests/digest-COC7xDiQ.mjs +141 -0
  37. package/dist/tests/digest.test.cjs +102 -0
  38. package/dist/tests/digest.test.d.cts +1 -0
  39. package/dist/tests/digest.test.d.mts +1 -0
  40. package/dist/tests/digest.test.mjs +103 -0
  41. package/dist/tests/docloader-C3YFl6y4.cjs +396 -0
  42. package/dist/tests/docloader-CvmS4sVq.mjs +373 -0
  43. package/dist/tests/docloader.test.cjs +692 -39
  44. package/dist/tests/docloader.test.mjs +686 -34
  45. package/dist/tests/internal/multicodec.test.cjs +2 -3
  46. package/dist/tests/internal/multicodec.test.mjs +2 -2
  47. package/dist/tests/internal/portable-dereference.test.cjs +172 -0
  48. package/dist/tests/internal/portable-dereference.test.d.cts +1 -0
  49. package/dist/tests/internal/portable-dereference.test.d.mts +1 -0
  50. package/dist/tests/internal/portable-dereference.test.mjs +173 -0
  51. package/dist/tests/jsonld-cache-BPQmOZWD.mjs +342 -0
  52. package/dist/tests/jsonld-cache-C07AyNOY.cjs +397 -0
  53. package/dist/tests/jsonld-cache.test.cjs +101 -298
  54. package/dist/tests/jsonld-cache.test.mjs +94 -289
  55. package/dist/tests/{key-_wXwomh_.cjs → key-C-AYkdJJ.cjs} +11 -4
  56. package/dist/tests/{key-CDGDH_vC.mjs → key-C2Db_TAJ.mjs} +11 -3
  57. package/dist/tests/key.test.cjs +6 -5
  58. package/dist/tests/key.test.mjs +6 -4
  59. package/dist/tests/langstr.test.cjs +4 -4
  60. package/dist/tests/langstr.test.mjs +2 -2
  61. package/dist/tests/link.test.cjs +2 -3
  62. package/dist/tests/link.test.mjs +2 -2
  63. package/dist/tests/multibase/multibase.test.cjs +8 -9
  64. package/dist/tests/multibase/multibase.test.mjs +6 -6
  65. package/dist/tests/{multibase-Bz_UUDtL.cjs → multibase-B5Mea7Ip.cjs} +19 -2
  66. package/dist/tests/{multibase-B4bvakyA.mjs → multibase-BPnF_L4e.mjs} +12 -1
  67. package/dist/tests/portable-dereference-BNXtgg5U.cjs +278 -0
  68. package/dist/tests/portable-dereference-DRE5bz-l.mjs +249 -0
  69. package/dist/tests/portable-media-BLKllU56.cjs +153 -0
  70. package/dist/tests/portable-media-DRSGBORB.mjs +148 -0
  71. package/dist/tests/portable-media.test.cjs +222 -0
  72. package/dist/tests/portable-media.test.d.cts +1 -0
  73. package/dist/tests/portable-media.test.d.mts +1 -0
  74. package/dist/tests/portable-media.test.mjs +223 -0
  75. package/dist/tests/portable-workers.test.cjs +36 -0
  76. package/dist/tests/portable-workers.test.d.cts +2 -0
  77. package/dist/tests/portable-workers.test.d.mts +2 -0
  78. package/dist/tests/portable-workers.test.mjs +35 -0
  79. package/dist/tests/{request-uk51rkhO.cjs → request-8vPWtV1-.cjs} +10 -4
  80. package/dist/tests/{request-C8CaGwtt.mjs → request-DRaOaTqD.mjs} +8 -2
  81. package/dist/tests/request.test.cjs +7 -4
  82. package/dist/tests/request.test.mjs +5 -2
  83. package/dist/tests/signed-representation.test.cjs +588 -0
  84. package/dist/tests/signed-representation.test.d.cts +1 -0
  85. package/dist/tests/signed-representation.test.d.mts +1 -0
  86. package/dist/tests/signed-representation.test.mjs +589 -0
  87. package/dist/tests/temporal.test.cjs +1 -2
  88. package/dist/tests/temporal.test.mjs +1 -1
  89. package/dist/tests/url-BNakuZ8k.cjs +998 -0
  90. package/dist/tests/url-DMxmp7ZG.mjs +859 -0
  91. package/dist/tests/url.test.cjs +489 -6
  92. package/dist/tests/url.test.mjs +489 -5
  93. package/dist/url-DrGTR8yv.cjs +993 -0
  94. package/dist/url-Dzyp-NsC.js +860 -0
  95. package/package.json +27 -4
  96. package/scripts/test-bun.mjs +17 -0
  97. package/src/body.test.ts +125 -0
  98. package/src/body.ts +152 -0
  99. package/src/contexts/cid-v1.json +114 -0
  100. package/src/contexts/fep-22cd.json +21 -0
  101. package/src/contexts/miscellany.json +17 -0
  102. package/src/contexts.ts +39 -1
  103. package/src/digest.test.ts +220 -0
  104. package/src/digest.ts +229 -0
  105. package/src/docloader.test.ts +918 -27
  106. package/src/docloader.ts +320 -105
  107. package/src/internal/jsonld-cache.ts +97 -1
  108. package/src/internal/portable-dereference.test.ts +254 -0
  109. package/src/internal/portable-dereference.ts +1000 -0
  110. package/src/internal/signed-representation.ts +565 -0
  111. package/src/jsonld-cache.test.ts +89 -0
  112. package/src/key.test.ts +9 -0
  113. package/src/key.ts +11 -1
  114. package/src/mod.ts +28 -0
  115. package/src/multibase/multibase.test.ts +5 -5
  116. package/src/portable-media.test.ts +293 -0
  117. package/src/portable-media.ts +264 -0
  118. package/src/portable-workers.test.ts +81 -0
  119. package/src/portable.ts +180 -0
  120. package/src/preprocessor.ts +7 -0
  121. package/src/request.test.ts +10 -1
  122. package/src/request.ts +9 -1
  123. package/src/signed-representation.test.ts +338 -0
  124. package/src/url.test.ts +823 -3
  125. package/src/url.ts +700 -23
  126. package/tsdown.config.ts +2 -0
  127. package/dist/tests/url-CsOV_B_P.cjs +0 -482
  128. package/dist/tests/url-Du7RQQgP.mjs +0 -392
  129. package/dist/url-DD4F0ULf.cjs +0 -483
  130. package/dist/url-DGVbSVVi.js +0 -393
  131. /package/dist/{chunk-M78iaK0I.cjs → rolldown-runtime-B7lfambq.cjs} +0 -0
  132. /package/dist/tests/{langstr-CbAxaeEZ.cjs → langstr-C4Fl80ae.cjs} +0 -0
  133. /package/dist/tests/{langstr-Di5AvKpB.mjs → langstr-CQ26J_L7.mjs} +0 -0
  134. /package/dist/tests/{link-NUUWCdnK.mjs → link-Cevmc87v.mjs} +0 -0
  135. /package/dist/tests/{link-FguCydMA.cjs → link-DlKm8bEr.cjs} +0 -0
  136. /package/dist/tests/{multicodec-CxGVGa91.cjs → multicodec-CLRPeW4N.cjs} +0 -0
  137. /package/dist/tests/{multicodec-CyFp54fI.mjs → multicodec-CRIj_05H.mjs} +0 -0
  138. /package/dist/tests/{chunk-C2EiDwsr.cjs → rolldown-runtime-emK7D4bc.cjs} +0 -0
@@ -100,6 +100,13 @@ interface DocumentLoaderOptions {
100
100
  * @since 1.8.0
101
101
  */
102
102
  signal?: AbortSignal;
103
+ /**
104
+ * Whether to lower error-level logs for recoverable document loading
105
+ * failures to warning-level logs. The loader still throws the error.
106
+ * @default `false`
107
+ * @since 2.4.0
108
+ */
109
+ suppressError?: boolean;
103
110
  }
104
111
  /**
105
112
  * A JSON-LD document loader that fetches documents from the Web.
@@ -140,6 +147,28 @@ interface DocumentLoaderFactoryOptions {
140
147
  * @since 2.2.0
141
148
  */
142
149
  maxRedirection?: number;
150
+ /**
151
+ * The timeout in milliseconds for each call of the created document
152
+ * loader. The timeout is shared by all the steps of a call, including
153
+ * URL validation, every HTTP redirect and alternate document link it
154
+ * follows, retries, and reading the response body; it does not restart
155
+ * for each of them. It does not interrupt synchronous work such as
156
+ * parsing a document that has already been received.
157
+ *
158
+ * When a call times out, the loader throws a {@link FetchError} without
159
+ * a {@link FetchError.response}, whose `cause` is a `DOMException` named
160
+ * `"TimeoutError"`. An `AbortSignal` passed through
161
+ * {@link DocumentLoaderOptions.signal} still cancels a call; in that case
162
+ * the loader throws the signal's reason as before.
163
+ *
164
+ * Fractional values are rounded up. Set it to `null` to turn off the
165
+ * timeout.
166
+ * @default `10000` (10 seconds)
167
+ * @throws {RangeError} If the value is not a positive finite number or is
168
+ * greater than 2,147,483,647 (about 24.8 days).
169
+ * @since 2.4.0
170
+ */
171
+ timeout?: number | null;
143
172
  }
144
173
  /**
145
174
  * A factory function that creates an authenticated {@link DocumentLoader} for
@@ -160,11 +189,39 @@ type AuthenticatedDocumentLoaderFactory = (identity: {
160
189
  * @param url The URL of the document to load.
161
190
  * @param response The response to get the document from.
162
191
  * @param fetch The function to fetch the document.
192
+ * @param options The options for loading the document.
163
193
  * @returns The loaded remote document.
164
194
  * @throws {FetchError} If the response is not OK.
165
195
  * @internal
166
196
  */
167
- declare function getRemoteDocument(url: string, response: Response, fetch: (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>): Promise<RemoteDocument>;
197
+ declare function getRemoteDocument(url: string, response: Response, fetch: (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>, options?: DocumentLoaderOptions): Promise<RemoteDocument>;
198
+ /**
199
+ * Resolves {@link DocumentLoaderFactoryOptions.timeout} into milliseconds.
200
+ * @param timeout The timeout option. `undefined` means the default timeout,
201
+ * and `null` means no timeout.
202
+ * @returns The timeout in milliseconds, or `null` if it is turned off.
203
+ * @throws {RangeError} If the timeout is invalid.
204
+ * @internal
205
+ */
206
+ declare function resolveDocumentLoaderTimeout(timeout: number | null | undefined): number | null;
207
+ /**
208
+ * Bounds each call of the given document loader by the given timeout.
209
+ * The timeout is combined with the caller's `signal`, and the combined
210
+ * signal is passed to the loader. The call settles no later than the
211
+ * timeout even if the loader is stuck in a step that cannot be aborted,
212
+ * e.g., a DNS lookup.
213
+ *
214
+ * A timed-out call throws a {@link FetchError} without a response, whose
215
+ * `cause` is a `DOMException` named `"TimeoutError"`. If the caller's
216
+ * signal is aborted, its reason is thrown instead.
217
+ * @param loader The document loader to bound.
218
+ * @param timeout The timeout in milliseconds, or `null` for no timeout.
219
+ * It is assumed to have been resolved by
220
+ * {@link resolveDocumentLoaderTimeout}.
221
+ * @returns The bounded document loader.
222
+ * @internal
223
+ */
224
+ declare function withDocumentLoaderTimeout(loader: DocumentLoader, timeout: number | null): DocumentLoader;
168
225
  /**
169
226
  * Options for {@link getDocumentLoader}.
170
227
  * @since 1.3.0
@@ -177,6 +234,10 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
177
234
  }
178
235
  /**
179
236
  * Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
237
+ * At most 20 HTTP redirects and alternate document links are followed in total
238
+ * per call. Revisiting a URL within that chain throws a {@link FetchError}.
239
+ * Each call times out after 10 seconds by default; see
240
+ * {@link DocumentLoaderFactoryOptions.timeout}.
180
241
  *
181
242
  * The created loader preloads the below frequently used contexts by default
182
243
  * (unless `options.skipPreloadedContexts` is set to `true`):
@@ -186,8 +247,10 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
186
247
  * - <https://w3id.org/security/data-integrity/v1>
187
248
  * - <https://w3id.org/security/data-integrity/v2>
188
249
  * - <https://www.w3.org/ns/did/v1>
250
+ * - <https://www.w3.org/ns/cid/v1>
189
251
  * - <https://w3id.org/security/multikey/v1>
190
252
  * - <https://w3id.org/fep/ef61>
253
+ * - <https://w3id.org/fep/7aa9>
191
254
  * - <https://purl.archive.org/socialweb/webfinger>
192
255
  * - <http://schema.org/>
193
256
  * @param options Options for the document loader.
@@ -198,7 +261,8 @@ declare function getDocumentLoader({
198
261
  allowPrivateAddress,
199
262
  maxRedirection,
200
263
  skipPreloadedContexts,
264
+ timeout,
201
265
  userAgent
202
266
  }?: GetDocumentLoaderOptions): DocumentLoader;
203
267
  //#endregion
204
- export { DocumentLoaderOptions as a, getDocumentLoader as c, FetchError as d, GetUserAgentOptions as f, logRequest as h, DocumentLoaderFactoryOptions as i, getRemoteDocument as l, getUserAgent as m, DocumentLoader as n, GetDocumentLoaderOptions as o, createActivityPubRequest as p, DocumentLoaderFactory as r, RemoteDocument as s, AuthenticatedDocumentLoaderFactory as t, CreateRequestOptions as u };
268
+ export { logRequest as _, DocumentLoaderOptions as a, getDocumentLoader as c, withDocumentLoaderTimeout as d, CreateRequestOptions as f, getUserAgent as g, createActivityPubRequest as h, DocumentLoaderFactoryOptions as i, getRemoteDocument as l, GetUserAgentOptions as m, DocumentLoader as n, GetDocumentLoaderOptions as o, FetchError as p, DocumentLoaderFactory as r, RemoteDocument as s, AuthenticatedDocumentLoaderFactory as t, resolveDocumentLoaderTimeout as u };
@@ -1,9 +1,74 @@
1
1
 
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const require_url = require("../url-DD4F0ULf.cjs");
3
+ const require_url = require("../url-DrGTR8yv.cjs");
4
4
  const require_jsonld = require("../jsonld.cjs");
5
5
  //#region src/internal/jsonld-cache.ts
6
+ /**
7
+ * Reads expanded gateways, including an unmapped term on portable actors.
8
+ * The original values and their order are preserved for URL validation by
9
+ * the caller. An explicitly mapped FEP-ef61 property always takes precedence.
10
+ * @internal Used by generated vocabulary classes and portable proof checks.
11
+ */
12
+ function getPortableActorGateways(node, allowUnmapped = true) {
13
+ const property = "https://w3id.org/fep/ef61/gateways";
14
+ if (globalThis.Object.hasOwn(node, property)) return Array.isArray(node[property]) ? node[property] : void 0;
15
+ if (!allowUnmapped || typeof node["@id"] !== "string" || !("http://www.w3.org/ns/ldp#inbox" in node) || !("https://www.w3.org/ns/activitystreams#outbox" in node)) return void 0;
16
+ try {
17
+ if (!require_url.getFe34Origin(require_url.parseIri(require_url.fromCompatibleEf61Id(node["@id"]) ?? node["@id"])).startsWith("did:")) return void 0;
18
+ } catch (error) {
19
+ if (error instanceof TypeError) return void 0;
20
+ throw error;
21
+ }
22
+ return Array.isArray(node["_:gateways"]) ? node["_:gateways"] : void 0;
23
+ }
6
24
  const noJsonLdContext = Symbol("noJsonLdContext");
25
+ const documentLoaderWrappers = /* @__PURE__ */ new WeakMap();
26
+ /**
27
+ * Registers a loader wrapper with the shared released-wrapper registry.
28
+ * Both suppression and snapshot wrappers must use this registry so mixed
29
+ * chains can be unwrapped. The caller updates the state on release.
30
+ * @internal Not a public API.
31
+ */
32
+ function registerDocumentLoaderWrapper(loader, state) {
33
+ documentLoaderWrappers.set(loader, state);
34
+ }
35
+ /**
36
+ * Removes released loader wrappers, stopping at the first active wrapper.
37
+ * Active wrappers retain their operation's suppression or snapshot cache.
38
+ * @internal Not a public API.
39
+ */
40
+ function unwrapReleasedDocumentLoader(base) {
41
+ for (let state = documentLoaderWrappers.get(base); state?.released; state = documentLoaderWrappers.get(base)) base = state.base;
42
+ return base;
43
+ }
44
+ /**
45
+ * Lowers context loading failure logs for one accessor operation. Parsed
46
+ * objects retain the loader, so release it before returning to the caller.
47
+ * Released wrappers are unwrapped to avoid accumulating loader chains.
48
+ * @internal Used by generated vocabulary accessors; not a public API.
49
+ */
50
+ function createScopedContextLoader(base, suppressError) {
51
+ base = unwrapReleasedDocumentLoader(base);
52
+ if (!suppressError) return {
53
+ loader: base,
54
+ release: () => {}
55
+ };
56
+ const state = {
57
+ base,
58
+ released: false
59
+ };
60
+ const loader = (url, options) => base(url, state.released ? options : {
61
+ ...options,
62
+ suppressError: true
63
+ });
64
+ registerDocumentLoaderWrapper(loader, state);
65
+ return {
66
+ loader,
67
+ release: () => {
68
+ state.released = true;
69
+ }
70
+ };
71
+ }
7
72
  /**
8
73
  * Checks whether an IRI is trusted relative to another IRI.
9
74
  *
@@ -274,6 +339,10 @@ function combineContexts(inheritedContext, ownContext) {
274
339
  }
275
340
  //#endregion
276
341
  exports.compactJsonLdCache = compactJsonLdCache;
342
+ exports.createScopedContextLoader = createScopedContextLoader;
277
343
  exports.getJsonLdContext = getJsonLdContext;
344
+ exports.getPortableActorGateways = getPortableActorGateways;
278
345
  exports.isTrustedIriOrigin = isTrustedIriOrigin;
279
346
  exports.normalizeJsonLdIris = normalizeJsonLdIris;
347
+ exports.registerDocumentLoaderWrapper = registerDocumentLoaderWrapper;
348
+ exports.unwrapReleasedDocumentLoader = unwrapReleasedDocumentLoader;
@@ -1,8 +1,41 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { n as DocumentLoader } from "../docloader-D2DTRiyA.cjs";
2
+ import { n as DocumentLoader } from "../docloader-CYwqh5Df.cjs";
3
3
 
4
4
  //#region src/internal/jsonld-cache.d.ts
5
5
  /**
6
+ * Reads expanded gateways, including an unmapped term on portable actors.
7
+ * The original values and their order are preserved for URL validation by
8
+ * the caller. An explicitly mapped FEP-ef61 property always takes precedence.
9
+ * @internal Used by generated vocabulary classes and portable proof checks.
10
+ */
11
+ declare function getPortableActorGateways(node: Record<string, unknown>, allowUnmapped?: boolean): unknown[] | undefined;
12
+ /**
13
+ * Registers a loader wrapper with the shared released-wrapper registry.
14
+ * Both suppression and snapshot wrappers must use this registry so mixed
15
+ * chains can be unwrapped. The caller updates the state on release.
16
+ * @internal Not a public API.
17
+ */
18
+ declare function registerDocumentLoaderWrapper(loader: DocumentLoader, state: {
19
+ readonly base: DocumentLoader;
20
+ released: boolean;
21
+ }): void;
22
+ /**
23
+ * Removes released loader wrappers, stopping at the first active wrapper.
24
+ * Active wrappers retain their operation's suppression or snapshot cache.
25
+ * @internal Not a public API.
26
+ */
27
+ declare function unwrapReleasedDocumentLoader(base: DocumentLoader): DocumentLoader;
28
+ /**
29
+ * Lowers context loading failure logs for one accessor operation. Parsed
30
+ * objects retain the loader, so release it before returning to the caller.
31
+ * Released wrappers are unwrapped to avoid accumulating loader chains.
32
+ * @internal Used by generated vocabulary accessors; not a public API.
33
+ */
34
+ declare function createScopedContextLoader(base: DocumentLoader, suppressError?: boolean): {
35
+ loader: DocumentLoader;
36
+ release: () => void;
37
+ };
38
+ /**
6
39
  * Options for deciding whether two IRIs should be treated as same-origin.
7
40
  *
8
41
  * @internal Technically exported for generated vocabulary classes, but not
@@ -45,4 +78,4 @@ declare function getJsonLdContext(value: unknown, depth?: number): unknown;
45
78
  */
46
79
  declare function compactJsonLdCache(normalized: unknown, original: unknown, documentLoader?: DocumentLoader, depth?: number, inheritedContext?: unknown): Promise<unknown>;
47
80
  //#endregion
48
- export { IriTrustOptions, compactJsonLdCache, getJsonLdContext, isTrustedIriOrigin, normalizeJsonLdIris };
81
+ export { IriTrustOptions, compactJsonLdCache, createScopedContextLoader, getJsonLdContext, getPortableActorGateways, isTrustedIriOrigin, normalizeJsonLdIris, registerDocumentLoaderWrapper, unwrapReleasedDocumentLoader };
@@ -1,8 +1,41 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { n as DocumentLoader } from "../docloader-C_dir7Xb.js";
2
+ import { n as DocumentLoader } from "../docloader-CYwqh5Df.js";
3
3
 
4
4
  //#region src/internal/jsonld-cache.d.ts
5
5
  /**
6
+ * Reads expanded gateways, including an unmapped term on portable actors.
7
+ * The original values and their order are preserved for URL validation by
8
+ * the caller. An explicitly mapped FEP-ef61 property always takes precedence.
9
+ * @internal Used by generated vocabulary classes and portable proof checks.
10
+ */
11
+ declare function getPortableActorGateways(node: Record<string, unknown>, allowUnmapped?: boolean): unknown[] | undefined;
12
+ /**
13
+ * Registers a loader wrapper with the shared released-wrapper registry.
14
+ * Both suppression and snapshot wrappers must use this registry so mixed
15
+ * chains can be unwrapped. The caller updates the state on release.
16
+ * @internal Not a public API.
17
+ */
18
+ declare function registerDocumentLoaderWrapper(loader: DocumentLoader, state: {
19
+ readonly base: DocumentLoader;
20
+ released: boolean;
21
+ }): void;
22
+ /**
23
+ * Removes released loader wrappers, stopping at the first active wrapper.
24
+ * Active wrappers retain their operation's suppression or snapshot cache.
25
+ * @internal Not a public API.
26
+ */
27
+ declare function unwrapReleasedDocumentLoader(base: DocumentLoader): DocumentLoader;
28
+ /**
29
+ * Lowers context loading failure logs for one accessor operation. Parsed
30
+ * objects retain the loader, so release it before returning to the caller.
31
+ * Released wrappers are unwrapped to avoid accumulating loader chains.
32
+ * @internal Used by generated vocabulary accessors; not a public API.
33
+ */
34
+ declare function createScopedContextLoader(base: DocumentLoader, suppressError?: boolean): {
35
+ loader: DocumentLoader;
36
+ release: () => void;
37
+ };
38
+ /**
6
39
  * Options for deciding whether two IRIs should be treated as same-origin.
7
40
  *
8
41
  * @internal Technically exported for generated vocabulary classes, but not
@@ -45,4 +78,4 @@ declare function getJsonLdContext(value: unknown, depth?: number): unknown;
45
78
  */
46
79
  declare function compactJsonLdCache(normalized: unknown, original: unknown, documentLoader?: DocumentLoader, depth?: number, inheritedContext?: unknown): Promise<unknown>;
47
80
  //#endregion
48
- export { IriTrustOptions, compactJsonLdCache, getJsonLdContext, isTrustedIriOrigin, normalizeJsonLdIris };
81
+ export { IriTrustOptions, compactJsonLdCache, createScopedContextLoader, getJsonLdContext, getPortableActorGateways, isTrustedIriOrigin, normalizeJsonLdIris, registerDocumentLoaderWrapper, unwrapReleasedDocumentLoader };
@@ -1,8 +1,73 @@
1
1
 
2
- import { a as formatIri, c as haveSameIriOrigin, s as haveSameFe34Origin } from "../url-DGVbSVVi.js";
2
+ import { _ as parseIri, c as getFe34Origin, d as haveSameIriOrigin, o as formatIri, s as fromCompatibleEf61Id, u as haveSameFe34Origin } from "../url-Dzyp-NsC.js";
3
3
  import jsonld_default from "../jsonld.js";
4
4
  //#region src/internal/jsonld-cache.ts
5
+ /**
6
+ * Reads expanded gateways, including an unmapped term on portable actors.
7
+ * The original values and their order are preserved for URL validation by
8
+ * the caller. An explicitly mapped FEP-ef61 property always takes precedence.
9
+ * @internal Used by generated vocabulary classes and portable proof checks.
10
+ */
11
+ function getPortableActorGateways(node, allowUnmapped = true) {
12
+ const property = "https://w3id.org/fep/ef61/gateways";
13
+ if (globalThis.Object.hasOwn(node, property)) return Array.isArray(node[property]) ? node[property] : void 0;
14
+ if (!allowUnmapped || typeof node["@id"] !== "string" || !("http://www.w3.org/ns/ldp#inbox" in node) || !("https://www.w3.org/ns/activitystreams#outbox" in node)) return void 0;
15
+ try {
16
+ if (!getFe34Origin(parseIri(fromCompatibleEf61Id(node["@id"]) ?? node["@id"])).startsWith("did:")) return void 0;
17
+ } catch (error) {
18
+ if (error instanceof TypeError) return void 0;
19
+ throw error;
20
+ }
21
+ return Array.isArray(node["_:gateways"]) ? node["_:gateways"] : void 0;
22
+ }
5
23
  const noJsonLdContext = Symbol("noJsonLdContext");
24
+ const documentLoaderWrappers = /* @__PURE__ */ new WeakMap();
25
+ /**
26
+ * Registers a loader wrapper with the shared released-wrapper registry.
27
+ * Both suppression and snapshot wrappers must use this registry so mixed
28
+ * chains can be unwrapped. The caller updates the state on release.
29
+ * @internal Not a public API.
30
+ */
31
+ function registerDocumentLoaderWrapper(loader, state) {
32
+ documentLoaderWrappers.set(loader, state);
33
+ }
34
+ /**
35
+ * Removes released loader wrappers, stopping at the first active wrapper.
36
+ * Active wrappers retain their operation's suppression or snapshot cache.
37
+ * @internal Not a public API.
38
+ */
39
+ function unwrapReleasedDocumentLoader(base) {
40
+ for (let state = documentLoaderWrappers.get(base); state?.released; state = documentLoaderWrappers.get(base)) base = state.base;
41
+ return base;
42
+ }
43
+ /**
44
+ * Lowers context loading failure logs for one accessor operation. Parsed
45
+ * objects retain the loader, so release it before returning to the caller.
46
+ * Released wrappers are unwrapped to avoid accumulating loader chains.
47
+ * @internal Used by generated vocabulary accessors; not a public API.
48
+ */
49
+ function createScopedContextLoader(base, suppressError) {
50
+ base = unwrapReleasedDocumentLoader(base);
51
+ if (!suppressError) return {
52
+ loader: base,
53
+ release: () => {}
54
+ };
55
+ const state = {
56
+ base,
57
+ released: false
58
+ };
59
+ const loader = (url, options) => base(url, state.released ? options : {
60
+ ...options,
61
+ suppressError: true
62
+ });
63
+ registerDocumentLoaderWrapper(loader, state);
64
+ return {
65
+ loader,
66
+ release: () => {
67
+ state.released = true;
68
+ }
69
+ };
70
+ }
6
71
  /**
7
72
  * Checks whether an IRI is trusted relative to another IRI.
8
73
  *
@@ -272,4 +337,4 @@ function combineContexts(inheritedContext, ownContext) {
272
337
  return [...inherited, ...own];
273
338
  }
274
339
  //#endregion
275
- export { compactJsonLdCache, getJsonLdContext, isTrustedIriOrigin, normalizeJsonLdIris };
340
+ export { compactJsonLdCache, createScopedContextLoader, getJsonLdContext, getPortableActorGateways, isTrustedIriOrigin, normalizeJsonLdIris, registerDocumentLoaderWrapper, unwrapReleasedDocumentLoader };