@fedify/vocab-runtime 2.2.0-dev.613 → 2.2.0-dev.628
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 +80 -170
- package/dist/mod.d.cts +1 -2
- package/dist/mod.d.ts +1 -2
- package/dist/mod.js +56 -149
- package/dist/tests/{chunk-DWy1uDak.cjs → chunk-Do9eywBl.cjs} +13 -17
- package/dist/tests/decimal.test.cjs +12 -21
- package/dist/tests/{decimal.test.js → decimal.test.mjs} +10 -18
- package/dist/tests/{docloader-DEi540Xh.js → docloader-OyxWpw3H.mjs} +35 -65
- package/dist/tests/{docloader-txRGFv1x.cjs → docloader-qks_ixwW.cjs} +51 -81
- package/dist/tests/docloader.test.cjs +53 -90
- package/dist/tests/{docloader.test.js → docloader.test.mjs} +53 -96
- 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-ByCmSI2y.js → key-BeTHFQJK.mjs} +14 -25
- package/dist/tests/{key-CCPn6TEY.cjs → key-DTTIntwb.cjs} +60 -71
- package/dist/tests/key.test.cjs +23 -45
- package/dist/tests/{key.test.js → key.test.mjs} +21 -42
- package/dist/tests/{langstr-EPh86hXK.cjs → langstr-CbAxaeEZ.cjs} +6 -8
- package/dist/tests/{langstr-BsVE3s9u.js → langstr-Di5AvKpB.mjs} +1 -2
- package/dist/tests/langstr.test.cjs +7 -8
- package/dist/tests/{langstr.test.js → langstr.test.mjs} +3 -4
- package/dist/tests/{link-DYNFAdNu.cjs → link-FguCydMA.cjs} +6 -8
- package/dist/tests/{link-C3q2TC2G.js → link-NUUWCdnK.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-B4g8pz6F.js → multibase-BgU9XRf7.mjs} +5 -12
- package/dist/tests/{multibase-o_ovPHYJ.cjs → multibase-F7LtMMsK.cjs} +43 -49
- package/dist/tests/{multicodec--6hQ74zI.cjs → multicodec-CxGVGa91.cjs} +16 -18
- package/dist/tests/{multicodec-Dq3IiOV4.js → multicodec-CyFp54fI.mjs} +1 -2
- package/dist/tests/{request-BO6hGoBJ.js → request-Cx6B4KEl.mjs} +4 -45
- package/dist/tests/{request-73FIhAHw.cjs → request-D1_g3-fs.cjs} +38 -72
- package/dist/tests/request.test.cjs +23 -24
- package/dist/tests/request.test.mjs +42 -0
- package/dist/tests/{url-CWEP9Zs9.js → url-BQ_kgmCk.mjs} +3 -7
- package/dist/tests/{url-DIjOdK8Q.cjs → url-pFuSds44.cjs} +31 -35
- 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/{decimal.test.d.ts → decimal.test.d.mts} +0 -0
- /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,16 +1,14 @@
|
|
|
1
|
-
const require_chunk = require(
|
|
2
|
-
const require_docloader = require(
|
|
3
|
-
const require_request = require(
|
|
4
|
-
require(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const node_test = require_chunk.__toESM(require("node:test"));
|
|
8
|
-
|
|
1
|
+
const require_chunk = require("./chunk-Do9eywBl.cjs");
|
|
2
|
+
const require_docloader = require("./docloader-qks_ixwW.cjs");
|
|
3
|
+
const require_request = require("./request-D1_g3-fs.cjs");
|
|
4
|
+
const require_url = require("./url-pFuSds44.cjs");
|
|
5
|
+
let node_assert = require("node:assert");
|
|
6
|
+
let node_test = require("node:test");
|
|
9
7
|
//#region ../../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js
|
|
10
|
-
var require_glob_to_regexp =
|
|
11
|
-
module.exports = function(glob
|
|
12
|
-
if (typeof glob
|
|
13
|
-
var str = String(glob
|
|
8
|
+
var require_glob_to_regexp = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
|
|
9
|
+
module.exports = function(glob, opts) {
|
|
10
|
+
if (typeof glob !== "string") throw new TypeError("Expected a string");
|
|
11
|
+
var str = String(glob);
|
|
14
12
|
var reStr = "";
|
|
15
13
|
var extended = opts ? !!opts.extended : false;
|
|
16
14
|
var globstar = opts ? !!opts.globstar : false;
|
|
@@ -67,13 +65,10 @@ var require_glob_to_regexp = require_chunk.__commonJS({ "../../node_modules/.pnp
|
|
|
67
65
|
}
|
|
68
66
|
var nextChar = str[i + 1];
|
|
69
67
|
if (!globstar) reStr += ".*";
|
|
70
|
-
else {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
i++;
|
|
75
|
-
} else reStr += "([^/]*)";
|
|
76
|
-
}
|
|
68
|
+
else if (starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0)) {
|
|
69
|
+
reStr += "((?:[^/]*(?:/|$))*)";
|
|
70
|
+
i++;
|
|
71
|
+
} else reStr += "([^/]*)";
|
|
77
72
|
break;
|
|
78
73
|
default: reStr += c;
|
|
79
74
|
}
|
|
@@ -81,10 +76,10 @@ var require_glob_to_regexp = require_chunk.__commonJS({ "../../node_modules/.pnp
|
|
|
81
76
|
if (!flags || !~flags.indexOf("g")) reStr = "^" + reStr + "$";
|
|
82
77
|
return new RegExp(reStr, flags);
|
|
83
78
|
};
|
|
84
|
-
}
|
|
85
|
-
|
|
79
|
+
}));
|
|
86
80
|
//#endregion
|
|
87
81
|
//#region ../../node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.mjs
|
|
82
|
+
var import_glob_to_regexp = /* @__PURE__ */ require_chunk.__toESM(require_glob_to_regexp(), 1);
|
|
88
83
|
/**
|
|
89
84
|
* @param {string|RegExp} input The route pattern
|
|
90
85
|
* @param {boolean} [loose] Allow open-ended matching. Ignored with `RegExp` input.
|
|
@@ -114,7 +109,6 @@ function parse(input, loose) {
|
|
|
114
109
|
pattern: new RegExp("^" + pattern + (loose ? "(?=$|/)" : "/?$"), "i")
|
|
115
110
|
};
|
|
116
111
|
}
|
|
117
|
-
|
|
118
112
|
//#endregion
|
|
119
113
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/TypeDescriptor.js
|
|
120
114
|
const valueTypes = new Set([
|
|
@@ -206,7 +200,6 @@ var TypeDescriptor = class TypeDescriptor {
|
|
|
206
200
|
return TypeDescriptor.of(value) === "undefined";
|
|
207
201
|
}
|
|
208
202
|
};
|
|
209
|
-
|
|
210
203
|
//#endregion
|
|
211
204
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/IsSubsetOf.js
|
|
212
205
|
const allowedTypes = new Set([
|
|
@@ -233,7 +226,7 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
233
226
|
switch (subsetItemType) {
|
|
234
227
|
case "array":
|
|
235
228
|
case "object":
|
|
236
|
-
case "function":
|
|
229
|
+
case "function":
|
|
237
230
|
if (visited.includes(subsetItem)) continue;
|
|
238
231
|
visited.push(subsetItem);
|
|
239
232
|
isItemInSuperset = superset.some((supersetItem) => {
|
|
@@ -244,7 +237,6 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
244
237
|
}
|
|
245
238
|
});
|
|
246
239
|
break;
|
|
247
|
-
}
|
|
248
240
|
default: isItemInSuperset = superset.includes(subsetItem);
|
|
249
241
|
}
|
|
250
242
|
if (!isItemInSuperset) return false;
|
|
@@ -256,21 +248,18 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
256
248
|
if (Object.keys(subset).length > Object.keys(superset).length) return false;
|
|
257
249
|
for (const [subsetKey, subsetValue] of Object.entries(subset)) {
|
|
258
250
|
const supersetValue = superset[subsetKey];
|
|
259
|
-
|
|
260
|
-
switch (subsetValueType) {
|
|
251
|
+
switch (TypeDescriptor.of(subsetValue)) {
|
|
261
252
|
case "array":
|
|
262
253
|
case "object":
|
|
263
|
-
case "function":
|
|
254
|
+
case "function":
|
|
264
255
|
if (visited.includes(subsetValue)) continue;
|
|
265
256
|
visited.push(subsetValue);
|
|
266
257
|
try {
|
|
267
|
-
|
|
268
|
-
if (!isInSuperset) return false;
|
|
258
|
+
if (!isSubsetOf(subsetValue, supersetValue, visited)) return false;
|
|
269
259
|
} catch {
|
|
270
260
|
return false;
|
|
271
261
|
}
|
|
272
262
|
break;
|
|
273
|
-
}
|
|
274
263
|
default: if (subsetValue !== supersetValue) return false;
|
|
275
264
|
}
|
|
276
265
|
}
|
|
@@ -293,8 +282,7 @@ isSubsetOf.structural = function(subset, superset, visited = []) {
|
|
|
293
282
|
if (visited.includes(subsetValue)) continue;
|
|
294
283
|
visited.push(subsetValue);
|
|
295
284
|
try {
|
|
296
|
-
|
|
297
|
-
if (!isInSuperset) return false;
|
|
285
|
+
if (!isSubsetOf.structural(subsetValue, supersetValue, visited)) return false;
|
|
298
286
|
} catch {
|
|
299
287
|
return false;
|
|
300
288
|
}
|
|
@@ -302,7 +290,6 @@ isSubsetOf.structural = function(subset, superset, visited = []) {
|
|
|
302
290
|
}
|
|
303
291
|
return true;
|
|
304
292
|
};
|
|
305
|
-
|
|
306
293
|
//#endregion
|
|
307
294
|
//#region ../../node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.mjs
|
|
308
295
|
var has = Object.prototype.hasOwnProperty;
|
|
@@ -365,11 +352,10 @@ function dequal(foo, bar) {
|
|
|
365
352
|
}
|
|
366
353
|
return foo !== foo && bar !== bar;
|
|
367
354
|
}
|
|
368
|
-
|
|
369
355
|
//#endregion
|
|
370
356
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/RequestUtils.js
|
|
371
|
-
const absoluteUrlRX = new RegExp("^[a-z]+://|^data:", "i");
|
|
372
|
-
const protocolRelativeUrlRX = new RegExp("^//", "i");
|
|
357
|
+
const absoluteUrlRX = /* @__PURE__ */ new RegExp("^[a-z]+://|^data:", "i");
|
|
358
|
+
const protocolRelativeUrlRX = /* @__PURE__ */ new RegExp("^//", "i");
|
|
373
359
|
function hasCredentialsInUrl(url) {
|
|
374
360
|
const urlObject = new URL(url, !absoluteUrlRX.test(url) ? "http://dummy" : void 0);
|
|
375
361
|
return Boolean(urlObject.username || urlObject.password);
|
|
@@ -417,7 +403,7 @@ async function createCallLogFromRequest(request, options) {
|
|
|
417
403
|
} catch {}
|
|
418
404
|
if (request.headers) derivedOptions.headers = normalizeHeaders(request.headers);
|
|
419
405
|
const url = normalizeUrl(request.url, true);
|
|
420
|
-
|
|
406
|
+
return {
|
|
421
407
|
args: [request, options],
|
|
422
408
|
url,
|
|
423
409
|
queryParams: new URLSearchParams(getQuery(url)),
|
|
@@ -426,11 +412,9 @@ async function createCallLogFromRequest(request, options) {
|
|
|
426
412
|
signal: options && options.signal || request.signal,
|
|
427
413
|
pendingPromises
|
|
428
414
|
};
|
|
429
|
-
return callLog;
|
|
430
415
|
}
|
|
431
416
|
function getPath(url) {
|
|
432
|
-
|
|
433
|
-
return u.pathname;
|
|
417
|
+
return (absoluteUrlRX.test(url) ? new URL(url) : new URL(url, "http://dummy")).pathname;
|
|
434
418
|
}
|
|
435
419
|
function getHost(url) {
|
|
436
420
|
if (absoluteUrlRX.test(url)) return new URL(url).host;
|
|
@@ -448,10 +432,8 @@ function normalizeHeaders(headers) {
|
|
|
448
432
|
else entries = Object.entries(headers);
|
|
449
433
|
return Object.fromEntries(entries.map(([key, val]) => [key.toLowerCase(), String(val).valueOf()]));
|
|
450
434
|
}
|
|
451
|
-
|
|
452
435
|
//#endregion
|
|
453
436
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Matchers.js
|
|
454
|
-
var import_glob_to_regexp = require_chunk.__toESM(require_glob_to_regexp(), 1);
|
|
455
437
|
const isUrlMatcher = (matcher) => matcher instanceof RegExp || typeof matcher === "string" || typeof matcher === "object" && "href" in matcher;
|
|
456
438
|
const isFunctionMatcher = (matcher) => typeof matcher === "function";
|
|
457
439
|
const stringMatchers = {
|
|
@@ -505,8 +487,7 @@ const getMissingHeaderMatcher = ({ missingHeaders: expectedMissingHeaders }) =>
|
|
|
505
487
|
const getMethodMatcher = ({ method: expectedMethod }) => {
|
|
506
488
|
if (!expectedMethod) return;
|
|
507
489
|
return ({ options: { method } = {} }) => {
|
|
508
|
-
|
|
509
|
-
return expectedMethod === actualMethod;
|
|
490
|
+
return expectedMethod === (method ? method.toLowerCase() : "get");
|
|
510
491
|
};
|
|
511
492
|
};
|
|
512
493
|
const getQueryParamsMatcher = ({ query: passedQuery }) => {
|
|
@@ -585,7 +566,7 @@ const getUrlMatcher = (route) => {
|
|
|
585
566
|
}
|
|
586
567
|
if (typeof matcherUrl === "string") {
|
|
587
568
|
for (const shorthand in stringMatchers) if (matcherUrl.indexOf(`${shorthand}:`) === 0) {
|
|
588
|
-
const urlFragment = matcherUrl.replace(
|
|
569
|
+
const urlFragment = matcherUrl.replace(new RegExp(`^${shorthand}:`), "");
|
|
589
570
|
return stringMatchers[shorthand](urlFragment);
|
|
590
571
|
}
|
|
591
572
|
return getFullUrlMatcher(route, matcherUrl, query);
|
|
@@ -596,7 +577,7 @@ const getUrlMatcher = (route) => {
|
|
|
596
577
|
else if (key in stringMatchers) return stringMatchers[key](pattern);
|
|
597
578
|
else throw new Error(`unrecognised url matching pattern: ${key}`);
|
|
598
579
|
});
|
|
599
|
-
return (route
|
|
580
|
+
return (route) => matchers.every((matcher) => matcher(route));
|
|
600
581
|
}
|
|
601
582
|
};
|
|
602
583
|
const builtInMatchers = [
|
|
@@ -634,7 +615,6 @@ const builtInMatchers = [
|
|
|
634
615
|
matcher: getFunctionMatcher
|
|
635
616
|
}
|
|
636
617
|
];
|
|
637
|
-
|
|
638
618
|
//#endregion
|
|
639
619
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/StatusTextMap.js
|
|
640
620
|
const statusTextMap = {
|
|
@@ -701,17 +681,15 @@ const statusTextMap = {
|
|
|
701
681
|
510: "Not Extended",
|
|
702
682
|
511: "Network Authentication Required"
|
|
703
683
|
};
|
|
704
|
-
var StatusTextMap_default = statusTextMap;
|
|
705
|
-
|
|
706
684
|
//#endregion
|
|
707
685
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Route.js
|
|
708
|
-
var __classPrivateFieldSet =
|
|
686
|
+
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
709
687
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
710
688
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
711
689
|
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");
|
|
712
690
|
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
713
691
|
};
|
|
714
|
-
var __classPrivateFieldGet =
|
|
692
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
715
693
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
716
694
|
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");
|
|
717
695
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -772,14 +750,13 @@ var Route = class {
|
|
|
772
750
|
constructResponseOptions(responseInput) {
|
|
773
751
|
const options = responseInput.options || {};
|
|
774
752
|
options.status = sanitizeStatus(responseInput.status);
|
|
775
|
-
options.statusText =
|
|
753
|
+
options.statusText = statusTextMap[options.status];
|
|
776
754
|
options.headers = new this.config.Headers(responseInput.headers);
|
|
777
755
|
return options;
|
|
778
756
|
}
|
|
779
757
|
constructResponseBody(responseInput, responseOptions) {
|
|
780
758
|
let body = responseInput.body;
|
|
781
|
-
|
|
782
|
-
if (!bodyIsBodyInit) if (typeof body === "undefined") body = null;
|
|
759
|
+
if (!isBodyInit(body)) if (typeof body === "undefined") body = null;
|
|
783
760
|
else if (typeof body === "object") {
|
|
784
761
|
body = JSON.stringify(body);
|
|
785
762
|
if (!responseOptions.headers.has("Content-Type")) responseOptions.headers.set("Content-Type", "application/json");
|
|
@@ -798,26 +775,25 @@ var Route = class {
|
|
|
798
775
|
_a.registeredMatchers.push(matcher);
|
|
799
776
|
}
|
|
800
777
|
};
|
|
801
|
-
_a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route_instances = /* @__PURE__ */ new WeakSet(), _Route_validate = function _Route_validate
|
|
778
|
+
_a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route_instances = /* @__PURE__ */ new WeakSet(), _Route_validate = function _Route_validate() {
|
|
802
779
|
if (["matched", "unmatched"].includes(this.config.name)) throw new Error(`fetch-mock: Routes cannot use the reserved name \`${this.config.name}\``);
|
|
803
780
|
if (!("response" in this.config)) throw new Error("fetch-mock: Each route must define a response");
|
|
804
781
|
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 '*'");
|
|
805
|
-
}, _Route_sanitize = function _Route_sanitize
|
|
782
|
+
}, _Route_sanitize = function _Route_sanitize() {
|
|
806
783
|
if (this.config.method) this.config.method = this.config.method.toLowerCase();
|
|
807
|
-
}, _Route_generateMatcher = function _Route_generateMatcher
|
|
784
|
+
}, _Route_generateMatcher = function _Route_generateMatcher() {
|
|
808
785
|
const activeMatchers = _a.registeredMatchers.filter(({ name }) => name in this.config).map(({ matcher, usesBody }) => ({
|
|
809
786
|
matcher: matcher(this.config),
|
|
810
787
|
usesBody
|
|
811
788
|
}));
|
|
812
789
|
this.config.usesBody = activeMatchers.some(({ usesBody }) => usesBody);
|
|
813
790
|
this.matcher = (normalizedRequest) => activeMatchers.every(({ matcher }) => matcher(normalizedRequest));
|
|
814
|
-
}, _Route_limit = function _Route_limit
|
|
791
|
+
}, _Route_limit = function _Route_limit() {
|
|
815
792
|
if (!this.config.repeat) return;
|
|
816
793
|
const originalMatcher = this.matcher;
|
|
817
794
|
let timesLeft = this.config.repeat;
|
|
818
795
|
this.matcher = (callLog) => {
|
|
819
|
-
|
|
820
|
-
if (match) {
|
|
796
|
+
if (timesLeft && originalMatcher(callLog)) {
|
|
821
797
|
timesLeft--;
|
|
822
798
|
return true;
|
|
823
799
|
}
|
|
@@ -825,7 +801,7 @@ _a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route
|
|
|
825
801
|
this.reset = () => {
|
|
826
802
|
timesLeft = this.config.repeat;
|
|
827
803
|
};
|
|
828
|
-
}, _Route_delayResponse = function _Route_delayResponse
|
|
804
|
+
}, _Route_delayResponse = function _Route_delayResponse() {
|
|
829
805
|
if (this.config.delay) {
|
|
830
806
|
const { response } = this.config;
|
|
831
807
|
this.config.response = () => {
|
|
@@ -835,8 +811,6 @@ _a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route
|
|
|
835
811
|
};
|
|
836
812
|
Route.registeredMatchers = [];
|
|
837
813
|
builtInMatchers.forEach(Route.defineMatcher);
|
|
838
|
-
var Route_default = Route;
|
|
839
|
-
|
|
840
814
|
//#endregion
|
|
841
815
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Router.js
|
|
842
816
|
const responseConfigProps = [
|
|
@@ -909,8 +883,7 @@ var Router = class {
|
|
|
909
883
|
});
|
|
910
884
|
}
|
|
911
885
|
if (this.needsToReadBody(request)) options.body = await options.body;
|
|
912
|
-
const
|
|
913
|
-
const route = routesToTry.find((route$1) => route$1.matcher(callLog));
|
|
886
|
+
const route = (this.fallbackRoute ? [...this.routes, this.fallbackRoute] : this.routes).find((route) => route.matcher(callLog));
|
|
914
887
|
if (route) try {
|
|
915
888
|
callLog.route = route;
|
|
916
889
|
const { response, responseOptions, responseInput } = await this.generateResponse(callLog);
|
|
@@ -965,7 +938,7 @@ var Router = class {
|
|
|
965
938
|
else Object.assign(config, matcher);
|
|
966
939
|
if (typeof response !== "undefined") config.response = response;
|
|
967
940
|
if (nameOrOptions) Object.assign(config, typeof nameOrOptions === "string" ? nameToOptions(nameOrOptions) : nameOrOptions);
|
|
968
|
-
const route = new
|
|
941
|
+
const route = new Route({
|
|
969
942
|
...this.config,
|
|
970
943
|
...config
|
|
971
944
|
});
|
|
@@ -984,7 +957,7 @@ var Router = class {
|
|
|
984
957
|
}
|
|
985
958
|
setFallback(response) {
|
|
986
959
|
if (this.fallbackRoute) console.warn("calling fetchMock.catch() twice - are you sure you want to overwrite the previous fallback response");
|
|
987
|
-
this.fallbackRoute = new
|
|
960
|
+
this.fallbackRoute = new Route({
|
|
988
961
|
matcherFunction: () => true,
|
|
989
962
|
response: response || "ok",
|
|
990
963
|
...this.config
|
|
@@ -1016,7 +989,6 @@ var Router = class {
|
|
|
1016
989
|
route.init(newConfig);
|
|
1017
990
|
}
|
|
1018
991
|
};
|
|
1019
|
-
|
|
1020
992
|
//#endregion
|
|
1021
993
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/CallHistory.js
|
|
1022
994
|
const isName = (filter) => typeof filter === "string" && /^[\da-zA-Z-]+$/.test(filter) && !["matched", "unmatched"].includes(filter);
|
|
@@ -1062,12 +1034,12 @@ var CallHistory = class {
|
|
|
1062
1034
|
...filter,
|
|
1063
1035
|
...options || {}
|
|
1064
1036
|
};
|
|
1065
|
-
const { matcher } = new
|
|
1037
|
+
const { matcher } = new Route({
|
|
1066
1038
|
response: "ok",
|
|
1067
1039
|
...options
|
|
1068
1040
|
});
|
|
1069
|
-
calls = calls.filter(({ url, options
|
|
1070
|
-
return matcher(createCallLogFromUrlAndOptions(url, options
|
|
1041
|
+
calls = calls.filter(({ url, options }) => {
|
|
1042
|
+
return matcher(createCallLogFromUrlAndOptions(url, options));
|
|
1071
1043
|
});
|
|
1072
1044
|
return calls;
|
|
1073
1045
|
}
|
|
@@ -1100,8 +1072,6 @@ var CallHistory = class {
|
|
|
1100
1072
|
}).every((isDone) => isDone);
|
|
1101
1073
|
}
|
|
1102
1074
|
};
|
|
1103
|
-
var CallHistory_default = CallHistory;
|
|
1104
|
-
|
|
1105
1075
|
//#endregion
|
|
1106
1076
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/FetchMock.js
|
|
1107
1077
|
const defaultFetchMockConfig = {
|
|
@@ -1123,7 +1093,9 @@ const defineGreedyShorthand = (shorthandOptions) => {
|
|
|
1123
1093
|
return this.route("*", response, Object.assign(options || {}, shorthandOptions));
|
|
1124
1094
|
};
|
|
1125
1095
|
};
|
|
1126
|
-
|
|
1096
|
+
//#endregion
|
|
1097
|
+
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/index.js
|
|
1098
|
+
var esm_default = new class FetchMock {
|
|
1127
1099
|
constructor(config, router) {
|
|
1128
1100
|
this.sticky = defineShorthand({ sticky: true });
|
|
1129
1101
|
this.once = defineShorthand({ repeat: 1 });
|
|
@@ -1164,7 +1136,7 @@ var FetchMock = class FetchMock {
|
|
|
1164
1136
|
routes: router ? [...router.routes] : [],
|
|
1165
1137
|
fallbackRoute: router ? router.fallbackRoute : null
|
|
1166
1138
|
});
|
|
1167
|
-
this.callHistory = new
|
|
1139
|
+
this.callHistory = new CallHistory(this.config, this.router);
|
|
1168
1140
|
this.fetchHandler = this.fetchHandler.bind(this);
|
|
1169
1141
|
Object.assign(this.fetchHandler, { fetchMock: this });
|
|
1170
1142
|
}
|
|
@@ -1189,7 +1161,7 @@ var FetchMock = class FetchMock {
|
|
|
1189
1161
|
return this;
|
|
1190
1162
|
}
|
|
1191
1163
|
defineMatcher(matcher) {
|
|
1192
|
-
|
|
1164
|
+
Route.defineMatcher(matcher);
|
|
1193
1165
|
}
|
|
1194
1166
|
removeRoutes(options) {
|
|
1195
1167
|
this.router.removeRoutes(options);
|
|
@@ -1231,14 +1203,7 @@ var FetchMock = class FetchMock {
|
|
|
1231
1203
|
this.mockGlobal();
|
|
1232
1204
|
return this.spy();
|
|
1233
1205
|
}
|
|
1234
|
-
};
|
|
1235
|
-
const fetchMock = new FetchMock({ ...defaultFetchMockConfig });
|
|
1236
|
-
var FetchMock_default = fetchMock;
|
|
1237
|
-
|
|
1238
|
-
//#endregion
|
|
1239
|
-
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/index.js
|
|
1240
|
-
var esm_default = FetchMock_default;
|
|
1241
|
-
|
|
1206
|
+
}({ ...defaultFetchMockConfig });
|
|
1242
1207
|
//#endregion
|
|
1243
1208
|
//#region src/docloader.test.ts
|
|
1244
1209
|
(0, node_test.test)("new FetchError()", () => {
|
|
@@ -1460,7 +1425,7 @@ var esm_default = FetchMock_default;
|
|
|
1460
1425
|
await (0, node_assert.rejects)(() => fetchDocumentLoader("https://example.com/404"), require_request.FetchError, "HTTP 404: https://example.com/404");
|
|
1461
1426
|
});
|
|
1462
1427
|
await t.test("preloaded contexts", async () => {
|
|
1463
|
-
for (const [url, document] of Object.entries(require_docloader.
|
|
1428
|
+
for (const [url, document] of Object.entries(require_docloader.preloadedContexts)) (0, node_assert.deepStrictEqual)(await fetchDocumentLoader(url), {
|
|
1464
1429
|
contextUrl: null,
|
|
1465
1430
|
documentUrl: url,
|
|
1466
1431
|
document
|
|
@@ -1515,10 +1480,9 @@ var esm_default = FetchMock_default;
|
|
|
1515
1480
|
let redirectAttempts = 0;
|
|
1516
1481
|
esm_default.get("begin:https://example.com/too-many-redirects/", (cl) => {
|
|
1517
1482
|
redirectAttempts++;
|
|
1518
|
-
const index = Number(cl.url.split("/").at(-1));
|
|
1519
1483
|
return {
|
|
1520
1484
|
status: 302,
|
|
1521
|
-
headers: { Location: `https://example.com/too-many-redirects/${
|
|
1485
|
+
headers: { Location: `https://example.com/too-many-redirects/${Number(cl.url.split("/").at(-1)) + 1}` }
|
|
1522
1486
|
};
|
|
1523
1487
|
});
|
|
1524
1488
|
await t.test("too many redirects", async () => {
|
|
@@ -1578,5 +1542,4 @@ var esm_default = FetchMock_default;
|
|
|
1578
1542
|
});
|
|
1579
1543
|
esm_default.hardReset();
|
|
1580
1544
|
});
|
|
1581
|
-
|
|
1582
|
-
//#endregion
|
|
1545
|
+
//#endregion
|