@fedify/vocab 2.1.0 → 2.1.2
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/mod.cjs +3873 -5608
- package/dist/mod.d.cts +383 -384
- package/dist/mod.d.ts +383 -384
- package/dist/mod.js +1117 -2853
- package/dist-tests/{actor.test.js → actor.test.mjs} +315 -557
- package/dist-tests/{deno-zAg2jvCV.js → deno-Cb1qyeNy.mjs} +66 -145
- package/dist-tests/{lookup.test.js → lookup.test.mjs} +29 -48
- package/dist-tests/type-Cf-vxmre.mjs +9 -0
- package/dist-tests/type.test.mjs +16 -0
- package/dist-tests/{utils-BSWXlrig.js → utils-CE8Dk5hm.mjs} +3 -7
- package/dist-tests/{vocab-dV6QKnk_.js → vocab-uS-D0TBY.mjs} +1118 -2801
- package/dist-tests/{vocab.test.js → vocab.test.mjs} +100 -158
- package/package.json +6 -6
- package/dist-tests/type-CNuABalk.js +0 -13
- package/dist-tests/type.test.js +0 -24
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { __commonJS, __toESM } from "./vocab-dV6QKnk_.js";
|
|
6
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
globalThis.addEventListener = () => {};
|
|
3
|
+
import { S as __commonJSMin, w as __toESM } from "./vocab-uS-D0TBY.mjs";
|
|
7
4
|
//#region ../../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js
|
|
8
|
-
var require_glob_to_regexp =
|
|
9
|
-
module.exports = function(glob
|
|
10
|
-
if (typeof glob
|
|
11
|
-
var str = String(glob
|
|
5
|
+
var require_glob_to_regexp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6
|
+
module.exports = function(glob, opts) {
|
|
7
|
+
if (typeof glob !== "string") throw new TypeError("Expected a string");
|
|
8
|
+
var str = String(glob);
|
|
12
9
|
var reStr = "";
|
|
13
10
|
var extended = opts ? !!opts.extended : false;
|
|
14
11
|
var globstar = opts ? !!opts.globstar : false;
|
|
@@ -65,13 +62,10 @@ var require_glob_to_regexp = __commonJS({ "../../node_modules/.pnpm/glob-to-rege
|
|
|
65
62
|
}
|
|
66
63
|
var nextChar = str[i + 1];
|
|
67
64
|
if (!globstar) reStr += ".*";
|
|
68
|
-
else {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
i++;
|
|
73
|
-
} else reStr += "([^/]*)";
|
|
74
|
-
}
|
|
65
|
+
else if (starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0)) {
|
|
66
|
+
reStr += "((?:[^/]*(?:/|$))*)";
|
|
67
|
+
i++;
|
|
68
|
+
} else reStr += "([^/]*)";
|
|
75
69
|
break;
|
|
76
70
|
default: reStr += c;
|
|
77
71
|
}
|
|
@@ -79,8 +73,7 @@ var require_glob_to_regexp = __commonJS({ "../../node_modules/.pnpm/glob-to-rege
|
|
|
79
73
|
if (!flags || !~flags.indexOf("g")) reStr = "^" + reStr + "$";
|
|
80
74
|
return new RegExp(reStr, flags);
|
|
81
75
|
};
|
|
82
|
-
}
|
|
83
|
-
|
|
76
|
+
}));
|
|
84
77
|
//#endregion
|
|
85
78
|
//#region ../../node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.mjs
|
|
86
79
|
/**
|
|
@@ -112,7 +105,6 @@ function parse(input, loose) {
|
|
|
112
105
|
pattern: new RegExp("^" + pattern + (loose ? "(?=$|/)" : "/?$"), "i")
|
|
113
106
|
};
|
|
114
107
|
}
|
|
115
|
-
|
|
116
108
|
//#endregion
|
|
117
109
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/TypeDescriptor.js
|
|
118
110
|
const valueTypes = new Set([
|
|
@@ -204,7 +196,6 @@ var TypeDescriptor = class TypeDescriptor {
|
|
|
204
196
|
return TypeDescriptor.of(value) === "undefined";
|
|
205
197
|
}
|
|
206
198
|
};
|
|
207
|
-
|
|
208
199
|
//#endregion
|
|
209
200
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/IsSubsetOf.js
|
|
210
201
|
const allowedTypes = new Set([
|
|
@@ -231,7 +222,7 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
231
222
|
switch (subsetItemType) {
|
|
232
223
|
case "array":
|
|
233
224
|
case "object":
|
|
234
|
-
case "function":
|
|
225
|
+
case "function":
|
|
235
226
|
if (visited.includes(subsetItem)) continue;
|
|
236
227
|
visited.push(subsetItem);
|
|
237
228
|
isItemInSuperset = superset.some((supersetItem) => {
|
|
@@ -242,7 +233,6 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
242
233
|
}
|
|
243
234
|
});
|
|
244
235
|
break;
|
|
245
|
-
}
|
|
246
236
|
default: isItemInSuperset = superset.includes(subsetItem);
|
|
247
237
|
}
|
|
248
238
|
if (!isItemInSuperset) return false;
|
|
@@ -254,21 +244,18 @@ const isSubsetOf = function(subset, superset, visited = []) {
|
|
|
254
244
|
if (Object.keys(subset).length > Object.keys(superset).length) return false;
|
|
255
245
|
for (const [subsetKey, subsetValue] of Object.entries(subset)) {
|
|
256
246
|
const supersetValue = superset[subsetKey];
|
|
257
|
-
|
|
258
|
-
switch (subsetValueType) {
|
|
247
|
+
switch (TypeDescriptor.of(subsetValue)) {
|
|
259
248
|
case "array":
|
|
260
249
|
case "object":
|
|
261
|
-
case "function":
|
|
250
|
+
case "function":
|
|
262
251
|
if (visited.includes(subsetValue)) continue;
|
|
263
252
|
visited.push(subsetValue);
|
|
264
253
|
try {
|
|
265
|
-
|
|
266
|
-
if (!isInSuperset) return false;
|
|
254
|
+
if (!isSubsetOf(subsetValue, supersetValue, visited)) return false;
|
|
267
255
|
} catch {
|
|
268
256
|
return false;
|
|
269
257
|
}
|
|
270
258
|
break;
|
|
271
|
-
}
|
|
272
259
|
default: if (subsetValue !== supersetValue) return false;
|
|
273
260
|
}
|
|
274
261
|
}
|
|
@@ -291,8 +278,7 @@ isSubsetOf.structural = function(subset, superset, visited = []) {
|
|
|
291
278
|
if (visited.includes(subsetValue)) continue;
|
|
292
279
|
visited.push(subsetValue);
|
|
293
280
|
try {
|
|
294
|
-
|
|
295
|
-
if (!isInSuperset) return false;
|
|
281
|
+
if (!isSubsetOf.structural(subsetValue, supersetValue, visited)) return false;
|
|
296
282
|
} catch {
|
|
297
283
|
return false;
|
|
298
284
|
}
|
|
@@ -300,7 +286,6 @@ isSubsetOf.structural = function(subset, superset, visited = []) {
|
|
|
300
286
|
}
|
|
301
287
|
return true;
|
|
302
288
|
};
|
|
303
|
-
|
|
304
289
|
//#endregion
|
|
305
290
|
//#region ../../node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.mjs
|
|
306
291
|
var has = Object.prototype.hasOwnProperty;
|
|
@@ -363,11 +348,10 @@ function dequal(foo, bar) {
|
|
|
363
348
|
}
|
|
364
349
|
return foo !== foo && bar !== bar;
|
|
365
350
|
}
|
|
366
|
-
|
|
367
351
|
//#endregion
|
|
368
352
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/RequestUtils.js
|
|
369
|
-
const absoluteUrlRX = new RegExp("^[a-z]+://|^data:", "i");
|
|
370
|
-
const protocolRelativeUrlRX = new RegExp("^//", "i");
|
|
353
|
+
const absoluteUrlRX = /* @__PURE__ */ new RegExp("^[a-z]+://|^data:", "i");
|
|
354
|
+
const protocolRelativeUrlRX = /* @__PURE__ */ new RegExp("^//", "i");
|
|
371
355
|
function hasCredentialsInUrl(url) {
|
|
372
356
|
const urlObject = new URL(url, !absoluteUrlRX.test(url) ? "http://dummy" : void 0);
|
|
373
357
|
return Boolean(urlObject.username || urlObject.password);
|
|
@@ -415,7 +399,7 @@ async function createCallLogFromRequest(request, options) {
|
|
|
415
399
|
} catch {}
|
|
416
400
|
if (request.headers) derivedOptions.headers = normalizeHeaders(request.headers);
|
|
417
401
|
const url = normalizeUrl(request.url, true);
|
|
418
|
-
|
|
402
|
+
return {
|
|
419
403
|
args: [request, options],
|
|
420
404
|
url,
|
|
421
405
|
queryParams: new URLSearchParams(getQuery(url)),
|
|
@@ -424,11 +408,9 @@ async function createCallLogFromRequest(request, options) {
|
|
|
424
408
|
signal: options && options.signal || request.signal,
|
|
425
409
|
pendingPromises
|
|
426
410
|
};
|
|
427
|
-
return callLog;
|
|
428
411
|
}
|
|
429
412
|
function getPath(url) {
|
|
430
|
-
|
|
431
|
-
return u.pathname;
|
|
413
|
+
return (absoluteUrlRX.test(url) ? new URL(url) : new URL(url, "http://dummy")).pathname;
|
|
432
414
|
}
|
|
433
415
|
function getHost(url) {
|
|
434
416
|
if (absoluteUrlRX.test(url)) return new URL(url).host;
|
|
@@ -446,10 +428,9 @@ function normalizeHeaders(headers) {
|
|
|
446
428
|
else entries = Object.entries(headers);
|
|
447
429
|
return Object.fromEntries(entries.map(([key, val]) => [key.toLowerCase(), String(val).valueOf()]));
|
|
448
430
|
}
|
|
449
|
-
|
|
450
431
|
//#endregion
|
|
451
432
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Matchers.js
|
|
452
|
-
var import_glob_to_regexp = __toESM(require_glob_to_regexp(), 1);
|
|
433
|
+
var import_glob_to_regexp = /* @__PURE__ */ __toESM(require_glob_to_regexp(), 1);
|
|
453
434
|
const isUrlMatcher = (matcher) => matcher instanceof RegExp || typeof matcher === "string" || typeof matcher === "object" && "href" in matcher;
|
|
454
435
|
const isFunctionMatcher = (matcher) => typeof matcher === "function";
|
|
455
436
|
const stringMatchers = {
|
|
@@ -503,8 +484,7 @@ const getMissingHeaderMatcher = ({ missingHeaders: expectedMissingHeaders }) =>
|
|
|
503
484
|
const getMethodMatcher = ({ method: expectedMethod }) => {
|
|
504
485
|
if (!expectedMethod) return;
|
|
505
486
|
return ({ options: { method } = {} }) => {
|
|
506
|
-
|
|
507
|
-
return expectedMethod === actualMethod;
|
|
487
|
+
return expectedMethod === (method ? method.toLowerCase() : "get");
|
|
508
488
|
};
|
|
509
489
|
};
|
|
510
490
|
const getQueryParamsMatcher = ({ query: passedQuery }) => {
|
|
@@ -583,7 +563,7 @@ const getUrlMatcher = (route) => {
|
|
|
583
563
|
}
|
|
584
564
|
if (typeof matcherUrl === "string") {
|
|
585
565
|
for (const shorthand in stringMatchers) if (matcherUrl.indexOf(`${shorthand}:`) === 0) {
|
|
586
|
-
const urlFragment = matcherUrl.replace(
|
|
566
|
+
const urlFragment = matcherUrl.replace(new RegExp(`^${shorthand}:`), "");
|
|
587
567
|
return stringMatchers[shorthand](urlFragment);
|
|
588
568
|
}
|
|
589
569
|
return getFullUrlMatcher(route, matcherUrl, query);
|
|
@@ -594,7 +574,7 @@ const getUrlMatcher = (route) => {
|
|
|
594
574
|
else if (key in stringMatchers) return stringMatchers[key](pattern);
|
|
595
575
|
else throw new Error(`unrecognised url matching pattern: ${key}`);
|
|
596
576
|
});
|
|
597
|
-
return (route
|
|
577
|
+
return (route) => matchers.every((matcher) => matcher(route));
|
|
598
578
|
}
|
|
599
579
|
};
|
|
600
580
|
const builtInMatchers = [
|
|
@@ -632,7 +612,6 @@ const builtInMatchers = [
|
|
|
632
612
|
matcher: getFunctionMatcher
|
|
633
613
|
}
|
|
634
614
|
];
|
|
635
|
-
|
|
636
615
|
//#endregion
|
|
637
616
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/StatusTextMap.js
|
|
638
617
|
const statusTextMap = {
|
|
@@ -699,17 +678,15 @@ const statusTextMap = {
|
|
|
699
678
|
510: "Not Extended",
|
|
700
679
|
511: "Network Authentication Required"
|
|
701
680
|
};
|
|
702
|
-
var StatusTextMap_default = statusTextMap;
|
|
703
|
-
|
|
704
681
|
//#endregion
|
|
705
682
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Route.js
|
|
706
|
-
var __classPrivateFieldSet =
|
|
683
|
+
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
707
684
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
708
685
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
709
686
|
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");
|
|
710
687
|
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
711
688
|
};
|
|
712
|
-
var __classPrivateFieldGet =
|
|
689
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
713
690
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
714
691
|
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");
|
|
715
692
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -770,14 +747,13 @@ var Route = class {
|
|
|
770
747
|
constructResponseOptions(responseInput) {
|
|
771
748
|
const options = responseInput.options || {};
|
|
772
749
|
options.status = sanitizeStatus(responseInput.status);
|
|
773
|
-
options.statusText =
|
|
750
|
+
options.statusText = statusTextMap[options.status];
|
|
774
751
|
options.headers = new this.config.Headers(responseInput.headers);
|
|
775
752
|
return options;
|
|
776
753
|
}
|
|
777
754
|
constructResponseBody(responseInput, responseOptions) {
|
|
778
755
|
let body = responseInput.body;
|
|
779
|
-
|
|
780
|
-
if (!bodyIsBodyInit) if (typeof body === "undefined") body = null;
|
|
756
|
+
if (!isBodyInit(body)) if (typeof body === "undefined") body = null;
|
|
781
757
|
else if (typeof body === "object") {
|
|
782
758
|
body = JSON.stringify(body);
|
|
783
759
|
if (!responseOptions.headers.has("Content-Type")) responseOptions.headers.set("Content-Type", "application/json");
|
|
@@ -796,26 +772,25 @@ var Route = class {
|
|
|
796
772
|
_a.registeredMatchers.push(matcher);
|
|
797
773
|
}
|
|
798
774
|
};
|
|
799
|
-
_a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route_instances = /* @__PURE__ */ new WeakSet(), _Route_validate = function _Route_validate
|
|
775
|
+
_a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route_instances = /* @__PURE__ */ new WeakSet(), _Route_validate = function _Route_validate() {
|
|
800
776
|
if (["matched", "unmatched"].includes(this.config.name)) throw new Error(`fetch-mock: Routes cannot use the reserved name \`${this.config.name}\``);
|
|
801
777
|
if (!("response" in this.config)) throw new Error("fetch-mock: Each route must define a response");
|
|
802
|
-
if (!_a.registeredMatchers.some(({ name
|
|
803
|
-
}, _Route_sanitize = function _Route_sanitize
|
|
778
|
+
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 '*'");
|
|
779
|
+
}, _Route_sanitize = function _Route_sanitize() {
|
|
804
780
|
if (this.config.method) this.config.method = this.config.method.toLowerCase();
|
|
805
|
-
}, _Route_generateMatcher = function _Route_generateMatcher
|
|
806
|
-
const activeMatchers = _a.registeredMatchers.filter(({ name
|
|
781
|
+
}, _Route_generateMatcher = function _Route_generateMatcher() {
|
|
782
|
+
const activeMatchers = _a.registeredMatchers.filter(({ name }) => name in this.config).map(({ matcher, usesBody }) => ({
|
|
807
783
|
matcher: matcher(this.config),
|
|
808
784
|
usesBody
|
|
809
785
|
}));
|
|
810
786
|
this.config.usesBody = activeMatchers.some(({ usesBody }) => usesBody);
|
|
811
787
|
this.matcher = (normalizedRequest) => activeMatchers.every(({ matcher }) => matcher(normalizedRequest));
|
|
812
|
-
}, _Route_limit = function _Route_limit
|
|
788
|
+
}, _Route_limit = function _Route_limit() {
|
|
813
789
|
if (!this.config.repeat) return;
|
|
814
790
|
const originalMatcher = this.matcher;
|
|
815
791
|
let timesLeft = this.config.repeat;
|
|
816
792
|
this.matcher = (callLog) => {
|
|
817
|
-
|
|
818
|
-
if (match) {
|
|
793
|
+
if (timesLeft && originalMatcher(callLog)) {
|
|
819
794
|
timesLeft--;
|
|
820
795
|
return true;
|
|
821
796
|
}
|
|
@@ -823,7 +798,7 @@ _a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route
|
|
|
823
798
|
this.reset = () => {
|
|
824
799
|
timesLeft = this.config.repeat;
|
|
825
800
|
};
|
|
826
|
-
}, _Route_delayResponse = function _Route_delayResponse
|
|
801
|
+
}, _Route_delayResponse = function _Route_delayResponse() {
|
|
827
802
|
if (this.config.delay) {
|
|
828
803
|
const { response } = this.config;
|
|
829
804
|
this.config.response = () => {
|
|
@@ -833,8 +808,6 @@ _a = Route, _Route_responseSubscriptions = /* @__PURE__ */ new WeakMap(), _Route
|
|
|
833
808
|
};
|
|
834
809
|
Route.registeredMatchers = [];
|
|
835
810
|
builtInMatchers.forEach(Route.defineMatcher);
|
|
836
|
-
var Route_default = Route;
|
|
837
|
-
|
|
838
811
|
//#endregion
|
|
839
812
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/Router.js
|
|
840
813
|
const responseConfigProps = [
|
|
@@ -907,8 +880,7 @@ var Router = class {
|
|
|
907
880
|
});
|
|
908
881
|
}
|
|
909
882
|
if (this.needsToReadBody(request)) options.body = await options.body;
|
|
910
|
-
const
|
|
911
|
-
const route = routesToTry.find((route$1) => route$1.matcher(callLog));
|
|
883
|
+
const route = (this.fallbackRoute ? [...this.routes, this.fallbackRoute] : this.routes).find((route) => route.matcher(callLog));
|
|
912
884
|
if (route) try {
|
|
913
885
|
callLog.route = route;
|
|
914
886
|
const { response, responseOptions, responseInput } = await this.generateResponse(callLog);
|
|
@@ -935,24 +907,24 @@ var Router = class {
|
|
|
935
907
|
return callLog.route.constructResponse(responseConfig);
|
|
936
908
|
}
|
|
937
909
|
createObservableResponse(response, responseConfig, responseInput, responseUrl, pendingPromises) {
|
|
938
|
-
return new Proxy(response, { get: (originalResponse, name
|
|
910
|
+
return new Proxy(response, { get: (originalResponse, name) => {
|
|
939
911
|
if (responseInput.redirectUrl) {
|
|
940
|
-
if (name
|
|
941
|
-
if (name
|
|
912
|
+
if (name === "url") return responseInput.redirectUrl;
|
|
913
|
+
if (name === "redirected") return true;
|
|
942
914
|
} else {
|
|
943
|
-
if (name
|
|
944
|
-
if (name
|
|
915
|
+
if (name === "url") return responseUrl;
|
|
916
|
+
if (name === "redirected") return false;
|
|
945
917
|
}
|
|
946
918
|
if (responseInput.status === 0) {
|
|
947
|
-
if (name
|
|
948
|
-
if (name
|
|
919
|
+
if (name === "status") return 0;
|
|
920
|
+
if (name === "statusText") return "";
|
|
949
921
|
}
|
|
950
|
-
if (typeof response[name
|
|
922
|
+
if (typeof response[name] === "function") return new Proxy(response[name], { apply: (func, thisArg, args) => {
|
|
951
923
|
const result = func.apply(response, args);
|
|
952
924
|
if (result.then) pendingPromises.push(result.catch(() => void 0));
|
|
953
925
|
return result;
|
|
954
926
|
} });
|
|
955
|
-
return originalResponse[name
|
|
927
|
+
return originalResponse[name];
|
|
956
928
|
} });
|
|
957
929
|
}
|
|
958
930
|
addRoute(matcher, response, nameOrOptions) {
|
|
@@ -963,7 +935,7 @@ var Router = class {
|
|
|
963
935
|
else Object.assign(config, matcher);
|
|
964
936
|
if (typeof response !== "undefined") config.response = response;
|
|
965
937
|
if (nameOrOptions) Object.assign(config, typeof nameOrOptions === "string" ? nameToOptions(nameOrOptions) : nameOrOptions);
|
|
966
|
-
const route = new
|
|
938
|
+
const route = new Route({
|
|
967
939
|
...this.config,
|
|
968
940
|
...config
|
|
969
941
|
});
|
|
@@ -982,7 +954,7 @@ var Router = class {
|
|
|
982
954
|
}
|
|
983
955
|
setFallback(response) {
|
|
984
956
|
if (this.fallbackRoute) console.warn("calling fetchMock.catch() twice - are you sure you want to overwrite the previous fallback response");
|
|
985
|
-
this.fallbackRoute = new
|
|
957
|
+
this.fallbackRoute = new Route({
|
|
986
958
|
matcherFunction: () => true,
|
|
987
959
|
response: response || "ok",
|
|
988
960
|
...this.config
|
|
@@ -991,15 +963,15 @@ var Router = class {
|
|
|
991
963
|
}
|
|
992
964
|
removeRoutes({ names, includeSticky, includeFallback } = {}) {
|
|
993
965
|
includeFallback = includeFallback ?? true;
|
|
994
|
-
this.routes = this.routes.filter(({ config: { sticky, name
|
|
966
|
+
this.routes = this.routes.filter(({ config: { sticky, name } }) => {
|
|
995
967
|
if (sticky && !includeSticky) return true;
|
|
996
968
|
if (!names) return false;
|
|
997
|
-
return !names.includes(name
|
|
969
|
+
return !names.includes(name);
|
|
998
970
|
});
|
|
999
971
|
if (includeFallback) delete this.fallbackRoute;
|
|
1000
972
|
}
|
|
1001
973
|
modifyRoute(routeName, options) {
|
|
1002
|
-
const route = this.routes.find(({ config: { name
|
|
974
|
+
const route = this.routes.find(({ config: { name } }) => name === routeName);
|
|
1003
975
|
if (!route) throw new Error(`Cannot call modifyRoute() on route \`${routeName}\`: route of that name not found`);
|
|
1004
976
|
if (route.config.sticky) throw new Error(`Cannot call modifyRoute() on route \`${routeName}\`: route is sticky and cannot be modified`);
|
|
1005
977
|
if ("name" in options) throw new Error(`Cannot rename the route \`${routeName}\` as \`${options.name}\`: renaming routes is not supported`);
|
|
@@ -1014,7 +986,6 @@ var Router = class {
|
|
|
1014
986
|
route.init(newConfig);
|
|
1015
987
|
}
|
|
1016
988
|
};
|
|
1017
|
-
|
|
1018
989
|
//#endregion
|
|
1019
990
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/CallHistory.js
|
|
1020
991
|
const isName = (filter) => typeof filter === "string" && /^[\da-zA-Z-]+$/.test(filter) && !["matched", "unmatched"].includes(filter);
|
|
@@ -1060,12 +1031,12 @@ var CallHistory = class {
|
|
|
1060
1031
|
...filter,
|
|
1061
1032
|
...options || {}
|
|
1062
1033
|
};
|
|
1063
|
-
const { matcher } = new
|
|
1034
|
+
const { matcher } = new Route({
|
|
1064
1035
|
response: "ok",
|
|
1065
1036
|
...options
|
|
1066
1037
|
});
|
|
1067
|
-
calls = calls.filter(({ url, options
|
|
1068
|
-
return matcher(createCallLogFromUrlAndOptions(url, options
|
|
1038
|
+
calls = calls.filter(({ url, options }) => {
|
|
1039
|
+
return matcher(createCallLogFromUrlAndOptions(url, options));
|
|
1069
1040
|
});
|
|
1070
1041
|
return calls;
|
|
1071
1042
|
}
|
|
@@ -1079,7 +1050,7 @@ var CallHistory = class {
|
|
|
1079
1050
|
let routesToCheck = this.router.routes;
|
|
1080
1051
|
if (routeNames) {
|
|
1081
1052
|
routeNames = Array.isArray(routeNames) ? routeNames : [routeNames];
|
|
1082
|
-
routesToCheck = this.router.routes.filter(({ config: { name
|
|
1053
|
+
routesToCheck = this.router.routes.filter(({ config: { name } }) => routeNames.includes(name));
|
|
1083
1054
|
}
|
|
1084
1055
|
return routesToCheck.map((route) => {
|
|
1085
1056
|
const calls = this.callLogs.filter(({ route: routeApplied }) => routeApplied === route);
|
|
@@ -1098,8 +1069,6 @@ var CallHistory = class {
|
|
|
1098
1069
|
}).every((isDone) => isDone);
|
|
1099
1070
|
}
|
|
1100
1071
|
};
|
|
1101
|
-
var CallHistory_default = CallHistory;
|
|
1102
|
-
|
|
1103
1072
|
//#endregion
|
|
1104
1073
|
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/FetchMock.js
|
|
1105
1074
|
const defaultFetchMockConfig = {
|
|
@@ -1121,7 +1090,9 @@ const defineGreedyShorthand = (shorthandOptions) => {
|
|
|
1121
1090
|
return this.route("*", response, Object.assign(options || {}, shorthandOptions));
|
|
1122
1091
|
};
|
|
1123
1092
|
};
|
|
1124
|
-
|
|
1093
|
+
//#endregion
|
|
1094
|
+
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/index.js
|
|
1095
|
+
var esm_default = new class FetchMock {
|
|
1125
1096
|
constructor(config, router) {
|
|
1126
1097
|
this.sticky = defineShorthand({ sticky: true });
|
|
1127
1098
|
this.once = defineShorthand({ repeat: 1 });
|
|
@@ -1162,7 +1133,7 @@ var FetchMock = class FetchMock {
|
|
|
1162
1133
|
routes: router ? [...router.routes] : [],
|
|
1163
1134
|
fallbackRoute: router ? router.fallbackRoute : null
|
|
1164
1135
|
});
|
|
1165
|
-
this.callHistory = new
|
|
1136
|
+
this.callHistory = new CallHistory(this.config, this.router);
|
|
1166
1137
|
this.fetchHandler = this.fetchHandler.bind(this);
|
|
1167
1138
|
Object.assign(this.fetchHandler, { fetchMock: this });
|
|
1168
1139
|
}
|
|
@@ -1187,7 +1158,7 @@ var FetchMock = class FetchMock {
|
|
|
1187
1158
|
return this;
|
|
1188
1159
|
}
|
|
1189
1160
|
defineMatcher(matcher) {
|
|
1190
|
-
|
|
1161
|
+
Route.defineMatcher(matcher);
|
|
1191
1162
|
}
|
|
1192
1163
|
removeRoutes(options) {
|
|
1193
1164
|
this.router.removeRoutes(options);
|
|
@@ -1219,9 +1190,9 @@ var FetchMock = class FetchMock {
|
|
|
1219
1190
|
this.unmockGlobal();
|
|
1220
1191
|
return this;
|
|
1221
1192
|
}
|
|
1222
|
-
spy(matcher, name
|
|
1193
|
+
spy(matcher, name) {
|
|
1223
1194
|
const boundFetch = this.config.fetch.bind(globalThis);
|
|
1224
|
-
if (matcher) this.route(matcher, ({ args }) => boundFetch(...args), name
|
|
1195
|
+
if (matcher) this.route(matcher, ({ args }) => boundFetch(...args), name);
|
|
1225
1196
|
else this.catch(({ args }) => boundFetch(...args));
|
|
1226
1197
|
return this;
|
|
1227
1198
|
}
|
|
@@ -1229,60 +1200,10 @@ var FetchMock = class FetchMock {
|
|
|
1229
1200
|
this.mockGlobal();
|
|
1230
1201
|
return this.spy();
|
|
1231
1202
|
}
|
|
1232
|
-
};
|
|
1233
|
-
const fetchMock = new FetchMock({ ...defaultFetchMockConfig });
|
|
1234
|
-
var FetchMock_default = fetchMock;
|
|
1235
|
-
|
|
1236
|
-
//#endregion
|
|
1237
|
-
//#region ../../node_modules/.pnpm/fetch-mock@12.6.0/node_modules/fetch-mock/dist/esm/index.js
|
|
1238
|
-
var esm_default = FetchMock_default;
|
|
1239
|
-
|
|
1203
|
+
}({ ...defaultFetchMockConfig });
|
|
1240
1204
|
//#endregion
|
|
1241
1205
|
//#region deno.json
|
|
1242
1206
|
var name = "@fedify/vocab";
|
|
1243
|
-
var version = "2.1.
|
|
1244
|
-
var license = "MIT";
|
|
1245
|
-
var exports = { ".": "./src/mod.ts" };
|
|
1246
|
-
var description = "Vocabularies library for @fedify/fedify";
|
|
1247
|
-
var author = {
|
|
1248
|
-
"name": "Hong Minhee",
|
|
1249
|
-
"email": "hong@minhee.org",
|
|
1250
|
-
"url": "https://hongminhee.org/"
|
|
1251
|
-
};
|
|
1252
|
-
var imports = {
|
|
1253
|
-
"fast-check": "npm:fast-check@^3.22.0",
|
|
1254
|
-
"fetch-mock": "npm:fetch-mock@^12.5.2",
|
|
1255
|
-
"jsonld": "npm:jsonld@^9.0.0"
|
|
1256
|
-
};
|
|
1257
|
-
var exclude = [
|
|
1258
|
-
"dist/",
|
|
1259
|
-
"dist-tests/",
|
|
1260
|
-
"node_modules/",
|
|
1261
|
-
"src/*.yaml",
|
|
1262
|
-
"!src/vocab.ts"
|
|
1263
|
-
];
|
|
1264
|
-
var publish = { "exclude": [
|
|
1265
|
-
"**/*.test.ts",
|
|
1266
|
-
"tsdown.config.ts",
|
|
1267
|
-
"scripts/"
|
|
1268
|
-
] };
|
|
1269
|
-
var tasks = {
|
|
1270
|
-
"check": "deno fmt --check && deno lint && deno check src/*.ts",
|
|
1271
|
-
"compile": "deno run --allow-read --allow-write --allow-env --allow-run scripts/codegen.ts",
|
|
1272
|
-
"test": "deno test --allow-read --allow-write --allow-env --unstable-kv --trace-leaks --parallel"
|
|
1273
|
-
};
|
|
1274
|
-
var deno_default = {
|
|
1275
|
-
name,
|
|
1276
|
-
version,
|
|
1277
|
-
license,
|
|
1278
|
-
exports,
|
|
1279
|
-
description,
|
|
1280
|
-
author,
|
|
1281
|
-
imports,
|
|
1282
|
-
exclude,
|
|
1283
|
-
publish,
|
|
1284
|
-
tasks
|
|
1285
|
-
};
|
|
1286
|
-
|
|
1207
|
+
var version = "2.1.2";
|
|
1287
1208
|
//#endregion
|
|
1288
|
-
export {
|
|
1209
|
+
export { version as n, esm_default as r, name as t };
|