@fedify/fedify 1.6.0-dev.811 → 1.6.0-dev.813

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 (141) hide show
  1. package/CHANGES.md +2 -0
  2. package/esm/deno.js +2 -3
  3. package/esm/federation/collection.js +1 -1
  4. package/esm/federation/handler.js +3 -2
  5. package/esm/{deps/jsr.io/@std/http/1.0.16/_negotiation/media_type.js → federation/negotiation.js} +14 -62
  6. package/esm/nodeinfo/client.js +2 -2
  7. package/esm/nodeinfo/mod.js +1 -1
  8. package/esm/nodeinfo/semver.js +150 -0
  9. package/esm/nodeinfo/types.js +2 -2
  10. package/esm/runtime/key.js +4 -4
  11. package/esm/sig/http.js +2 -2
  12. package/esm/sig/ld.js +2 -2
  13. package/esm/sig/proof.js +1 -1
  14. package/esm/vocab/vocab.js +176 -176
  15. package/package.json +3 -2
  16. package/types/deno.d.ts +1 -2
  17. package/types/federation/handler.d.ts.map +1 -1
  18. package/types/{deps/jsr.io/@std/http/1.0.16/_negotiation/common.d.ts → federation/negotiation.d.ts} +2 -3
  19. package/types/federation/negotiation.d.ts.map +1 -0
  20. package/types/nodeinfo/client.d.ts.map +1 -1
  21. package/types/nodeinfo/mod.d.ts +1 -1
  22. package/types/nodeinfo/mod.d.ts.map +1 -1
  23. package/types/nodeinfo/semver.d.ts +71 -0
  24. package/types/nodeinfo/semver.d.ts.map +1 -0
  25. package/types/nodeinfo/types.d.ts +1 -1
  26. package/types/nodeinfo/types.d.ts.map +1 -1
  27. package/esm/deps/jsr.io/@std/encoding/1.0.7/_types.js +0 -2
  28. package/esm/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.js +0 -26
  29. package/esm/deps/jsr.io/@std/encoding/1.0.7/base64.js +0 -163
  30. package/esm/deps/jsr.io/@std/encoding/1.0.7/base64url.js +0 -81
  31. package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.js +0 -109
  32. package/esm/deps/jsr.io/@std/http/1.0.16/_negotiation/common.js +0 -40
  33. package/esm/deps/jsr.io/@std/http/1.0.16/_negotiation/encoding.js +0 -123
  34. package/esm/deps/jsr.io/@std/http/1.0.16/_negotiation/language.js +0 -113
  35. package/esm/deps/jsr.io/@std/http/1.0.16/negotiation.js +0 -37
  36. package/esm/deps/jsr.io/@std/semver/1.0.5/_constants.js +0 -28
  37. package/esm/deps/jsr.io/@std/semver/1.0.5/_shared.js +0 -162
  38. package/esm/deps/jsr.io/@std/semver/1.0.5/_test_comparator_set.js +0 -58
  39. package/esm/deps/jsr.io/@std/semver/1.0.5/can_parse.js +0 -27
  40. package/esm/deps/jsr.io/@std/semver/1.0.5/compare.js +0 -35
  41. package/esm/deps/jsr.io/@std/semver/1.0.5/difference.js +0 -41
  42. package/esm/deps/jsr.io/@std/semver/1.0.5/equals.js +0 -27
  43. package/esm/deps/jsr.io/@std/semver/1.0.5/format.js +0 -32
  44. package/esm/deps/jsr.io/@std/semver/1.0.5/format_range.js +0 -27
  45. package/esm/deps/jsr.io/@std/semver/1.0.5/greater_or_equal.js +0 -26
  46. package/esm/deps/jsr.io/@std/semver/1.0.5/greater_than.js +0 -28
  47. package/esm/deps/jsr.io/@std/semver/1.0.5/greater_than_range.js +0 -58
  48. package/esm/deps/jsr.io/@std/semver/1.0.5/increment.js +0 -176
  49. package/esm/deps/jsr.io/@std/semver/1.0.5/is_range.js +0 -38
  50. package/esm/deps/jsr.io/@std/semver/1.0.5/is_semver.js +0 -53
  51. package/esm/deps/jsr.io/@std/semver/1.0.5/less_or_equal.js +0 -26
  52. package/esm/deps/jsr.io/@std/semver/1.0.5/less_than.js +0 -26
  53. package/esm/deps/jsr.io/@std/semver/1.0.5/less_than_range.js +0 -58
  54. package/esm/deps/jsr.io/@std/semver/1.0.5/max_satisfying.js +0 -30
  55. package/esm/deps/jsr.io/@std/semver/1.0.5/min_satisfying.js +0 -30
  56. package/esm/deps/jsr.io/@std/semver/1.0.5/mod.js +0 -300
  57. package/esm/deps/jsr.io/@std/semver/1.0.5/not_equals.js +0 -25
  58. package/esm/deps/jsr.io/@std/semver/1.0.5/parse.js +0 -44
  59. package/esm/deps/jsr.io/@std/semver/1.0.5/parse_range.js +0 -358
  60. package/esm/deps/jsr.io/@std/semver/1.0.5/range_intersects.js +0 -89
  61. package/esm/deps/jsr.io/@std/semver/1.0.5/satisfies.js +0 -27
  62. package/esm/deps/jsr.io/@std/semver/1.0.5/try_parse.js +0 -27
  63. package/esm/deps/jsr.io/@std/semver/1.0.5/try_parse_range.js +0 -33
  64. package/esm/deps/jsr.io/@std/semver/1.0.5/types.js +0 -3
  65. package/types/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts +0 -9
  66. package/types/deps/jsr.io/@std/encoding/1.0.7/_types.d.ts.map +0 -1
  67. package/types/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.d.ts +0 -2
  68. package/types/deps/jsr.io/@std/encoding/1.0.7/_validate_binary_like.d.ts.map +0 -1
  69. package/types/deps/jsr.io/@std/encoding/1.0.7/base64.d.ts +0 -40
  70. package/types/deps/jsr.io/@std/encoding/1.0.7/base64.d.ts.map +0 -1
  71. package/types/deps/jsr.io/@std/encoding/1.0.7/base64url.d.ts +0 -40
  72. package/types/deps/jsr.io/@std/encoding/1.0.7/base64url.d.ts.map +0 -1
  73. package/types/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts +0 -39
  74. package/types/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +0 -1
  75. package/types/deps/jsr.io/@std/http/1.0.16/_negotiation/common.d.ts.map +0 -1
  76. package/types/deps/jsr.io/@std/http/1.0.16/_negotiation/encoding.d.ts +0 -34
  77. package/types/deps/jsr.io/@std/http/1.0.16/_negotiation/encoding.d.ts.map +0 -1
  78. package/types/deps/jsr.io/@std/http/1.0.16/_negotiation/language.d.ts +0 -31
  79. package/types/deps/jsr.io/@std/http/1.0.16/_negotiation/language.d.ts.map +0 -1
  80. package/types/deps/jsr.io/@std/http/1.0.16/_negotiation/media_type.d.ts +0 -31
  81. package/types/deps/jsr.io/@std/http/1.0.16/_negotiation/media_type.d.ts.map +0 -1
  82. package/types/deps/jsr.io/@std/http/1.0.16/negotiation.d.ts +0 -148
  83. package/types/deps/jsr.io/@std/http/1.0.16/negotiation.d.ts.map +0 -1
  84. package/types/deps/jsr.io/@std/semver/1.0.5/_constants.d.ts +0 -12
  85. package/types/deps/jsr.io/@std/semver/1.0.5/_constants.d.ts.map +0 -1
  86. package/types/deps/jsr.io/@std/semver/1.0.5/_shared.d.ts +0 -44
  87. package/types/deps/jsr.io/@std/semver/1.0.5/_shared.d.ts.map +0 -1
  88. package/types/deps/jsr.io/@std/semver/1.0.5/_test_comparator_set.d.ts +0 -3
  89. package/types/deps/jsr.io/@std/semver/1.0.5/_test_comparator_set.d.ts.map +0 -1
  90. package/types/deps/jsr.io/@std/semver/1.0.5/can_parse.d.ts +0 -17
  91. package/types/deps/jsr.io/@std/semver/1.0.5/can_parse.d.ts.map +0 -1
  92. package/types/deps/jsr.io/@std/semver/1.0.5/compare.d.ts +0 -28
  93. package/types/deps/jsr.io/@std/semver/1.0.5/compare.d.ts.map +0 -1
  94. package/types/deps/jsr.io/@std/semver/1.0.5/difference.d.ts +0 -27
  95. package/types/deps/jsr.io/@std/semver/1.0.5/difference.d.ts.map +0 -1
  96. package/types/deps/jsr.io/@std/semver/1.0.5/equals.d.ts +0 -24
  97. package/types/deps/jsr.io/@std/semver/1.0.5/equals.d.ts.map +0 -1
  98. package/types/deps/jsr.io/@std/semver/1.0.5/format.d.ts +0 -22
  99. package/types/deps/jsr.io/@std/semver/1.0.5/format.d.ts.map +0 -1
  100. package/types/deps/jsr.io/@std/semver/1.0.5/format_range.d.ts +0 -18
  101. package/types/deps/jsr.io/@std/semver/1.0.5/format_range.d.ts.map +0 -1
  102. package/types/deps/jsr.io/@std/semver/1.0.5/greater_or_equal.d.ts +0 -25
  103. package/types/deps/jsr.io/@std/semver/1.0.5/greater_or_equal.d.ts.map +0 -1
  104. package/types/deps/jsr.io/@std/semver/1.0.5/greater_than.d.ts +0 -25
  105. package/types/deps/jsr.io/@std/semver/1.0.5/greater_than.d.ts.map +0 -1
  106. package/types/deps/jsr.io/@std/semver/1.0.5/greater_than_range.d.ts +0 -23
  107. package/types/deps/jsr.io/@std/semver/1.0.5/greater_than_range.d.ts.map +0 -1
  108. package/types/deps/jsr.io/@std/semver/1.0.5/increment.d.ts +0 -51
  109. package/types/deps/jsr.io/@std/semver/1.0.5/increment.d.ts.map +0 -1
  110. package/types/deps/jsr.io/@std/semver/1.0.5/is_range.d.ts +0 -23
  111. package/types/deps/jsr.io/@std/semver/1.0.5/is_range.d.ts.map +0 -1
  112. package/types/deps/jsr.io/@std/semver/1.0.5/is_semver.d.ts +0 -34
  113. package/types/deps/jsr.io/@std/semver/1.0.5/is_semver.d.ts.map +0 -1
  114. package/types/deps/jsr.io/@std/semver/1.0.5/less_or_equal.d.ts +0 -25
  115. package/types/deps/jsr.io/@std/semver/1.0.5/less_or_equal.d.ts.map +0 -1
  116. package/types/deps/jsr.io/@std/semver/1.0.5/less_than.d.ts +0 -25
  117. package/types/deps/jsr.io/@std/semver/1.0.5/less_than.d.ts.map +0 -1
  118. package/types/deps/jsr.io/@std/semver/1.0.5/less_than_range.d.ts +0 -23
  119. package/types/deps/jsr.io/@std/semver/1.0.5/less_than_range.d.ts.map +0 -1
  120. package/types/deps/jsr.io/@std/semver/1.0.5/max_satisfying.d.ts +0 -22
  121. package/types/deps/jsr.io/@std/semver/1.0.5/max_satisfying.d.ts.map +0 -1
  122. package/types/deps/jsr.io/@std/semver/1.0.5/min_satisfying.d.ts +0 -22
  123. package/types/deps/jsr.io/@std/semver/1.0.5/min_satisfying.d.ts.map +0 -1
  124. package/types/deps/jsr.io/@std/semver/1.0.5/mod.d.ts +0 -298
  125. package/types/deps/jsr.io/@std/semver/1.0.5/mod.d.ts.map +0 -1
  126. package/types/deps/jsr.io/@std/semver/1.0.5/not_equals.d.ts +0 -24
  127. package/types/deps/jsr.io/@std/semver/1.0.5/not_equals.d.ts.map +0 -1
  128. package/types/deps/jsr.io/@std/semver/1.0.5/parse.d.ts +0 -25
  129. package/types/deps/jsr.io/@std/semver/1.0.5/parse.d.ts.map +0 -1
  130. package/types/deps/jsr.io/@std/semver/1.0.5/parse_range.d.ts +0 -27
  131. package/types/deps/jsr.io/@std/semver/1.0.5/parse_range.d.ts.map +0 -1
  132. package/types/deps/jsr.io/@std/semver/1.0.5/range_intersects.d.ts +0 -25
  133. package/types/deps/jsr.io/@std/semver/1.0.5/range_intersects.d.ts.map +0 -1
  134. package/types/deps/jsr.io/@std/semver/1.0.5/satisfies.d.ts +0 -24
  135. package/types/deps/jsr.io/@std/semver/1.0.5/satisfies.d.ts.map +0 -1
  136. package/types/deps/jsr.io/@std/semver/1.0.5/try_parse.d.ts +0 -21
  137. package/types/deps/jsr.io/@std/semver/1.0.5/try_parse.d.ts.map +0 -1
  138. package/types/deps/jsr.io/@std/semver/1.0.5/try_parse_range.d.ts +0 -23
  139. package/types/deps/jsr.io/@std/semver/1.0.5/try_parse_range.d.ts.map +0 -1
  140. package/types/deps/jsr.io/@std/semver/1.0.5/types.d.ts +0 -58
  141. package/types/deps/jsr.io/@std/semver/1.0.5/types.d.ts.map +0 -1
