@fedify/vocab-runtime 2.0.8 → 2.0.10
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/deno.json +1 -1
- package/dist/{chunk-CUT6urMc.cjs → chunk-CKQMccvm.cjs} +7 -9
- package/dist/jsonld.cjs +4 -5
- package/dist/jsonld.d.cts +3 -4
- package/dist/jsonld.d.ts +2 -2
- package/dist/jsonld.js +1 -3
- package/dist/mod.cjs +56 -121
- package/dist/mod.d.cts +1 -5
- package/dist/mod.d.ts +1 -5
- package/dist/mod.js +32 -100
- package/dist/tests/{chunk-DWy1uDak.cjs → chunk-Do9eywBl.cjs} +13 -17
- package/dist/tests/docloader.test.cjs +65 -106
- package/dist/tests/{docloader.test.js → docloader.test.mjs} +60 -107
- package/dist/tests/internal/multicodec.test.cjs +5 -7
- package/dist/tests/internal/{multicodec.test.js → multicodec.test.mjs} +3 -4
- package/dist/tests/key.test.cjs +39 -70
- package/dist/tests/{key.test.js → key.test.mjs} +32 -62
- package/dist/tests/langstr.test.cjs +6 -8
- package/dist/tests/{langstr.test.js → langstr.test.mjs} +2 -4
- package/dist/tests/{link-CdFPEo9O.cjs → link-B6ZWBZhf.cjs} +6 -8
- package/dist/tests/{link-Ck2yj4dH.js → link-B8JGXSS2.mjs} +1 -2
- package/dist/tests/link.test.cjs +5 -7
- package/dist/tests/{link.test.js → link.test.mjs} +3 -4
- package/dist/tests/multibase/multibase.test.cjs +10 -17
- package/dist/tests/multibase/{multibase.test.js → multibase.test.mjs} +10 -18
- package/dist/tests/{multibase-B2D6B0V4.cjs → multibase-CgYqpk4Z.cjs} +43 -49
- package/dist/tests/{multibase-BdHCGO4H.js → multibase-jcKrOpuU.mjs} +5 -12
- package/dist/tests/{multicodec-mHcRzSGY.cjs → multicodec-DeYop8xg.cjs} +16 -18
- package/dist/tests/{multicodec-DvC5xnX2.js → multicodec-aqbZnrNi.mjs} +1 -2
- package/dist/tests/{request-Cqx2eUpt.js → request-BaPLwjp1.mjs} +4 -45
- package/dist/tests/{request-D2-F2dMS.cjs → request-DIHEQLwz.cjs} +38 -72
- package/dist/tests/request.test.cjs +23 -24
- package/dist/tests/request.test.mjs +42 -0
- package/dist/tests/{url-C5Vs9nYh.cjs → url-Cr2K-wzd.cjs} +31 -35
- package/dist/tests/{url-fW_DHbih.js → url-Djghaq0m.mjs} +3 -7
- package/dist/tests/url.test.cjs +5 -7
- package/dist/tests/{url.test.js → url.test.mjs} +3 -4
- package/package.json +3 -3
- package/dist/tests/request.test.js +0 -43
- /package/dist/tests/{docloader.test.d.ts → docloader.test.d.mts} +0 -0
- /package/dist/tests/internal/{multicodec.test.d.ts → multicodec.test.d.mts} +0 -0
- /package/dist/tests/{key.test.d.ts → key.test.d.mts} +0 -0
- /package/dist/tests/{langstr.test.d.ts → langstr.test.d.mts} +0 -0
- /package/dist/tests/{link.test.d.ts → link.test.d.mts} +0 -0
- /package/dist/tests/multibase/{multibase.test.d.ts → multibase.test.d.mts} +0 -0
- /package/dist/tests/{request.test.d.ts → request.test.d.mts} +0 -0
- /package/dist/tests/{url.test.d.ts → url.test.d.mts} +0 -0
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HttpHeaderLink } from "./link-
|
|
3
|
-
import {
|
|
4
|
-
import "node:module";
|
|
1
|
+
import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-BaPLwjp1.mjs";
|
|
2
|
+
import { t as HttpHeaderLink } from "./link-B8JGXSS2.mjs";
|
|
3
|
+
import { a as validatePublicUrl, t as UrlError } from "./url-Djghaq0m.mjs";
|
|
5
4
|
import { deepStrictEqual, ok, rejects } from "node:assert";
|
|
6
5
|
import { test } from "node:test";
|
|
7
6
|
import { getLogger } from "@logtape/logtape";
|
|
8
7
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
|
-
|
|
10
|
-
//#region rolldown:runtime
|
|
8
|
+
//#region \0rolldown/runtime.js
|
|
11
9
|
var __create = Object.create;
|
|
12
10
|
var __defProp = Object.defineProperty;
|
|
13
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
14
12
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
15
13
|
var __getProtoOf = Object.getPrototypeOf;
|
|
16
14
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
-
var
|
|
18
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
|
-
};
|
|
15
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
20
16
|
var __copyProps = (to, from, except, desc) => {
|
|
21
17
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
22
18
|
key = keys[i];
|
|
@@ -31,13 +27,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
27
|
value: mod,
|
|
32
28
|
enumerable: true
|
|
33
29
|
}) : target, mod));
|
|
34
|
-
|
|
35
30
|
//#endregion
|
|
36
|
-
//#region ../../node_modules/.pnpm/
|
|
37
|
-
var
|
|
38
|
-
module.exports = function(glob
|
|
39
|
-
if (typeof glob
|
|
40
|
-
var str = String(glob
|
|
31
|
+
//#region ../../node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.mjs
|
|
32
|
+
var import_glob_to_regexp = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
33
|
+
module.exports = function(glob, opts) {
|
|
34
|
+
if (typeof glob !== "string") throw new TypeError("Expected a string");
|
|
35
|
+
var str = String(glob);
|
|
41
36
|
var reStr = "";
|
|
42
37
|
var extended = opts ? !!opts.extended : false;
|
|
43
38
|
var globstar = opts ? !!opts.globstar : false;
|
|
@@ -94,13 +89,10 @@ var require_glob_to_regexp = __commonJS({ "../../node_modules/.pnpm/glob-to-rege
|
|
|
94
89
|
}
|
|
95
90
|
var nextChar = str[i + 1];
|
|
96
91
|
if (!globstar) reStr += ".*";
|
|
97
|
-
else {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
i++;
|
|
102
|
-
} else reStr += "([^/]*)";
|
|
103
|
-
}
|
|
92
|
+
else if (starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0)) {
|
|
93
|
+
reStr += "((?:[^/]*(?:/|$))*)";
|
|
94
|
+
i++;
|
|
95
|
+
} else reStr += "([^/]*)";
|
|
104
96
|
break;
|
|
105
97
|
default: reStr += c;
|
|
106
98
|
}
|
|
@@ -108,10 +100,7 @@ var require_glob_to_regexp = __commonJS({ "../../node_modules/.pnpm/glob-to-rege
|
|
|
108
100
|
if (!flags || !~flags.indexOf("g")) reStr = "^" + reStr + "$";
|
|
109
101
|
return new RegExp(reStr, flags);
|
|
110
102
|
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
//#endregion
|
|
114
|
-
//#region ../../node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.mjs
|
|
103
|
+
})))(), 1);
|
|
115
104
|
/**
|
|
116
105
|
* @param {string|RegExp} input The route pattern
|
|
117
106
|
* @param {boolean} [loose] Allow open-ended matching. Ignored with `RegExp` input.
|
|
@@ -141,7 +130,6 @@ function parse(input, loose) {
|
|
|
141
130
|
pattern: new RegExp("^" + pattern + (loose ? "(?=$|/)" : "/?$"), "i")
|
|
142
131
|
};
|
|
143
132
|
}
|
|
144
|
-
|
|
145
133
|
//#endregion
|
|
146
134
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/TypeDescriptor.js
|
|
147
135
|
const valueTypes = new Set([
|
|
@@ -233,7 +221,6 @@ var TypeDescriptor = class TypeDescriptor {
|
|
|
233
221
|
return TypeDescriptor.of(value) === "undefined";
|
|
234
222
|
}
|
|
235
223
|
};
|
|
236
|
-
|
|
237
224
|
//#endregion
|
|
238
225
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/IsSubsetOf.js
|
|
239
226
|
const allowedTypes = new Set([
|
|
@@ -260,7 +247,7 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
260
247
|
switch (subsetItemType) {
|
|
261
248
|
case "array":
|
|
262
249
|
case "object":
|
|
263
|
-
case "function":
|
|
250
|
+
case "function":
|
|
264
251
|
if (visited.includes(subsetItem)) continue;
|
|
265
252
|
visited.push(subsetItem);
|
|
266
253
|
isItemInSuperset = superset.some((supersetItem) => {
|
|
@@ -271,7 +258,6 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
271
258
|
}
|
|
272
259
|
});
|
|
273
260
|
break;
|
|
274
|
-
}
|
|
275
261
|
default: isItemInSuperset = superset.includes(subsetItem);
|
|
276
262
|
}
|
|
277
263
|
if (!isItemInSuperset) return false;
|
|
@@ -283,21 +269,18 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
283
269
|
if (Object.keys(subset).length > Object.keys(superset).length) return false;
|
|
284
270
|
for (const [subsetKey, subsetValue] of Object.entries(subset)) {
|
|
285
271
|
const supersetValue = superset[subsetKey];
|
|
286
|
-
|
|
287
|
-
switch (subsetValueType) {
|
|
272
|
+
switch (TypeDescriptor.of(subsetValue)) {
|
|
288
273
|
case "array":
|
|
289
274
|
case "object":
|
|
290
|
-
case "function":
|
|
275
|
+
case "function":
|
|
291
276
|
if (visited.includes(subsetValue)) continue;
|
|
292
277
|
visited.push(subsetValue);
|
|
293
278
|
try {
|
|
294
|
-
|
|
295
|
-
if (!isInSuperset) return false;
|
|
279
|
+
if (!isSubsetOf(subsetValue, supersetValue, visited)) return false;
|
|
296
280
|
} catch {
|
|
297
281
|
return false;
|
|
298
282
|
}
|
|
299
283
|
break;
|
|
300
|
-
}
|
|
301
284
|
default: if (subsetValue !== supersetValue) return false;
|
|
302
285
|
}
|
|
303
286
|
}
|
|
@@ -320,8 +303,7 @@ isSubsetOf.structural = function(subset, superset, visited = []) {
|
|
|
320
303
|
if (visited.includes(subsetValue)) continue;
|
|
321
304
|
visited.push(subsetValue);
|
|
322
305
|
try {
|
|
323
|
-
|
|
324
|
-
if (!isInSuperset) return false;
|
|
306
|
+
if (!isSubsetOf.structural(subsetValue, supersetValue, visited)) return false;
|
|
325
307
|
} catch {
|
|
326
308
|
return false;
|
|
327
309
|
}
|
|
@@ -329,7 +311,6 @@ isSubsetOf.structural = function(subset, superset, visited = []) {
|
|
|
329
311
|
}
|
|
330
312
|
return true;
|
|
331
313
|
};
|
|
332
|
-
|
|
333
314
|
//#endregion
|
|
334
315
|
//#region ../../node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.mjs
|
|
335
316
|
var has = Object.prototype.hasOwnProperty;
|
|
@@ -392,11 +373,10 @@ function dequal(foo, bar) {
|
|
|
392
373
|
}
|
|
393
374
|
return foo !== foo && bar !== bar;
|
|
394
375
|
}
|
|
395
|
-
|
|
396
376
|
//#endregion
|
|
397
377
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/RequestUtils.js
|
|
398
|
-
const absoluteUrlRX = new RegExp("^[a-z]+://|^data:", "i");
|
|
399
|
-
const protocolRelativeUrlRX = new RegExp("^//", "i");
|
|
378
|
+
const absoluteUrlRX = /* @__PURE__ */ new RegExp("^[a-z]+://|^data:", "i");
|
|
379
|
+
const protocolRelativeUrlRX = /* @__PURE__ */ new RegExp("^//", "i");
|
|
400
380
|
function hasCredentialsInUrl(url) {
|
|
401
381
|
const urlObject = new URL(url, !absoluteUrlRX.test(url) ? "http://dummy" : void 0);
|
|
402
382
|
return Boolean(urlObject.username || urlObject.password);
|
|
@@ -444,7 +424,7 @@ async function createCallLogFromRequest(request, options) {
|
|
|
444
424
|
} catch {}
|
|
445
425
|
if (request.headers) derivedOptions.headers = normalizeHeaders(request.headers);
|
|
446
426
|
const url = normalizeUrl(request.url, true);
|
|
447
|
-
|
|
427
|
+
return {
|
|
448
428
|
args: [request, options],
|
|
449
429
|
url,
|
|
450
430
|
queryParams: new URLSearchParams(getQuery(url)),
|
|
@@ -453,11 +433,9 @@ async function createCallLogFromRequest(request, options) {
|
|
|
453
433
|
signal: options && options.signal || request.signal,
|
|
454
434
|
pendingPromises
|
|
455
435
|
};
|
|
456
|
-
return callLog;
|
|
457
436
|
}
|
|
458
437
|
function getPath(url) {
|
|
459
|
-
|
|
460
|
-
return u.pathname;
|
|
438
|
+
return (absoluteUrlRX.test(url) ? new URL(url) : new URL(url, "http://dummy")).pathname;
|
|
461
439
|
}
|
|
462
440
|
function getHost(url) {
|
|
463
441
|
if (absoluteUrlRX.test(url)) return new URL(url).host;
|
|
@@ -475,10 +453,8 @@ function normalizeHeaders(headers) {
|
|
|
475
453
|
else entries = Object.entries(headers);
|
|
476
454
|
return Object.fromEntries(entries.map(([key, val]) => [key.toLowerCase(), String(val).valueOf()]));
|
|
477
455
|
}
|
|
478
|
-
|
|
479
456
|
//#endregion
|
|
480
457
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Matchers.js
|
|
481
|
-
var import_glob_to_regexp = __toESM(require_glob_to_regexp(), 1);
|
|
482
458
|
const isUrlMatcher = (matcher) => matcher instanceof RegExp || typeof matcher === "string" || typeof matcher === "object" && "href" in matcher;
|
|
483
459
|
const isFunctionMatcher = (matcher) => typeof matcher === "function";
|
|
484
460
|
const stringMatchers = {
|
|
@@ -532,8 +508,7 @@ const getMissingHeaderMatcher = ({ missingHeaders: expectedMissingHeaders }) =>
|
|
|
532
508
|
const getMethodMatcher = ({ method: expectedMethod }) => {
|
|
533
509
|
if (!expectedMethod) return;
|
|
534
510
|
return ({ options: { method } = {} }) => {
|
|
535
|
-
|
|
536
|
-
return expectedMethod === actualMethod;
|
|
511
|
+
return expectedMethod === (method ? method.toLowerCase() : "get");
|
|
537
512
|
};
|
|
538
513
|
};
|
|
539
514
|
const getQueryParamsMatcher = ({ query: passedQuery }) => {
|
|
@@ -612,7 +587,7 @@ const getUrlMatcher = (route) => {
|
|
|
612
587
|
}
|
|
613
588
|
if (typeof matcherUrl === "string") {
|
|
614
589
|
for (const shorthand in stringMatchers) if (matcherUrl.indexOf(`${shorthand}:`) === 0) {
|
|
615
|
-
const urlFragment = matcherUrl.replace(
|
|
590
|
+
const urlFragment = matcherUrl.replace(new RegExp(`^${shorthand}:`), "");
|
|
616
591
|
return stringMatchers[shorthand](urlFragment);
|
|
617
592
|
}
|
|
618
593
|
return getFullUrlMatcher(route, matcherUrl, query);
|
|
@@ -623,7 +598,7 @@ const getUrlMatcher = (route) => {
|
|
|
623
598
|
else if (key in stringMatchers) return stringMatchers[key](pattern);
|
|
624
599
|
else throw new Error(`unrecognised url matching pattern: ${key}`);
|
|
625
600
|
});
|
|
626
|
-
return (route
|
|
601
|
+
return (route) => matchers.every((matcher) => matcher(route));
|
|
627
602
|
}
|
|
628
603
|
};
|
|
629
604
|
const builtInMatchers = [
|
|
@@ -661,7 +636,6 @@ const builtInMatchers = [
|
|
|
661
636
|
matcher: getFunctionMatcher
|
|
662
637
|
}
|
|
663
638
|
];
|
|
664
|
-
|
|
665
639
|
//#endregion
|
|
666
640
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/StatusTextMap.js
|
|
667
641
|
const statusTextMap = {
|
|
@@ -728,17 +702,15 @@ const statusTextMap = {
|
|
|
728
702
|
510: "Not Extended",
|
|
729
703
|
511: "Network Authentication Required"
|
|
730
704
|
};
|
|
731
|
-
var StatusTextMap_default = statusTextMap;
|
|
732
|
-
|
|
733
705
|
//#endregion
|
|
734
706
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Route.js
|
|
735
|
-
var __classPrivateFieldSet =
|
|
707
|
+
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
736
708
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
737
709
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
738
710
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
739
711
|
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
740
712
|
};
|
|
741
|
-
var __classPrivateFieldGet =
|
|
713
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
742
714
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
743
715
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
744
716
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -799,14 +771,13 @@ var Route = class {
|
|
|
799
771
|
constructResponseOptions(responseInput) {
|
|
800
772
|
const options = responseInput.options || {};
|
|
801
773
|
options.status = sanitizeStatus(responseInput.status);
|
|
802
|
-
options.statusText =
|
|
774
|
+
options.statusText = statusTextMap[options.status];
|
|
803
775
|
options.headers = new this.config.Headers(responseInput.headers);
|
|
804
776
|
return options;
|
|
805
777
|
}
|
|
806
778
|
constructResponseBody(responseInput, responseOptions) {
|
|
807
779
|
let body = responseInput.body;
|
|
808
|
-
|
|
809
|
-
if (!bodyIsBodyInit) if (typeof body === "undefined") body = null;
|
|
780
|
+
if (!isBodyInit(body)) if (typeof body === "undefined") body = null;
|
|
810
781
|
else if (typeof body === "object") {
|
|
811
782
|
body = JSON.stringify(body);
|
|
812
783
|
if (!responseOptions.headers.has("Content-Type")) responseOptions.headers.set("Content-Type", "application/json");
|
|
@@ -825,26 +796,25 @@ var Route = class {
|
|
|
825
796
|
_a.registeredMatchers.push(matcher);
|
|
826
797
|
}
|
|
827
798
|
};
|
|
828
|
-
_a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route_instances = /* @__PURE__ */ new WeakSet(), _Route_validate = function _Route_validate
|
|
799
|
+
_a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route_instances = /* @__PURE__ */ new WeakSet(), _Route_validate = function _Route_validate() {
|
|
829
800
|
if (["matched", "unmatched"].includes(this.config.name)) throw new Error(`fetch-mock: Routes cannot use the reserved name \`${this.config.name}\``);
|
|
830
801
|
if (!("response" in this.config)) throw new Error("fetch-mock: Each route must define a response");
|
|
831
802
|
if (!_a.registeredMatchers.some(({ name }) => name in this.config)) throw new Error("fetch-mock: Each route must specify some criteria for matching calls to fetch. To match all calls use '*'");
|
|
832
|
-
}, _Route_sanitize = function _Route_sanitize
|
|
803
|
+
}, _Route_sanitize = function _Route_sanitize() {
|
|
833
804
|
if (this.config.method) this.config.method = this.config.method.toLowerCase();
|
|
834
|
-
}, _Route_generateMatcher = function _Route_generateMatcher
|
|
805
|
+
}, _Route_generateMatcher = function _Route_generateMatcher() {
|
|
835
806
|
const activeMatchers = _a.registeredMatchers.filter(({ name }) => name in this.config).map(({ matcher, usesBody }) => ({
|
|
836
807
|
matcher: matcher(this.config),
|
|
837
808
|
usesBody
|
|
838
809
|
}));
|
|
839
810
|
this.config.usesBody = activeMatchers.some(({ usesBody }) => usesBody);
|
|
840
811
|
this.matcher = (normalizedRequest) => activeMatchers.every(({ matcher }) => matcher(normalizedRequest));
|
|
841
|
-
}, _Route_limit = function _Route_limit
|
|
812
|
+
}, _Route_limit = function _Route_limit() {
|
|
842
813
|
if (!this.config.repeat) return;
|
|
843
814
|
const originalMatcher = this.matcher;
|
|
844
815
|
let timesLeft = this.config.repeat;
|
|
845
816
|
this.matcher = (callLog) => {
|
|
846
|
-
|
|
847
|
-
if (match) {
|
|
817
|
+
if (timesLeft && originalMatcher(callLog)) {
|
|
848
818
|
timesLeft--;
|
|
849
819
|
return true;
|
|
850
820
|
}
|
|
@@ -852,7 +822,7 @@ _a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route
|
|
|
852
822
|
this.reset = () => {
|
|
853
823
|
timesLeft = this.config.repeat;
|
|
854
824
|
};
|
|
855
|
-
}, _Route_delayResponse = function _Route_delayResponse
|
|
825
|
+
}, _Route_delayResponse = function _Route_delayResponse() {
|
|
856
826
|
if (this.config.delay) {
|
|
857
827
|
const { response } = this.config;
|
|
858
828
|
this.config.response = () => {
|
|
@@ -862,8 +832,6 @@ _a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route
|
|
|
862
832
|
};
|
|
863
833
|
Route.registeredMatchers = [];
|
|
864
834
|
builtInMatchers.forEach(Route.defineMatcher);
|
|
865
|
-
var Route_default = Route;
|
|
866
|
-
|
|
867
835
|
//#endregion
|
|
868
836
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Router.js
|
|
869
837
|
const responseConfigProps = [
|
|
@@ -936,8 +904,7 @@ var Router = class {
|
|
|
936
904
|
});
|
|
937
905
|
}
|
|
938
906
|
if (this.needsToReadBody(request)) options.body = await options.body;
|
|
939
|
-
const
|
|
940
|
-
const route = routesToTry.find((route$1) => route$1.matcher(callLog));
|
|
907
|
+
const route = (this.fallbackRoute ? [...this.routes, this.fallbackRoute] : this.routes).find((route) => route.matcher(callLog));
|
|
941
908
|
if (route) try {
|
|
942
909
|
callLog.route = route;
|
|
943
910
|
const { response, responseOptions, responseInput } = await this.generateResponse(callLog);
|
|
@@ -992,7 +959,7 @@ var Router = class {
|
|
|
992
959
|
else Object.assign(config, matcher);
|
|
993
960
|
if (typeof response !== "undefined") config.response = response;
|
|
994
961
|
if (nameOrOptions) Object.assign(config, typeof nameOrOptions === "string" ? nameToOptions(nameOrOptions) : nameOrOptions);
|
|
995
|
-
const route = new
|
|
962
|
+
const route = new Route({
|
|
996
963
|
...this.config,
|
|
997
964
|
...config
|
|
998
965
|
});
|
|
@@ -1011,7 +978,7 @@ var Router = class {
|
|
|
1011
978
|
}
|
|
1012
979
|
setFallback(response) {
|
|
1013
980
|
if (this.fallbackRoute) console.warn("calling fetchMock.catch() twice - are you sure you want to overwrite the previous fallback response");
|
|
1014
|
-
this.fallbackRoute = new
|
|
981
|
+
this.fallbackRoute = new Route({
|
|
1015
982
|
matcherFunction: () => true,
|
|
1016
983
|
response: response || "ok",
|
|
1017
984
|
...this.config
|
|
@@ -1043,7 +1010,6 @@ var Router = class {
|
|
|
1043
1010
|
route.init(newConfig);
|
|
1044
1011
|
}
|
|
1045
1012
|
};
|
|
1046
|
-
|
|
1047
1013
|
//#endregion
|
|
1048
1014
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/CallHistory.js
|
|
1049
1015
|
const isName = (filter) => typeof filter === "string" && /^[\da-zA-Z-]+$/.test(filter) && !["matched", "unmatched"].includes(filter);
|
|
@@ -1089,12 +1055,12 @@ var CallHistory = class {
|
|
|
1089
1055
|
...filter,
|
|
1090
1056
|
...options || {}
|
|
1091
1057
|
};
|
|
1092
|
-
const { matcher } = new
|
|
1058
|
+
const { matcher } = new Route({
|
|
1093
1059
|
response: "ok",
|
|
1094
1060
|
...options
|
|
1095
1061
|
});
|
|
1096
|
-
calls = calls.filter(({ url, options
|
|
1097
|
-
return matcher(createCallLogFromUrlAndOptions(url, options
|
|
1062
|
+
calls = calls.filter(({ url, options }) => {
|
|
1063
|
+
return matcher(createCallLogFromUrlAndOptions(url, options));
|
|
1098
1064
|
});
|
|
1099
1065
|
return calls;
|
|
1100
1066
|
}
|
|
@@ -1127,8 +1093,6 @@ var CallHistory = class {
|
|
|
1127
1093
|
}).every((isDone) => isDone);
|
|
1128
1094
|
}
|
|
1129
1095
|
};
|
|
1130
|
-
var CallHistory_default = CallHistory;
|
|
1131
|
-
|
|
1132
1096
|
//#endregion
|
|
1133
1097
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/FetchMock.js
|
|
1134
1098
|
const defaultFetchMockConfig = {
|
|
@@ -1150,7 +1114,9 @@ const defineGreedyShorthand = (shorthandOptions) => {
|
|
|
1150
1114
|
return this.route("*", response, Object.assign(options || {}, shorthandOptions));
|
|
1151
1115
|
};
|
|
1152
1116
|
};
|
|
1153
|
-
|
|
1117
|
+
//#endregion
|
|
1118
|
+
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/index.js
|
|
1119
|
+
var esm_default = new class FetchMock {
|
|
1154
1120
|
constructor(config, router) {
|
|
1155
1121
|
this.sticky = defineShorthand({ sticky: true });
|
|
1156
1122
|
this.once = defineShorthand({ repeat: 1 });
|
|
@@ -1191,7 +1157,7 @@ var FetchMock = class FetchMock {
|
|
|
1191
1157
|
routes: router ? [...router.routes] : [],
|
|
1192
1158
|
fallbackRoute: router ? router.fallbackRoute : null
|
|
1193
1159
|
});
|
|
1194
|
-
this.callHistory = new
|
|
1160
|
+
this.callHistory = new CallHistory(this.config, this.router);
|
|
1195
1161
|
this.fetchHandler = this.fetchHandler.bind(this);
|
|
1196
1162
|
Object.assign(this.fetchHandler, { fetchMock: this });
|
|
1197
1163
|
}
|
|
@@ -1216,7 +1182,7 @@ var FetchMock = class FetchMock {
|
|
|
1216
1182
|
return this;
|
|
1217
1183
|
}
|
|
1218
1184
|
defineMatcher(matcher) {
|
|
1219
|
-
|
|
1185
|
+
Route.defineMatcher(matcher);
|
|
1220
1186
|
}
|
|
1221
1187
|
removeRoutes(options) {
|
|
1222
1188
|
this.router.removeRoutes(options);
|
|
@@ -1258,14 +1224,7 @@ var FetchMock = class FetchMock {
|
|
|
1258
1224
|
this.mockGlobal();
|
|
1259
1225
|
return this.spy();
|
|
1260
1226
|
}
|
|
1261
|
-
};
|
|
1262
|
-
const fetchMock = new FetchMock({ ...defaultFetchMockConfig });
|
|
1263
|
-
var FetchMock_default = fetchMock;
|
|
1264
|
-
|
|
1265
|
-
//#endregion
|
|
1266
|
-
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/index.js
|
|
1267
|
-
var esm_default = FetchMock_default;
|
|
1268
|
-
|
|
1227
|
+
}({ ...defaultFetchMockConfig });
|
|
1269
1228
|
//#endregion
|
|
1270
1229
|
//#region src/contexts.ts
|
|
1271
1230
|
const preloadedContexts = {
|
|
@@ -5514,8 +5473,6 @@ const preloadedContexts = {
|
|
|
5514
5473
|
}
|
|
5515
5474
|
} }
|
|
5516
5475
|
};
|
|
5517
|
-
var contexts_default = preloadedContexts;
|
|
5518
|
-
|
|
5519
5476
|
//#endregion
|
|
5520
5477
|
//#region src/docloader.ts
|
|
5521
5478
|
const logger = getLogger([
|
|
@@ -5533,7 +5490,7 @@ const DEFAULT_MAX_REDIRECTION = 20;
|
|
|
5533
5490
|
* @throws {FetchError} If the response is not OK.
|
|
5534
5491
|
* @internal
|
|
5535
5492
|
*/
|
|
5536
|
-
async function getRemoteDocument(url, response, fetch
|
|
5493
|
+
async function getRemoteDocument(url, response, fetch) {
|
|
5537
5494
|
const documentUrl = response.url === "" ? url : response.url;
|
|
5538
5495
|
const docUrl = new URL(documentUrl);
|
|
5539
5496
|
if (!response.ok) {
|
|
@@ -5571,7 +5528,7 @@ async function getRemoteDocument(url, response, fetch$1) {
|
|
|
5571
5528
|
alternateUrl: altUri.href,
|
|
5572
5529
|
url: documentUrl
|
|
5573
5530
|
});
|
|
5574
|
-
return await fetch
|
|
5531
|
+
return await fetch(altUri.href);
|
|
5575
5532
|
}
|
|
5576
5533
|
}
|
|
5577
5534
|
}
|
|
@@ -5597,15 +5554,14 @@ async function getRemoteDocument(url, response, fetch$1) {
|
|
|
5597
5554
|
attrPattern.lastIndex = 0;
|
|
5598
5555
|
while ((attrMatch = attrPattern.exec(tagContent)) !== null) {
|
|
5599
5556
|
const key = attrMatch[1].toLowerCase();
|
|
5600
|
-
|
|
5601
|
-
attribs[key] = value;
|
|
5557
|
+
attribs[key] = attrMatch[2] ?? attrMatch[3] ?? attrMatch[4] ?? "";
|
|
5602
5558
|
}
|
|
5603
5559
|
if (attribs.rel === "alternate" && "type" in attribs && (attribs.type === "application/activity+json" || attribs.type === "application/ld+json" || attribs.type.startsWith("application/ld+json;")) && "href" in attribs && new URL(attribs.href, docUrl).href !== docUrl.href) {
|
|
5604
5560
|
logger.debug("Found alternate document: {alternateUrl} from {url}", {
|
|
5605
5561
|
alternateUrl: attribs.href,
|
|
5606
5562
|
url: documentUrl
|
|
5607
5563
|
});
|
|
5608
|
-
return await fetch
|
|
5564
|
+
return await fetch(new URL(attribs.href, docUrl).href);
|
|
5609
5565
|
}
|
|
5610
5566
|
}
|
|
5611
5567
|
document = JSON.parse(html);
|
|
@@ -5640,16 +5596,15 @@ async function getRemoteDocument(url, response, fetch$1) {
|
|
|
5640
5596
|
* @since 1.3.0
|
|
5641
5597
|
*/
|
|
5642
5598
|
function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAgent } = {}) {
|
|
5643
|
-
const
|
|
5644
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
5599
|
+
const tracer = trace.getTracerProvider().getTracer(name, version);
|
|
5645
5600
|
async function load(url, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
|
|
5646
5601
|
options?.signal?.throwIfAborted();
|
|
5647
5602
|
const currentUrl = new URL(url).href;
|
|
5648
|
-
if (!skipPreloadedContexts && currentUrl in
|
|
5603
|
+
if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
|
|
5649
5604
|
logger.debug("Using preloaded context: {url}.", { url: currentUrl });
|
|
5650
5605
|
return {
|
|
5651
5606
|
contextUrl: null,
|
|
5652
|
-
document:
|
|
5607
|
+
document: preloadedContexts[currentUrl],
|
|
5653
5608
|
documentUrl: currentUrl
|
|
5654
5609
|
};
|
|
5655
5610
|
}
|
|
@@ -5712,7 +5667,6 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5712
5667
|
}
|
|
5713
5668
|
return load;
|
|
5714
5669
|
}
|
|
5715
|
-
|
|
5716
5670
|
//#endregion
|
|
5717
5671
|
//#region src/docloader.test.ts
|
|
5718
5672
|
test("new FetchError()", () => {
|
|
@@ -5930,7 +5884,7 @@ test("getDocumentLoader()", async (t) => {
|
|
|
5930
5884
|
await rejects(() => fetchDocumentLoader("https://example.com/404"), FetchError, "HTTP 404: https://example.com/404");
|
|
5931
5885
|
});
|
|
5932
5886
|
await t.test("preloaded contexts", async () => {
|
|
5933
|
-
for (const [url, document] of Object.entries(
|
|
5887
|
+
for (const [url, document] of Object.entries(preloadedContexts)) deepStrictEqual(await fetchDocumentLoader(url), {
|
|
5934
5888
|
contextUrl: null,
|
|
5935
5889
|
documentUrl: url,
|
|
5936
5890
|
document
|
|
@@ -5985,10 +5939,9 @@ test("getDocumentLoader()", async (t) => {
|
|
|
5985
5939
|
let redirectAttempts = 0;
|
|
5986
5940
|
esm_default.get("begin:https://example.com/too-many-redirects/", (cl) => {
|
|
5987
5941
|
redirectAttempts++;
|
|
5988
|
-
const index = Number(cl.url.split("/").at(-1));
|
|
5989
5942
|
return {
|
|
5990
5943
|
status: 302,
|
|
5991
|
-
headers: { Location: `https://example.com/too-many-redirects/${
|
|
5944
|
+
headers: { Location: `https://example.com/too-many-redirects/${Number(cl.url.split("/").at(-1)) + 1}` }
|
|
5992
5945
|
};
|
|
5993
5946
|
});
|
|
5994
5947
|
await t.test("too many redirects", async () => {
|
|
@@ -6042,5 +5995,5 @@ test("getDocumentLoader()", async (t) => {
|
|
|
6042
5995
|
});
|
|
6043
5996
|
esm_default.hardReset();
|
|
6044
5997
|
});
|
|
6045
|
-
|
|
6046
|
-
|
|
5998
|
+
//#endregion
|
|
5999
|
+
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
const require_multicodec = require(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
require("../chunk-Do9eywBl.cjs");
|
|
2
|
+
const require_multicodec = require("../multicodec-DeYop8xg.cjs");
|
|
3
|
+
let node_assert = require("node:assert");
|
|
4
|
+
let node_test = require("node:test");
|
|
6
5
|
//#region src/internal/multicodec.test.ts
|
|
7
6
|
(0, node_test.test)("getMulticodecPrefix() decodes supported multicodec prefixes", () => {
|
|
8
7
|
(0, node_assert.deepStrictEqual)(require_multicodec.getMulticodecPrefix(Uint8Array.from([
|
|
@@ -73,5 +72,4 @@ const node_test = require_chunk.__toESM(require("node:test"));
|
|
|
73
72
|
])), /* @__PURE__ */ new TypeError("Invalid multicodec prefix."));
|
|
74
73
|
(0, node_assert.throws)(() => require_multicodec.addMulticodecPrefix(-1, Uint8Array.from([0])), /* @__PURE__ */ new TypeError("Invalid multicodec code."));
|
|
75
74
|
});
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
75
|
+
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as getMulticodecPrefix, r as removeMulticodecPrefix, t as addMulticodecPrefix } from "../multicodec-aqbZnrNi.mjs";
|
|
2
2
|
import { deepStrictEqual, throws } from "node:assert";
|
|
3
3
|
import { test } from "node:test";
|
|
4
|
-
|
|
5
4
|
//#region src/internal/multicodec.test.ts
|
|
6
5
|
test("getMulticodecPrefix() decodes supported multicodec prefixes", () => {
|
|
7
6
|
deepStrictEqual(getMulticodecPrefix(Uint8Array.from([
|
|
@@ -72,5 +71,5 @@ test("multicodec helpers reject malformed prefixes", () => {
|
|
|
72
71
|
])), /* @__PURE__ */ new TypeError("Invalid multicodec prefix."));
|
|
73
72
|
throws(() => addMulticodecPrefix(-1, Uint8Array.from([0])), /* @__PURE__ */ new TypeError("Invalid multicodec code."));
|
|
74
73
|
});
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
//#endregion
|
|
75
|
+
export {};
|