@@ -1,123 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- /*!
3
- * Adapted directly from negotiator at https://github.com/jshttp/negotiator/
4
- * which is licensed as follows:
5
- *
6
- * (The MIT License)
7
- *
8
- * Copyright (c) 2012-2014 Federico Romero
9
- * Copyright (c) 2012-2014 Isaac Z. Schlueter
10
- * Copyright (c) 2014-2015 Douglas Christopher Wilson
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining
13
- * a copy of this software and associated documentation files (the
14
- * 'Software'), to deal in the Software without restriction, including
15
- * without limitation the rights to use, copy, modify, merge, publish,
16
- * distribute, sublicense, and/or sell copies of the Software, and to
17
- * permit persons to whom the Software is furnished to do so, subject to
18
- * the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be
21
- * included in all copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
24
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
27
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
29
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
- */
31
- import { compareSpecs, isQuality } from "./common.js";
32
- const simpleEncodingRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
33
- function parseEncoding(str, i) {
34
- const match = simpleEncodingRegExp.exec(str);
35
- if (!match) {
36
- return undefined;
37
- }
38
- const encoding = match[1];
39
- let q = 1;
40
- if (match[2]) {
41
- const params = match[2].split(";");
42
- for (const param of params) {
43
- const p = param.trim().split("=");
44
- if (p[0] === "q" && p[1]) {
45
- q = parseFloat(p[1]);
46
- break;
47
- }
48
- }
49
- }
50
- return { encoding, o: undefined, q, i, s: undefined };
51
- }
52
- function specify(encoding, spec, i = -1) {
53
- if (!spec.encoding) {
54
- return;
55
- }
56
- let s = 0;
57
- if (spec.encoding.toLowerCase() === encoding.toLowerCase()) {
58
- s = 1;
59
- }
60
- else if (spec.encoding !== "*") {
61
- return;
62
- }
63
- return {
64
- i,
65
- o: spec.i,
66
- q: spec.q,
67
- s,
68
- };
69
- }
70
- function parseAcceptEncoding(accept) {
71
- const accepts = accept.split(",");
72
- const parsedAccepts = [];
73
- let hasIdentity = false;
74
- let minQuality = 1;
75
- for (const [i, accept] of accepts.entries()) {
76
- const encoding = parseEncoding(accept.trim(), i);
77
- if (encoding) {
78
- parsedAccepts.push(encoding);
79
- hasIdentity = hasIdentity || !!specify("identity", encoding);
80
- minQuality = Math.min(minQuality, encoding.q || 1);
81
- }
82
- }
83
- if (!hasIdentity) {
84
- parsedAccepts.push({
85
- encoding: "identity",
86
- o: undefined,
87
- q: minQuality,
88
- i: accepts.length - 1,
89
- s: undefined,
90
- });
91
- }
92
- return parsedAccepts;
93
- }
94
- function getEncodingPriority(encoding, accepted, index) {
95
- let priority = { o: -1, q: 0, s: 0, i: 0 };
96
- for (const s of accepted) {
97
- const spec = specify(encoding, s, index);
98
- if (spec &&
99
- (priority.s - spec.s || priority.q - spec.q ||
100
- priority.o - spec.o) <
101
- 0) {
102
- priority = spec;
103
- }
104
- }
105
- return priority;
106
- }
107
- /** Given an `Accept-Encoding` string, parse out the encoding returning a
108
- * negotiated encoding based on the `provided` encodings otherwise just a
109
- * prioritized array of encodings. */
110
- export function preferredEncodings(accept, provided) {
111
- const accepts = parseAcceptEncoding(accept);
112
- if (!provided) {
113
- return accepts
114
- .filter(isQuality)
115
- .sort(compareSpecs)
116
- .map((spec) => spec.encoding);
117
- }
118
- const priorities = provided.map((type, index) => getEncodingPriority(type, accepts, index));
119
- return priorities
120
- .filter(isQuality)
121
- .sort(compareSpecs)
122
- .map((priority) => provided[priorities.indexOf(priority)]);
123
- }
@@ -1,113 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- /*!
3
- * Adapted directly from negotiator at https://github.com/jshttp/negotiator/
4
- * which is licensed as follows:
5
- *
6
- * (The MIT License)
7
- *
8
- * Copyright (c) 2012-2014 Federico Romero
9
- * Copyright (c) 2012-2014 Isaac Z. Schlueter
10
- * Copyright (c) 2014-2015 Douglas Christopher Wilson
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining
13
- * a copy of this software and associated documentation files (the
14
- * 'Software'), to deal in the Software without restriction, including
15
- * without limitation the rights to use, copy, modify, merge, publish,
16
- * distribute, sublicense, and/or sell copies of the Software, and to
17
- * permit persons to whom the Software is furnished to do so, subject to
18
- * the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be
21
- * included in all copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
24
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
27
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
29
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
- */
31
- import { compareSpecs, isQuality } from "./common.js";
32
- const SIMPLE_LANGUAGE_REGEXP = /^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;
33
- function parseLanguage(str, i) {
34
- const match = SIMPLE_LANGUAGE_REGEXP.exec(str);
35
- if (!match) {
36
- return undefined;
37
- }
38
- const [, prefix, suffix] = match;
39
- if (!prefix) {
40
- return undefined;
41
- }
42
- const full = suffix !== undefined ? `${prefix}-${suffix}` : prefix;
43
- let q = 1;
44
- if (match[3]) {
45
- const params = match[3].split(";");
46
- for (const param of params) {
47
- const [key, value] = param.trim().split("=");
48
- if (key === "q" && value) {
49
- q = parseFloat(value);
50
- break;
51
- }
52
- }
53
- }
54
- return { prefix, suffix, full, i, o: undefined, q, s: undefined };
55
- }
56
- function parseAcceptLanguage(accept) {
57
- const accepts = accept.split(",");
58
- const result = [];
59
- for (const [i, accept] of accepts.entries()) {
60
- const language = parseLanguage(accept.trim(), i);
61
- if (language) {
62
- result.push(language);
63
- }
64
- }
65
- return result;
66
- }
67
- function specify(language, spec, i) {
68
- const p = parseLanguage(language, i);
69
- if (!p) {
70
- return undefined;
71
- }
72
- let s = 0;
73
- if (spec.full.toLowerCase() === p.full.toLowerCase()) {
74
- s |= 4;
75
- }
76
- else if (spec.prefix.toLowerCase() === p.prefix.toLowerCase()) {
77
- s |= 2;
78
- }
79
- else if (spec.full.toLowerCase() === p.prefix.toLowerCase()) {
80
- s |= 1;
81
- }
82
- else if (spec.full !== "*") {
83
- return;
84
- }
85
- return { i, o: spec.i, q: spec.q, s };
86
- }
87
- function getLanguagePriority(language, accepted, index) {
88
- let priority = { i: -1, o: -1, q: 0, s: 0 };
89
- for (const accepts of accepted) {
90
- const spec = specify(language, accepts, index);
91
- if (spec &&
92
- ((priority.s ?? 0) - (spec.s ?? 0) || priority.q - spec.q ||
93
- (priority.o ?? 0) - (spec.o ?? 0)) < 0) {
94
- priority = spec;
95
- }
96
- }
97
- return priority;
98
- }
99
- export function preferredLanguages(accept = "*", provided) {
100
- const accepts = parseAcceptLanguage(accept);
101
- if (!provided) {
102
- return accepts
103
- .filter(isQuality)
104
- .sort(compareSpecs)
105
- .map((spec) => spec.full);
106
- }
107
- const priorities = provided
108
- .map((type, index) => getLanguagePriority(type, accepts, index));
109
- return priorities
110
- .filter(isQuality)
111
- .sort(compareSpecs)
112
- .map((priority) => provided[priorities.indexOf(priority)]);
113
- }
@@ -1,37 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- // This module is browser compatible.
3
- /**
4
- * Contains the functions {@linkcode accepts}, {@linkcode acceptsEncodings}, and
5
- * {@linkcode acceptsLanguages} to provide content negotiation capabilities.
6
- *
7
- * @module
8
- */
9
- import { preferredEncodings } from "./_negotiation/encoding.js";
10
- import { preferredLanguages } from "./_negotiation/language.js";
11
- import { preferredMediaTypes } from "./_negotiation/media_type.js";
12
- export function accepts(request, ...types) {
13
- const accept = request.headers.get("accept");
14
- return types.length
15
- ? accept ? preferredMediaTypes(accept, types)[0] : types[0]
16
- : accept
17
- ? preferredMediaTypes(accept)
18
- : ["*/*"];
19
- }
20
- export function acceptsEncodings(request, ...encodings) {
21
- const acceptEncoding = request.headers.get("accept-encoding");
22
- return encodings.length
23
- ? acceptEncoding
24
- ? preferredEncodings(acceptEncoding, encodings)[0]
25
- : encodings[0]
26
- : acceptEncoding
27
- ? preferredEncodings(acceptEncoding)
28
- : ["*"];
29
- }
30
- export function acceptsLanguages(request, ...langs) {
31
- const acceptLanguage = request.headers.get("accept-language");
32
- return langs.length
33
- ? acceptLanguage ? preferredLanguages(acceptLanguage, langs)[0] : langs[0]
34
- : acceptLanguage
35
- ? preferredLanguages(acceptLanguage)
36
- : ["*"];
37
- }
@@ -1,28 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- /**
3
- * ANY is a sentinel value used by some range calculations. It is not a valid
4
- * SemVer object and should not be used directly.
5
- */
6
- export const ANY = {
7
- major: Number.NaN,
8
- minor: Number.NaN,
9
- patch: Number.NaN,
10
- prerelease: [],
11
- build: [],
12
- };
13
- /**
14
- * A comparator which will span all valid semantic versions
15
- */
16
- export const ALL = {
17
- operator: undefined,
18
- ...ANY,
19
- };
20
- export const OPERATORS = [
21
- undefined,
22
- "=",
23
- "!=",
24
- ">",
25
- ">=",
26
- "<",
27
- "<=",
28
- ];
@@ -1,162 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- export function compareNumber(a, b) {
3
- if (isNaN(a) || isNaN(b)) {
4
- throw new Error("Cannot compare against non-numbers");
5
- }
6
- return a === b ? 0 : a < b ? -1 : 1;
7
- }
8
- export function checkIdentifier(v1 = [], v2 = []) {
9
- // NOT having a prerelease is > having one
10
- // But NOT having a build is < having one
11
- if (v1.length && !v2.length)
12
- return -1;
13
- if (!v1.length && v2.length)
14
- return 1;
15
- return 0;
16
- }
17
- export function compareIdentifier(v1 = [], v2 = []) {
18
- const length = Math.max(v1.length, v2.length);
19
- for (let i = 0; i < length; i++) {
20
- const a = v1[i];
21
- const b = v2[i];
22
- // same length is equal
23
- if (a === undefined && b === undefined)
24
- return 0;
25
- // longer > shorter
26
- if (b === undefined)
27
- return 1;
28
- // shorter < longer
29
- if (a === undefined)
30
- return -1;
31
- // string > number
32
- if (typeof a === "string" && typeof b === "number")
33
- return 1;
34
- // number < string
35
- if (typeof a === "number" && typeof b === "string")
36
- return -1;
37
- if (a < b)
38
- return -1;
39
- if (a > b)
40
- return 1;
41
- // If they're equal, continue comparing segments.
42
- }
43
- return 0;
44
- }
45
- /**
46
- * A single `0`, or a non-zero digit followed by zero or more digits.
47
- */
48
- const NUMERIC_IDENTIFIER = "0|[1-9]\\d*";
49
- /**
50
- * Zero or more digits, followed by a letter or hyphen, and then zero or more letters, digits, or hyphens.
51
- */
52
- const NON_NUMERIC_IDENTIFIER = "\\d*[a-zA-Z-][a-zA-Z0-9-]*";
53
- /**
54
- * Three dot-separated numeric identifiers.
55
- */
56
- const VERSION_CORE = `(?<major>${NUMERIC_IDENTIFIER})\\.(?<minor>${NUMERIC_IDENTIFIER})\\.(?<patch>${NUMERIC_IDENTIFIER})`;
57
- /**
58
- * A numeric identifier, or a non-numeric identifier.
59
- */
60
- const PRERELEASE_IDENTIFIER = `(?:${NUMERIC_IDENTIFIER}|${NON_NUMERIC_IDENTIFIER})`;
61
- /**
62
- * A hyphen, followed by one or more dot-separated pre-release version identifiers.
63
- * @example "-pre.release"
64
- */
65
- const PRERELEASE = `(?:-(?<prerelease>${PRERELEASE_IDENTIFIER}(?:\\.${PRERELEASE_IDENTIFIER})*))`;
66
- /**
67
- * Any combination of digits, letters, or hyphens.
68
- */
69
- const BUILD_IDENTIFIER = "[0-9A-Za-z-]+";
70
- /**
71
- * A plus sign, followed by one or more period-separated build metadata identifiers.
72
- * @example "+build.meta"
73
- */
74
- const BUILD = `(?:\\+(?<buildmetadata>${BUILD_IDENTIFIER}(?:\\.${BUILD_IDENTIFIER})*))`;
75
- /**
76
- * A version, followed optionally by a pre-release version and build metadata.
77
- */
78
- const FULL_VERSION = `v?${VERSION_CORE}${PRERELEASE}?${BUILD}?`;
79
- export const FULL_REGEXP = new RegExp(`^${FULL_VERSION}$`);
80
- /**
81
- * A comparator.
82
- * @example `=`, `<`, `<=`, `>`, `>=`
83
- */
84
- const COMPARATOR = "(?:<|>)?=?";
85
- /**
86
- * A wildcard identifier.
87
- * @example "x", "X", "*"
88
- */
89
- const WILDCARD_IDENTIFIER = `x|X|\\*`;
90
- const XRANGE_IDENTIFIER = `${NUMERIC_IDENTIFIER}|${WILDCARD_IDENTIFIER}`;
91
- /**
92
- * A version that can contain wildcards.
93
- * @example "x", "1.x", "1.x.x", "1.2.x", "*", "1.*", "1.*.*", "1.2.*"
94
- */
95
- export const XRANGE = `[v=\\s]*(?<major>${XRANGE_IDENTIFIER})(?:\\.(?<minor>${XRANGE_IDENTIFIER})(?:\\.(?<patch>${XRANGE_IDENTIFIER})${PRERELEASE}?${BUILD}?)?)?`;
96
- /**
97
- * An operator (`~`, `~>`, `^`, `=`, `<`, `<=`, `>`, or `>=`), followed by an x-range.
98
- * @example "~1.x.x", "^1.2.*", ">=1.2.3"
99
- */
100
- export const OPERATOR_XRANGE_REGEXP = new RegExp(`^(?<operator>~>?|\\^|${COMPARATOR})\\s*${XRANGE}$`);
101
- /**
102
- * An empty string or a comparator (`=`, `<`, `<=`, `>`, or `>=`), followed by a version.
103
- * @example ">1.2.3"
104
- */
105
- export const COMPARATOR_REGEXP = new RegExp(`^(?<operator>${COMPARATOR})\\s*(${FULL_VERSION})$|^$`);
106
- /**
107
- * Returns true if the value is a valid SemVer number.
108
- *
109
- * Must be a number. Must not be NaN. Can be positive or negative infinity.
110
- * Can be between 0 and MAX_SAFE_INTEGER.
111
- * @param value The value to check
112
- * @returns True if its a valid semver number
113
- */
114
- export function isValidNumber(value) {
115
- return (typeof value === "number" &&
116
- !Number.isNaN(value) &&
117
- (!Number.isFinite(value) ||
118
- (0 <= value && value <= Number.MAX_SAFE_INTEGER)));
119
- }
120
- export const MAX_LENGTH = 256;
121
- /**
122
- * Returns true if the value is a valid semver pre-release or build identifier.
123
- *
124
- * Must be a string. Must be between 1 and 256 characters long. Must match
125
- * the regular expression /[0-9A-Za-z-]+/.
126
- * @param value The value to check
127
- * @returns True if the value is a valid semver string.
128
- */
129
- export function isValidString(value) {
130
- return (typeof value === "string" &&
131
- value.length > 0 &&
132
- value.length <= MAX_LENGTH &&
133
- /[0-9A-Za-z-]+/.test(value));
134
- }
135
- const NUMERIC_IDENTIFIER_REGEXP = new RegExp(`^${NUMERIC_IDENTIFIER}$`);
136
- export function parsePrerelease(prerelease) {
137
- return prerelease
138
- .split(".")
139
- .filter(Boolean)
140
- .map((id) => {
141
- if (NUMERIC_IDENTIFIER_REGEXP.test(id)) {
142
- const number = Number(id);
143
- if (isValidNumber(number))
144
- return number;
145
- }
146
- return id;
147
- });
148
- }
149
- export function parseBuild(buildmetadata) {
150
- return buildmetadata.split(".").filter(Boolean);
151
- }
152
- export function parseNumber(input, errorMessage) {
153
- const number = Number(input);
154
- if (!isValidNumber(number))
155
- throw new TypeError(errorMessage);
156
- return number;
157
- }
158
- export function isWildcardComparator(c) {
159
- return (Number.isNaN(c.major) && Number.isNaN(c.minor) && Number.isNaN(c.patch) &&
160
- (c.prerelease === undefined || c.prerelease.length === 0) &&
161
- (c.build === undefined || c.build.length === 0));
162
- }
@@ -1,58 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- import { isWildcardComparator } from "./_shared.js";
3
- import { compare } from "./compare.js";
4
- function testComparator(version, comparator) {
5
- if (isWildcardComparator(comparator)) {
6
- return true;
7
- }
8
- const cmp = compare(version, comparator);
9
- switch (comparator.operator) {
10
- case "=":
11
- case undefined: {
12
- return cmp === 0;
13
- }
14
- case "!=": {
15
- return cmp !== 0;
16
- }
17
- case ">": {
18
- return cmp > 0;
19
- }
20
- case "<": {
21
- return cmp < 0;
22
- }
23
- case ">=": {
24
- return cmp >= 0;
25
- }
26
- case "<=": {
27
- return cmp <= 0;
28
- }
29
- }
30
- }
31
- export function testComparatorSet(version, set) {
32
- for (const comparator of set) {
33
- if (!testComparator(version, comparator)) {
34
- return false;
35
- }
36
- }
37
- if (version.prerelease && version.prerelease.length > 0) {
38
- // Find the comparator that is allowed to have prereleases
39
- // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
40
- // That should allow `1.2.3-pr.2` to pass.
41
- // However, `1.2.4-alpha.notready` should NOT be allowed,
42
- // even though it's within the range set by the comparators.
43
- for (const comparator of set) {
44
- if (isWildcardComparator(comparator)) {
45
- continue;
46
- }
47
- const { major, minor, patch, prerelease } = comparator;
48
- if (prerelease && prerelease.length > 0) {
49
- if (version.major === major && version.minor === minor &&
50
- version.patch === patch) {
51
- return true;
52
- }
53
- }
54
- }
55
- return false;
56
- }
57
- return true;
58
- }
@@ -1,27 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- // This module is browser compatible.
3
- import { parse } from "./parse.js";
4
- /**
5
- * Returns true if the string can be parsed as SemVer.
6
- *
7
- * @example Usage
8
- * ```ts
9
- * import { canParse } from "@std/semver/can-parse";
10
- * import { assert, assertFalse } from "@std/assert";
11
- *
12
- * assert(canParse("1.2.3"));
13
- * assertFalse(canParse("invalid"));
14
- * ```
15
- *
16
- * @param value The version string to check
17
- * @returns `true` if the string can be parsed as SemVer, `false` otherwise
18
- */
19
- export function canParse(value) {
20
- try {
21
- parse(value);
22
- return true;
23
- }
24
- catch {
25
- return false;
26
- }
27
- }
@@ -1,35 +0,0 @@
1
- import { checkIdentifier, compareIdentifier, compareNumber, } from "./_shared.js";
2
- /**
3
- * Compare two SemVers.
4
- *
5
- * Returns `0` if `version1` equals `version2`, or `1` if `version1` is greater, or `-1` if `version2` is
6
- * greater.
7
- *
8
- * Sorts in ascending order if passed to {@linkcode Array.sort}.
9
- *
10
- * @example Usage
11
- * ```ts
12
- * import { parse, compare } from "@std/semver";
13
- * import { assertEquals } from "@std/assert";
14
- *
15
- * const version1 = parse("1.2.3");
16
- * const version2 = parse("1.2.4");
17
- *
18
- * assertEquals(compare(version1, version2), -1);
19
- * assertEquals(compare(version2, version1), 1);
20
- * assertEquals(compare(version1, version1), 0);
21
- * ```
22
- *
23
- * @param version1 The first SemVer to compare
24
- * @param version2 The second SemVer to compare
25
- * @returns `1` if `version1` is greater, `0` if equal, or `-1` if `version2` is greater
26
- */
27
- export function compare(version1, version2) {
28
- if (version1 === version2)
29
- return 0;
30
- return (compareNumber(version1.major, version2.major) ||
31
- compareNumber(version1.minor, version2.minor) ||
32
- compareNumber(version1.patch, version2.patch) ||
33
- checkIdentifier(version1.prerelease, version2.prerelease) ||
34
- compareIdentifier(version1.prerelease, version2.prerelease));
35
- }
@@ -1,41 +0,0 @@
1
- import { compareIdentifier } from "./_shared.js";
2
- /**
3
- * Returns difference between two SemVers by the release type,
4
- * or `undefined` if the SemVers are the same.
5
- *
6
- * @example Usage
7
- * ```ts
8
- * import { parse, difference } from "@std/semver";
9
- * import { assertEquals } from "@std/assert";
10
- *
11
- * const version1 = parse("1.2.3");
12
- * const version2 = parse("1.2.4");
13
- * const version3 = parse("1.3.0");
14
- * const version4 = parse("2.0.0");
15
- *
16
- * assertEquals(difference(version1, version2), "patch");
17
- * assertEquals(difference(version1, version3), "minor");
18
- * assertEquals(difference(version1, version4), "major");
19
- * assertEquals(difference(version1, version1), undefined);
20
- * ```
21
- *
22
- * @param version1 The first SemVer to compare
23
- * @param version2 The second SemVer to compare
24
- * @returns The release type difference or `undefined` if the versions are the same
25
- */
26
- export function difference(version1, version2) {
27
- const hasPrerelease = version1.prerelease?.length ||
28
- version2.prerelease?.length;
29
- if (version1.major !== version2.major) {
30
- return hasPrerelease ? "premajor" : "major";
31
- }
32
- if (version1.minor !== version2.minor) {
33
- return hasPrerelease ? "preminor" : "minor";
34
- }
35
- if (version1.patch !== version2.patch) {
36
- return hasPrerelease ? "prepatch" : "patch";
37
- }
38
- if (compareIdentifier(version1.prerelease, version2.prerelease) !== 0) {
39
- return "prerelease";
40
- }
41
- }
@@ -1,27 +0,0 @@
1
- // Copyright 2018-2025 the Deno authors. MIT license.
2
- // This module is browser compatible.
3
- import { compare } from "./compare.js";
4
- /**
5
- * Returns `true` if both SemVers are equivalent.
6
- *
7
- * This is equal to `compare(version1, version2) === 0`.
8
- *
9
- * @example Usage
10
- * ```ts
11
- * import { parse, equals } from "@std/semver";
12
- * import { assert } from "@std/assert";
13
- *
14
- * const version1 = parse("1.2.3");
15
- * const version2 = parse("1.2.3");
16
- *
17
- * assert(equals(version1, version2));
18
- * assert(!equals(version1, parse("1.2.4")));
19
- * ```
20
- *
21
- * @param version1 The first SemVer to compare
22
- * @param version2 The second SemVer to compare
23
- * @returns `true` if `version1` is equal to `version2`, `false` otherwise
24
- */
25
- export function equals(version1, version2) {
26
- return compare(version1, version2) === 0;
27
- }
@@ -1,32 +0,0 @@
1
- function formatNumber(value) {
2
- return value.toFixed(0);
3
- }
4
- /**
5
- * Format a SemVer object into a string.
6
- *
7
- * @example Usage
8
- * ```ts
9
- * import { format } from "@std/semver/format";
10
- * import { assertEquals } from "@std/assert";
11
- *
12
- * const semver = {
13
- * major: 1,
14
- * minor: 2,
15
- * patch: 3,
16
- * };
17
- * assertEquals(format(semver), "1.2.3");
18
- * ```
19
- *
20
- * @param version The SemVer to format
21
- * @returns The string representation of a semantic version.
22
- */
23
- export function format(version) {
24
- const major = formatNumber(version.major);
25
- const minor = formatNumber(version.minor);
26
- const patch = formatNumber(version.patch);
27
- const pre = version.prerelease?.join(".") ?? "";
28
- const build = version.build?.join(".") ?? "";
29
- const primary = `${major}.${minor}.${patch}`;
30
- const release = [primary, pre].filter((v) => v).join("-");
31
- return [release, build].filter((v) => v).join("+");
32
- }