@fedify/vocab-runtime 2.4.0-pr.936.41 → 2.4.1

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 (152) hide show
  1. package/deno.json +4 -2
  2. package/dist/{tests/docloader-Ck8bcBir.mjs → contexts-B09jb9Pi.cjs} +173 -274
  3. package/dist/{tests/docloader-S_gQZ2tt.cjs → contexts-DWrj4AGR.js} +169 -293
  4. package/dist/{docloader-C_dir7Xb.d.ts → docloader-BMHljyYb.d.cts} +68 -2
  5. package/dist/{docloader-D2DTRiyA.d.cts → docloader-BMHljyYb.d.ts} +68 -2
  6. package/dist/internal/jsonld-cache.cjs +70 -1
  7. package/dist/internal/jsonld-cache.d.cts +35 -2
  8. package/dist/internal/jsonld-cache.d.ts +35 -2
  9. package/dist/internal/jsonld-cache.js +67 -2
  10. package/dist/internal/portable-dereference.cjs +721 -0
  11. package/dist/internal/portable-dereference.d.cts +349 -0
  12. package/dist/internal/portable-dereference.d.ts +349 -0
  13. package/dist/internal/portable-dereference.js +702 -0
  14. package/dist/internal/signed-representation.cjs +378 -0
  15. package/dist/internal/signed-representation.d.cts +144 -0
  16. package/dist/internal/signed-representation.d.ts +144 -0
  17. package/dist/internal/signed-representation.js +371 -0
  18. package/dist/jsonld.cjs +2 -2
  19. package/dist/mod.cjs +762 -4529
  20. package/dist/mod.d.cts +427 -9
  21. package/dist/mod.d.ts +427 -10
  22. package/dist/mod.js +742 -4524
  23. package/dist/portable-6Aj-7dZJ.d.cts +160 -0
  24. package/dist/portable-nkTiqH0w.d.ts +160 -0
  25. package/dist/tests/body-DpC9p-iG.mjs +130 -0
  26. package/dist/tests/body-cKLBprYm.cjs +153 -0
  27. package/dist/tests/body.test.cjs +89 -0
  28. package/dist/tests/body.test.d.cts +1 -0
  29. package/dist/tests/body.test.d.mts +1 -0
  30. package/dist/tests/body.test.mjs +90 -0
  31. package/dist/tests/contexts-C9Lj11SC.cjs +4533 -0
  32. package/dist/tests/contexts-duRA_dDC.mjs +4522 -0
  33. package/dist/tests/decimal.test.cjs +9 -7
  34. package/dist/tests/decimal.test.mjs +9 -6
  35. package/dist/tests/digest-3FeH2Y-Q.cjs +176 -0
  36. package/dist/tests/digest-COC7xDiQ.mjs +141 -0
  37. package/dist/tests/digest.test.cjs +102 -0
  38. package/dist/tests/digest.test.d.cts +1 -0
  39. package/dist/tests/digest.test.d.mts +1 -0
  40. package/dist/tests/digest.test.mjs +103 -0
  41. package/dist/tests/docloader-DyZ1JGIl.cjs +398 -0
  42. package/dist/tests/docloader-tUmMeXjU.mjs +375 -0
  43. package/dist/tests/docloader.test.cjs +816 -39
  44. package/dist/tests/docloader.test.mjs +810 -34
  45. package/dist/tests/internal/multicodec.test.cjs +2 -3
  46. package/dist/tests/internal/multicodec.test.mjs +2 -2
  47. package/dist/tests/internal/portable-dereference.test.cjs +172 -0
  48. package/dist/tests/internal/portable-dereference.test.d.cts +1 -0
  49. package/dist/tests/internal/portable-dereference.test.d.mts +1 -0
  50. package/dist/tests/internal/portable-dereference.test.mjs +173 -0
  51. package/dist/tests/jsonld-CmDhHNTx.cjs +12 -0
  52. package/dist/tests/jsonld-DweIJ07b.mjs +5 -0
  53. package/dist/tests/jsonld-cache-BEXiiM-V.cjs +386 -0
  54. package/dist/tests/jsonld-cache-DFnWsLuZ.mjs +339 -0
  55. package/dist/tests/jsonld-cache.test.cjs +102 -298
  56. package/dist/tests/jsonld-cache.test.mjs +95 -289
  57. package/dist/tests/{key-_wXwomh_.cjs → key-C-AYkdJJ.cjs} +11 -4
  58. package/dist/tests/{key-CDGDH_vC.mjs → key-C2Db_TAJ.mjs} +11 -3
  59. package/dist/tests/key.test.cjs +6 -5
  60. package/dist/tests/key.test.mjs +6 -4
  61. package/dist/tests/{langstr-Di5AvKpB.mjs → langstr-DYRmJqFn.mjs} +5 -2
  62. package/dist/tests/{langstr-CbAxaeEZ.cjs → langstr-_PqsL1ae.cjs} +5 -2
  63. package/dist/tests/langstr.test.cjs +11 -4
  64. package/dist/tests/langstr.test.mjs +9 -2
  65. package/dist/tests/langtag-CUppHs_s.mjs +45 -0
  66. package/dist/tests/langtag-Czjvxfzx.cjs +50 -0
  67. package/dist/tests/langtag.test.cjs +45 -0
  68. package/dist/tests/langtag.test.d.cts +1 -0
  69. package/dist/tests/langtag.test.d.mts +1 -0
  70. package/dist/tests/langtag.test.mjs +46 -0
  71. package/dist/tests/link.test.cjs +2 -3
  72. package/dist/tests/link.test.mjs +2 -2
  73. package/dist/tests/multibase/multibase.test.cjs +8 -9
  74. package/dist/tests/multibase/multibase.test.mjs +6 -6
  75. package/dist/tests/{multibase-Bz_UUDtL.cjs → multibase-B5Mea7Ip.cjs} +19 -2
  76. package/dist/tests/{multibase-B4bvakyA.mjs → multibase-BPnF_L4e.mjs} +12 -1
  77. package/dist/tests/portable-dereference-DmTYDy2p.mjs +250 -0
  78. package/dist/tests/portable-dereference-qTLMqe2_.cjs +279 -0
  79. package/dist/tests/portable-media-5p8azal0.cjs +153 -0
  80. package/dist/tests/portable-media-B_lt9MMA.mjs +148 -0
  81. package/dist/tests/portable-media.test.cjs +222 -0
  82. package/dist/tests/portable-media.test.d.cts +1 -0
  83. package/dist/tests/portable-media.test.d.mts +1 -0
  84. package/dist/tests/portable-media.test.mjs +223 -0
  85. package/dist/tests/portable-workers.test.cjs +36 -0
  86. package/dist/tests/portable-workers.test.d.cts +2 -0
  87. package/dist/tests/portable-workers.test.d.mts +2 -0
  88. package/dist/tests/portable-workers.test.mjs +35 -0
  89. package/dist/tests/{request-uk51rkhO.cjs → request-BgjA9wyl.cjs} +10 -4
  90. package/dist/tests/{request-C8CaGwtt.mjs → request-DodZNukP.mjs} +8 -2
  91. package/dist/tests/request.test.cjs +7 -4
  92. package/dist/tests/request.test.mjs +5 -2
  93. package/dist/tests/signed-representation.test.cjs +588 -0
  94. package/dist/tests/signed-representation.test.d.cts +1 -0
  95. package/dist/tests/signed-representation.test.d.mts +1 -0
  96. package/dist/tests/signed-representation.test.mjs +589 -0
  97. package/dist/tests/temporal.test.cjs +1 -2
  98. package/dist/tests/temporal.test.mjs +1 -1
  99. package/dist/tests/url-BNakuZ8k.cjs +998 -0
  100. package/dist/tests/url-DMxmp7ZG.mjs +859 -0
  101. package/dist/tests/url.test.cjs +489 -6
  102. package/dist/tests/url.test.mjs +489 -5
  103. package/dist/url-DrGTR8yv.cjs +993 -0
  104. package/dist/url-Dzyp-NsC.js +860 -0
  105. package/package.json +27 -4
  106. package/scripts/test-bun.mjs +17 -0
  107. package/src/body.test.ts +125 -0
  108. package/src/body.ts +152 -0
  109. package/src/contexts/cid-v1.json +114 -0
  110. package/src/contexts/fep-22cd.json +21 -0
  111. package/src/contexts/fep-6757.json +12 -0
  112. package/src/contexts/joinmastodon.json +1 -1
  113. package/src/contexts/miscellany.json +17 -0
  114. package/src/contexts.ts +47 -1
  115. package/src/digest.test.ts +220 -0
  116. package/src/digest.ts +229 -0
  117. package/src/docloader.test.ts +1066 -27
  118. package/src/docloader.ts +322 -105
  119. package/src/internal/jsonld-cache.ts +97 -1
  120. package/src/internal/portable-dereference.test.ts +254 -0
  121. package/src/internal/portable-dereference.ts +1000 -0
  122. package/src/internal/signed-representation.ts +565 -0
  123. package/src/jsonld-cache.test.ts +89 -0
  124. package/src/key.test.ts +9 -0
  125. package/src/key.ts +11 -1
  126. package/src/langstr.test.ts +18 -1
  127. package/src/langstr.ts +6 -2
  128. package/src/langtag.test.ts +53 -0
  129. package/src/langtag.ts +76 -0
  130. package/src/mod.ts +29 -0
  131. package/src/multibase/multibase.test.ts +5 -5
  132. package/src/portable-media.test.ts +293 -0
  133. package/src/portable-media.ts +264 -0
  134. package/src/portable-workers.test.ts +81 -0
  135. package/src/portable.ts +180 -0
  136. package/src/preprocessor.ts +7 -0
  137. package/src/request.test.ts +10 -1
  138. package/src/request.ts +9 -1
  139. package/src/signed-representation.test.ts +338 -0
  140. package/src/url.test.ts +823 -3
  141. package/src/url.ts +700 -23
  142. package/tsdown.config.ts +2 -0
  143. package/dist/tests/url-CsOV_B_P.cjs +0 -482
  144. package/dist/tests/url-Du7RQQgP.mjs +0 -392
  145. package/dist/url-DD4F0ULf.cjs +0 -483
  146. package/dist/url-DGVbSVVi.js +0 -393
  147. /package/dist/{chunk-M78iaK0I.cjs → rolldown-runtime-B7lfambq.cjs} +0 -0
  148. /package/dist/tests/{link-NUUWCdnK.mjs → link-Cevmc87v.mjs} +0 -0
  149. /package/dist/tests/{link-FguCydMA.cjs → link-DlKm8bEr.cjs} +0 -0
  150. /package/dist/tests/{multicodec-CxGVGa91.cjs → multicodec-CLRPeW4N.cjs} +0 -0
  151. /package/dist/tests/{multicodec-CyFp54fI.mjs → multicodec-CRIj_05H.mjs} +0 -0
  152. /package/dist/tests/{chunk-C2EiDwsr.cjs → rolldown-runtime-emK7D4bc.cjs} +0 -0
@@ -1,9 +1,9 @@
1
- const require_chunk = require("./chunk-C2EiDwsr.cjs");
2
- const require_langstr = require("./langstr-CbAxaeEZ.cjs");
3
- let node_assert = require("node:assert");
1
+ const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs");
2
+ const require_langstr = require("./langstr-_PqsL1ae.cjs");
4
3
  let node_test = require("node:test");
4
+ let node_assert = require("node:assert");
5
5
  let node_util = require("node:util");
6
- node_util = require_chunk.__toESM(node_util, 1);
6
+ node_util = require_rolldown_runtime.__toESM(node_util, 1);
7
7
  //#region src/langstr.test.ts
8
8
  (0, node_test.test)("new LanguageString()", () => {
9
9
  const langStr = new require_langstr.LanguageString("Hello", "en");
@@ -11,6 +11,13 @@ node_util = require_chunk.__toESM(node_util, 1);
11
11
  (0, node_assert.deepStrictEqual)(langStr.locale, new Intl.Locale("en"));
12
12
  (0, node_assert.deepStrictEqual)(new require_langstr.LanguageString("Hello", new Intl.Locale("en")), langStr);
13
13
  });
14
+ (0, node_test.test)("new LanguageString() with extlang tags", () => {
15
+ (0, node_assert.deepStrictEqual)(new require_langstr.LanguageString("你好", "zh-YUE").locale.baseName, "yue");
16
+ (0, node_assert.deepStrictEqual)(new require_langstr.LanguageString("你好", "zh-yue-HK").locale.baseName, "yue-HK");
17
+ (0, node_assert.deepStrictEqual)(new require_langstr.LanguageString("你好", "zh-cmn-Hant").locale.baseName, new Intl.Locale("cmn-Hant").baseName);
18
+ (0, node_assert.throws)(() => new require_langstr.LanguageString("Hello", "en-USA"), RangeError);
19
+ (0, node_assert.throws)(() => new require_langstr.LanguageString("你好", "zh-yue-"), RangeError);
20
+ });
14
21
  (0, node_test.test)("Deno.inspect(LanguageString)", () => {
15
22
  const langStr = new require_langstr.LanguageString("Hello, 'world'", "en");
16
23
  (0, node_assert.deepStrictEqual)(node_util.default.inspect(langStr, { colors: false }), "<en> \"Hello, 'world'\"");
@@ -1,6 +1,6 @@
1
- import { t as LanguageString } from "./langstr-Di5AvKpB.mjs";
2
- import { deepStrictEqual } from "node:assert";
1
+ import { t as LanguageString } from "./langstr-DYRmJqFn.mjs";
3
2
  import { test } from "node:test";
3
+ import { deepStrictEqual, throws } from "node:assert";
4
4
  import util from "node:util";
5
5
  //#region src/langstr.test.ts
6
6
  test("new LanguageString()", () => {
@@ -9,6 +9,13 @@ test("new LanguageString()", () => {
9
9
  deepStrictEqual(langStr.locale, new Intl.Locale("en"));
10
10
  deepStrictEqual(new LanguageString("Hello", new Intl.Locale("en")), langStr);
11
11
  });
12
+ test("new LanguageString() with extlang tags", () => {
13
+ deepStrictEqual(new LanguageString("你好", "zh-YUE").locale.baseName, "yue");
14
+ deepStrictEqual(new LanguageString("你好", "zh-yue-HK").locale.baseName, "yue-HK");
15
+ deepStrictEqual(new LanguageString("你好", "zh-cmn-Hant").locale.baseName, new Intl.Locale("cmn-Hant").baseName);
16
+ throws(() => new LanguageString("Hello", "en-USA"), RangeError);
17
+ throws(() => new LanguageString("你好", "zh-yue-"), RangeError);
18
+ });
12
19
  test("Deno.inspect(LanguageString)", () => {
13
20
  const langStr = new LanguageString("Hello, 'world'", "en");
14
21
  deepStrictEqual(util.inspect(langStr, { colors: false }), "<en> \"Hello, 'world'\"");
@@ -0,0 +1,45 @@
1
+ //#region src/langtag.ts
2
+ const EXTLANG_PAIRS = new Set(Object.entries({
3
+ ar: "aao abh abv acm acq acw acx acy adf aeb aec afb ajp apc apd arb arq ars ary arz auz avl ayh ayl ayn ayp bbz pga shu ssh",
4
+ kok: "gom knn",
5
+ lv: "ltg lvs",
6
+ ms: "bjn btj bve bvu coa dup hji jak jax kvb kvr kxd lce lcf liw max meo mfa mfb min mqg msi mui orn ors pel pse tmw urk vkk vkt xmm zlm zmi zsm",
7
+ sgn: "ads aed aen afg ajs ase asf asp asq asw bfi bfk bog bqn bqy bvl bzs cds csc csd cse csf csg csl csn csq csr csx doq dse dsl dsz dyl ecs ehs esl esn eso eth fcs fse fsl fss gds gse gsg gsm gss gus hab haf hds hks hos hps hsh hsl icl iks ils inl ins ise isg isr jcs jhs jks jls jos jsl jus kgi kvk lbs lgs lls lsb lsc lsg lsl lsn lso lsp lst lsv lsw lsy lws mdl mfs mre msd msr mzc mzg mzy nbs ncs nsi nsl nsp nsr nzs okl pgz pks prl prz psc psd psg psl pso psp psr pys rib rms rnb rsi rsl rsm rsn sdl sfb sfs sgg sgx slf sls sqk sqs sqx ssp ssr svk swl syy szs tse tsm tsq tss tsy tza ugn ugy ukl uks vgt vsi vsl vsv wbs xki xml xms yds ygs yhs ysl ysm zhk zib zsl",
8
+ sw: "swc swh",
9
+ uz: "uzn uzs",
10
+ zh: "cdo cjy cmn cnp cpx csp czh czo gan hak hnm hsn luh lzh mnp nan sjc wuu yue"
11
+ }).flatMap(([prefix, extlangs]) => extlangs.split(" ").map((extlang) => `${prefix}-${extlang}`)));
12
+ const PREFIX_PATTERN = /^[A-Za-z]{2,3}$/;
13
+ const EXTLANG_PATTERN = /^[A-Za-z]{3}$/;
14
+ /**
15
+ * Normalizes a BCP 47 language tag that has an extended language subtag
16
+ * (extlang), such as `zh-yue`, into its canonical form, such as `yue`, as
17
+ * described in [RFC 5646, Section 4.5][1]. `Intl.Locale` rejects extlang
18
+ * tags, so tags should be normalized before being passed to it.
19
+ *
20
+ * Only registered extlangs that follow their registered prefix are removed;
21
+ * any other tag is returned unchanged, so the result still needs to be
22
+ * validated, e.g., by `Intl.Locale`.
23
+ *
24
+ * NOTE: This function is marked as internal in the 2.0.x–2.4.x patch
25
+ * releases. When merging it into the *main* branch, remove the `@internal`
26
+ * tag, formalize it as a public API (`@since 2.5.0`), and add it to
27
+ * the changelog fragment.
28
+ *
29
+ * [1]: https://www.rfc-editor.org/rfc/rfc5646.html#section-4.5
30
+ *
31
+ * @param tag The BCP 47 language tag to normalize.
32
+ * @returns The normalized language tag.
33
+ * @internal
34
+ */
35
+ function normalizeLanguageTag(tag) {
36
+ const subtags = tag.split("-");
37
+ if (subtags.length < 2) return tag;
38
+ const [prefix, extlang, ...rest] = subtags;
39
+ if (!PREFIX_PATTERN.test(prefix) || !EXTLANG_PATTERN.test(extlang)) return tag;
40
+ const language = extlang.toLowerCase();
41
+ if (!EXTLANG_PAIRS.has(`${prefix.toLowerCase()}-${language}`)) return tag;
42
+ return [language, ...rest].join("-");
43
+ }
44
+ //#endregion
45
+ export { normalizeLanguageTag as t };
@@ -0,0 +1,50 @@
1
+ //#region src/langtag.ts
2
+ const EXTLANG_PAIRS = new Set(Object.entries({
3
+ ar: "aao abh abv acm acq acw acx acy adf aeb aec afb ajp apc apd arb arq ars ary arz auz avl ayh ayl ayn ayp bbz pga shu ssh",
4
+ kok: "gom knn",
5
+ lv: "ltg lvs",
6
+ ms: "bjn btj bve bvu coa dup hji jak jax kvb kvr kxd lce lcf liw max meo mfa mfb min mqg msi mui orn ors pel pse tmw urk vkk vkt xmm zlm zmi zsm",
7
+ sgn: "ads aed aen afg ajs ase asf asp asq asw bfi bfk bog bqn bqy bvl bzs cds csc csd cse csf csg csl csn csq csr csx doq dse dsl dsz dyl ecs ehs esl esn eso eth fcs fse fsl fss gds gse gsg gsm gss gus hab haf hds hks hos hps hsh hsl icl iks ils inl ins ise isg isr jcs jhs jks jls jos jsl jus kgi kvk lbs lgs lls lsb lsc lsg lsl lsn lso lsp lst lsv lsw lsy lws mdl mfs mre msd msr mzc mzg mzy nbs ncs nsi nsl nsp nsr nzs okl pgz pks prl prz psc psd psg psl pso psp psr pys rib rms rnb rsi rsl rsm rsn sdl sfb sfs sgg sgx slf sls sqk sqs sqx ssp ssr svk swl syy szs tse tsm tsq tss tsy tza ugn ugy ukl uks vgt vsi vsl vsv wbs xki xml xms yds ygs yhs ysl ysm zhk zib zsl",
8
+ sw: "swc swh",
9
+ uz: "uzn uzs",
10
+ zh: "cdo cjy cmn cnp cpx csp czh czo gan hak hnm hsn luh lzh mnp nan sjc wuu yue"
11
+ }).flatMap(([prefix, extlangs]) => extlangs.split(" ").map((extlang) => `${prefix}-${extlang}`)));
12
+ const PREFIX_PATTERN = /^[A-Za-z]{2,3}$/;
13
+ const EXTLANG_PATTERN = /^[A-Za-z]{3}$/;
14
+ /**
15
+ * Normalizes a BCP 47 language tag that has an extended language subtag
16
+ * (extlang), such as `zh-yue`, into its canonical form, such as `yue`, as
17
+ * described in [RFC 5646, Section 4.5][1]. `Intl.Locale` rejects extlang
18
+ * tags, so tags should be normalized before being passed to it.
19
+ *
20
+ * Only registered extlangs that follow their registered prefix are removed;
21
+ * any other tag is returned unchanged, so the result still needs to be
22
+ * validated, e.g., by `Intl.Locale`.
23
+ *
24
+ * NOTE: This function is marked as internal in the 2.0.x–2.4.x patch
25
+ * releases. When merging it into the *main* branch, remove the `@internal`
26
+ * tag, formalize it as a public API (`@since 2.5.0`), and add it to
27
+ * the changelog fragment.
28
+ *
29
+ * [1]: https://www.rfc-editor.org/rfc/rfc5646.html#section-4.5
30
+ *
31
+ * @param tag The BCP 47 language tag to normalize.
32
+ * @returns The normalized language tag.
33
+ * @internal
34
+ */
35
+ function normalizeLanguageTag(tag) {
36
+ const subtags = tag.split("-");
37
+ if (subtags.length < 2) return tag;
38
+ const [prefix, extlang, ...rest] = subtags;
39
+ if (!PREFIX_PATTERN.test(prefix) || !EXTLANG_PATTERN.test(extlang)) return tag;
40
+ const language = extlang.toLowerCase();
41
+ if (!EXTLANG_PAIRS.has(`${prefix.toLowerCase()}-${language}`)) return tag;
42
+ return [language, ...rest].join("-");
43
+ }
44
+ //#endregion
45
+ Object.defineProperty(exports, "normalizeLanguageTag", {
46
+ enumerable: true,
47
+ get: function() {
48
+ return normalizeLanguageTag;
49
+ }
50
+ });
@@ -0,0 +1,45 @@
1
+ const require_langtag = require("./langtag-Czjvxfzx.cjs");
2
+ let node_test = require("node:test");
3
+ let node_assert = require("node:assert");
4
+ //#region src/langtag.test.ts
5
+ (0, node_test.test)("normalizeLanguageTag() removes extlang subtags", () => {
6
+ for (const [input, expected] of [
7
+ ["zh-yue", "yue"],
8
+ ["zh-YUE", "yue"],
9
+ ["ZH-Yue-hk", "yue-hk"],
10
+ ["zh-yue-HK", "yue-HK"],
11
+ ["zh-cmn-Hant", "cmn-Hant"],
12
+ ["zh-yue-u-nu-hanidec", "yue-u-nu-hanidec"],
13
+ ["sgn-ase", "ase"],
14
+ ["ar-arz", "arz"],
15
+ ["ms-zlm", "zlm"],
16
+ ["kok-gom", "gom"],
17
+ ["koK-gom", "gom"],
18
+ ["lv-ltg", "ltg"],
19
+ ["sw-swc", "swc"],
20
+ ["uz-uzs", "uzs"],
21
+ ["zh-yue-cmn", "yue-cmn"],
22
+ ["zh-yue-", "yue-"]
23
+ ]) (0, node_assert.deepStrictEqual)(require_langtag.normalizeLanguageTag(input), expected, input);
24
+ });
25
+ (0, node_test.test)("normalizeLanguageTag() leaves other tags unchanged", () => {
26
+ for (const tag of [
27
+ "",
28
+ "en",
29
+ "en-US",
30
+ "en-USA",
31
+ "en-yue",
32
+ "zh",
33
+ "zh-Hant-TW",
34
+ "yue",
35
+ "yue-HK",
36
+ "x-private",
37
+ "i-klingon",
38
+ "zh-min-nan",
39
+ "koK-gom",
40
+ "zh-yuK",
41
+ "constructor-yue",
42
+ "toString-yue"
43
+ ]) (0, node_assert.deepStrictEqual)(require_langtag.normalizeLanguageTag(tag), tag, tag);
44
+ });
45
+ //#endregion
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,46 @@
1
+ import { t as normalizeLanguageTag } from "./langtag-CUppHs_s.mjs";
2
+ import { test } from "node:test";
3
+ import { deepStrictEqual } from "node:assert";
4
+ //#region src/langtag.test.ts
5
+ test("normalizeLanguageTag() removes extlang subtags", () => {
6
+ for (const [input, expected] of [
7
+ ["zh-yue", "yue"],
8
+ ["zh-YUE", "yue"],
9
+ ["ZH-Yue-hk", "yue-hk"],
10
+ ["zh-yue-HK", "yue-HK"],
11
+ ["zh-cmn-Hant", "cmn-Hant"],
12
+ ["zh-yue-u-nu-hanidec", "yue-u-nu-hanidec"],
13
+ ["sgn-ase", "ase"],
14
+ ["ar-arz", "arz"],
15
+ ["ms-zlm", "zlm"],
16
+ ["kok-gom", "gom"],
17
+ ["koK-gom", "gom"],
18
+ ["lv-ltg", "ltg"],
19
+ ["sw-swc", "swc"],
20
+ ["uz-uzs", "uzs"],
21
+ ["zh-yue-cmn", "yue-cmn"],
22
+ ["zh-yue-", "yue-"]
23
+ ]) deepStrictEqual(normalizeLanguageTag(input), expected, input);
24
+ });
25
+ test("normalizeLanguageTag() leaves other tags unchanged", () => {
26
+ for (const tag of [
27
+ "",
28
+ "en",
29
+ "en-US",
30
+ "en-USA",
31
+ "en-yue",
32
+ "zh",
33
+ "zh-Hant-TW",
34
+ "yue",
35
+ "yue-HK",
36
+ "x-private",
37
+ "i-klingon",
38
+ "zh-min-nan",
39
+ "koK-gom",
40
+ "zh-yuK",
41
+ "constructor-yue",
42
+ "toString-yue"
43
+ ]) deepStrictEqual(normalizeLanguageTag(tag), tag, tag);
44
+ });
45
+ //#endregion
46
+ export {};
@@ -1,7 +1,6 @@
1
- require("./chunk-C2EiDwsr.cjs");
2
- const require_link = require("./link-FguCydMA.cjs");
3
- let node_assert = require("node:assert");
1
+ const require_link = require("./link-DlKm8bEr.cjs");
4
2
  let node_test = require("node:test");
3
+ let node_assert = require("node:assert");
5
4
  //#region src/link.test.ts
6
5
  (0, node_test.test)("String Good 1", () => {
7
6
  const instance = new require_link.HttpHeaderLink(`<https://example.com>; rel="preconnect"`);
@@ -1,6 +1,6 @@
1
- import { t as HttpHeaderLink } from "./link-NUUWCdnK.mjs";
2
- import { deepStrictEqual, throws } from "node:assert";
1
+ import { t as HttpHeaderLink } from "./link-Cevmc87v.mjs";
3
2
  import { test } from "node:test";
3
+ import { deepStrictEqual, throws } from "node:assert";
4
4
  //#region src/link.test.ts
5
5
  test("String Good 1", () => {
6
6
  const instance = new HttpHeaderLink(`<https://example.com>; rel="preconnect"`);
@@ -1,9 +1,8 @@
1
- require("../chunk-C2EiDwsr.cjs");
2
- const require_multibase = require("../multibase-Bz_UUDtL.cjs");
1
+ const require_multibase = require("../multibase-B5Mea7Ip.cjs");
3
2
  let node_assert = require("node:assert");
4
- let node_test = require("node:test");
3
+ let _fedify_fixture = require("@fedify/fixture");
5
4
  //#region src/multibase/multibase.test.ts
6
- (0, node_test.test)("multibase.encode and decode", async (t) => {
5
+ (0, _fedify_fixture.test)("multibase.encode and decode", async (t) => {
7
6
  const testCases = [
8
7
  [
9
8
  "base16",
@@ -316,22 +315,22 @@ let node_test = require("node:test");
316
315
  "Uw7fDr8O_8J-lsMO3w6_Dv_CfmI7wn6W28J-krw=="
317
316
  ]
318
317
  ];
319
- for (const [name, input, expectedOutput] of testCases) await t.test(`Encoding/Decoding ${name} with ${input}`, () => {
318
+ for (const [name, input, expectedOutput] of testCases) await t.step(`Encoding/Decoding ${name} with ${input}`, () => {
320
319
  (0, node_assert.deepStrictEqual)(require_multibase.decodeText(require_multibase.encodeMultibase(name, require_multibase.encodeText(input))), expectedOutput, `Encoding ${name} failed`);
321
320
  (0, node_assert.deepStrictEqual)(require_multibase.decodeMultibase(expectedOutput), require_multibase.encodeText(input), `Decoding ${name} failed`);
322
321
  (0, node_assert.deepStrictEqual)(require_multibase.decodeMultibase(require_multibase.encodeText(expectedOutput)), require_multibase.encodeText(input), `Decoding buffer of ${name} failed`);
323
322
  });
324
- await t.test("should allow base32pad full alphabet", () => {
323
+ await t.step("should allow base32pad full alphabet", () => {
325
324
  const decoded = require_multibase.decodeMultibase("ctimaq4ygg2iegci7");
326
325
  (0, node_assert.deepStrictEqual)(require_multibase.decodeMultibase(require_multibase.encodeMultibase("c", decoded)), decoded);
327
326
  });
328
327
  });
329
- (0, node_test.test)("constants", async (t) => {
330
- await t.test("constants indexed by name", () => {
328
+ (0, _fedify_fixture.test)("constants", async (t) => {
329
+ await t.step("constants indexed by name", () => {
331
330
  const names$1 = require_multibase.names;
332
331
  (0, node_assert.deepStrictEqual)(Object.keys(names$1).length, 23);
333
332
  });
334
- await t.test("constants indexed by code", () => {
333
+ await t.step("constants indexed by code", () => {
335
334
  const codes$1 = require_multibase.codes;
336
335
  (0, node_assert.deepStrictEqual)(Object.keys(codes$1).length, 23);
337
336
  });
@@ -1,6 +1,6 @@
1
- import { a as decodeText, i as names, n as encodeMultibase, o as encodeText, r as codes, t as decodeMultibase } from "../multibase-B4bvakyA.mjs";
1
+ import { a as names, i as codes, n as encodeMultibase, o as decodeText, s as encodeText, t as decodeMultibase } from "../multibase-BPnF_L4e.mjs";
2
2
  import { deepStrictEqual } from "node:assert";
3
- import { test } from "node:test";
3
+ import { test } from "@fedify/fixture";
4
4
  //#region src/multibase/multibase.test.ts
5
5
  test("multibase.encode and decode", async (t) => {
6
6
  const testCases = [
@@ -315,21 +315,21 @@ test("multibase.encode and decode", async (t) => {
315
315
  "Uw7fDr8O_8J-lsMO3w6_Dv_CfmI7wn6W28J-krw=="
316
316
  ]
317
317
  ];
318
- for (const [name, input, expectedOutput] of testCases) await t.test(`Encoding/Decoding ${name} with ${input}`, () => {
318
+ for (const [name, input, expectedOutput] of testCases) await t.step(`Encoding/Decoding ${name} with ${input}`, () => {
319
319
  deepStrictEqual(decodeText(encodeMultibase(name, encodeText(input))), expectedOutput, `Encoding ${name} failed`);
320
320
  deepStrictEqual(decodeMultibase(expectedOutput), encodeText(input), `Decoding ${name} failed`);
321
321
  deepStrictEqual(decodeMultibase(encodeText(expectedOutput)), encodeText(input), `Decoding buffer of ${name} failed`);
322
322
  });
323
- await t.test("should allow base32pad full alphabet", () => {
323
+ await t.step("should allow base32pad full alphabet", () => {
324
324
  const decoded = decodeMultibase("ctimaq4ygg2iegci7");
325
325
  deepStrictEqual(decodeMultibase(encodeMultibase("c", decoded)), decoded);
326
326
  });
327
327
  });
328
328
  test("constants", async (t) => {
329
- await t.test("constants indexed by name", () => {
329
+ await t.step("constants indexed by name", () => {
330
330
  deepStrictEqual(Object.keys(names).length, 23);
331
331
  });
332
- await t.test("constants indexed by code", () => {
332
+ await t.step("constants indexed by code", () => {
333
333
  deepStrictEqual(Object.keys(codes).length, 23);
334
334
  });
335
335
  });
@@ -1,6 +1,6 @@
1
- const require_chunk = require("./chunk-C2EiDwsr.cjs");
1
+ const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs");
2
2
  let _multiformats_base_x = require("@multiformats/base-x");
3
- _multiformats_base_x = require_chunk.__toESM(_multiformats_base_x, 1);
3
+ _multiformats_base_x = require_rolldown_runtime.__toESM(_multiformats_base_x, 1);
4
4
  //#region src/multibase/util.ts
5
5
  const textDecoder = new TextDecoder();
6
6
  const decodeText = (bytes) => textDecoder.decode(bytes);
@@ -305,6 +305,17 @@ function encoding(nameOrCode) {
305
305
  else if (Object.prototype.hasOwnProperty.call(codes, nameOrCode)) return codes[nameOrCode];
306
306
  else throw new Error(`Unsupported encoding: ${nameOrCode}`);
307
307
  }
308
+ /**
309
+ * Get encoding multibase from data
310
+ *
311
+ * @param {string|Uint8Array} data
312
+ * @returns {Base}
313
+ * @throws {Error} Will throw if the encoding is not supported
314
+ */
315
+ function encodingFromBaseData(data) {
316
+ if (data instanceof Uint8Array) data = decodeText(data);
317
+ return encoding(data[0]);
318
+ }
308
319
  //#endregion
309
320
  Object.defineProperty(exports, "codes", {
310
321
  enumerable: true,
@@ -336,6 +347,12 @@ Object.defineProperty(exports, "encodeText", {
336
347
  return encodeText;
337
348
  }
338
349
  });
350
+ Object.defineProperty(exports, "encodingFromBaseData", {
351
+ enumerable: true,
352
+ get: function() {
353
+ return encodingFromBaseData;
354
+ }
355
+ });
339
356
  Object.defineProperty(exports, "names", {
340
357
  enumerable: true,
341
358
  get: function() {
@@ -303,5 +303,16 @@ function encoding(nameOrCode) {
303
303
  else if (Object.prototype.hasOwnProperty.call(codes, nameOrCode)) return codes[nameOrCode];
304
304
  else throw new Error(`Unsupported encoding: ${nameOrCode}`);
305
305
  }
306
+ /**
307
+ * Get encoding multibase from data
308
+ *
309
+ * @param {string|Uint8Array} data
310
+ * @returns {Base}
311
+ * @throws {Error} Will throw if the encoding is not supported
312
+ */
313
+ function encodingFromBaseData(data) {
314
+ if (data instanceof Uint8Array) data = decodeText(data);
315
+ return encoding(data[0]);
316
+ }
306
317
  //#endregion
307
- export { decodeText as a, names as i, encodeMultibase as n, encodeText as o, codes as r, decodeMultibase as t };
318
+ export { names as a, codes as i, encodeMultibase as n, decodeText as o, encodingFromBaseData as r, encodeText as s, decodeMultibase as t };
@@ -0,0 +1,250 @@
1
+ import { t as preloadedContexts } from "./contexts-duRA_dDC.mjs";
2
+ import { h as parseGatewayOrigin, o as formatIri, s as fromCompatibleEf61Id, t as GATEWAY_HINT_PARAMETER, u as haveSameFe34Origin } from "./url-DMxmp7ZG.mjs";
3
+ import "./jsonld-DweIJ07b.mjs";
4
+ import { c as unwrapReleasedDocumentLoader, s as registerDocumentLoaderWrapper } from "./jsonld-cache-DFnWsLuZ.mjs";
5
+ import { getLogger } from "@logtape/logtape";
6
+ import "@opentelemetry/api";
7
+ //#region src/internal/portable-dereference.ts
8
+ const logger = getLogger([
9
+ "fedify",
10
+ "vocab",
11
+ "gateway"
12
+ ]);
13
+ /**
14
+ * The maximum number of `@gateway` location hints to try for one reference.
15
+ * Hints come from possibly untrusted documents, so they are bounded to keep
16
+ * a single accessor call from fanning out to many servers.
17
+ */
18
+ const MAX_GATEWAY_HINTS = 5;
19
+ const BASELINE_CONTEXT_URLS = /* @__PURE__ */ new Set([
20
+ "https://w3id.org/identity/v1",
21
+ "https://www.w3.org/ns/activitystreams",
22
+ "https://w3id.org/security/v1",
23
+ "https://w3id.org/security/data-integrity/v1"
24
+ ]);
25
+ const provenances = /* @__PURE__ */ new WeakMap();
26
+ function getObjectId(object) {
27
+ if (object == null || typeof object !== "object" || !("id" in object)) return null;
28
+ const id = object.id;
29
+ return id instanceof URL ? id : null;
30
+ }
31
+ /**
32
+ * Checks whether a vocabulary object is part of a chain of portable objects,
33
+ * i.e., whether it has a portable ID, has an FEP-ef61 compatible identifier
34
+ * as its ID (even a malformed one, so that it fails closed), or was obtained
35
+ * from a portable object. Accessors of such objects dereference references
36
+ * as portable objects.
37
+ *
38
+ * Being part of a chain does not mean that the object itself is verified:
39
+ * an object parsed from arbitrary JSON-LD is in a chain just because of its
40
+ * ID. Only {@link dereferencePortableIri} records that an object was
41
+ * accepted by a verifier.
42
+ *
43
+ * @internal Technically exported for generated vocabulary classes, but not
44
+ * part of the public API contract. This is not considered public API for
45
+ * Semantic Versioning decisions.
46
+ */
47
+ function isInPortableChain(object) {
48
+ if (provenances.has(object)) return true;
49
+ const id = getObjectId(object);
50
+ return id != null && (isPortableIri(id) || isCompatibleEf61Iri(id));
51
+ }
52
+ /**
53
+ * Checks whether a URL is an FEP-ef61 compatible identifier, i.e., an HTTP(S)
54
+ * URL under a gateway's `/.well-known/apgateway/` path that stands for
55
+ * a portable object. Malformed compatible identifiers count as compatible
56
+ * identifiers too.
57
+ *
58
+ * @internal Technically exported for generated vocabulary classes, but not
59
+ * part of the public API contract. This is not considered public API for
60
+ * Semantic Versioning decisions.
61
+ */
62
+ function isCompatibleEf61Iri(url) {
63
+ try {
64
+ return fromCompatibleEf61Id(url) != null;
65
+ } catch (error) {
66
+ if (error instanceof TypeError) return true;
67
+ throw error;
68
+ }
69
+ }
70
+ /**
71
+ * Records that a vocabulary object returned by a property accessor was
72
+ * obtained through the given property of a portable object, so that later
73
+ * dereferences from it can tell where it came from. Nothing is recorded if
74
+ * the parent is not in a portable chain, or if the child already has its
75
+ * provenance.
76
+ *
77
+ * @internal Technically exported for generated vocabulary classes, but not
78
+ * part of the public API contract. This is not considered public API for
79
+ * Semantic Versioning decisions.
80
+ */
81
+ function recordPortableReferrer(parent, child, property) {
82
+ if (child == null || typeof child !== "object") return;
83
+ if (provenances.has(child) || !isInPortableChain(parent)) return;
84
+ provenances.set(child, { referrer: {
85
+ object: parent,
86
+ property
87
+ } });
88
+ }
89
+ /**
90
+ * Checks whether a URL is an FEP-ef61 portable ActivityPub IRI.
91
+ *
92
+ * @internal Technically exported for generated vocabulary classes, but not
93
+ * part of the public API contract. This is not considered public API for
94
+ * Semantic Versioning decisions.
95
+ */
96
+ function isPortableIri(url) {
97
+ return url.protocol === "ap+ef61:" || url.protocol === "ap:";
98
+ }
99
+ /**
100
+ * Picks the ordered list of FEP-ef61 gateways to fetch a portable IRI from.
101
+ *
102
+ * If `gateways` is given, it is used as is (even when empty), and `@gateway`
103
+ * location hints in the IRI are ignored. Otherwise, up to
104
+ * {@link MAX_GATEWAY_HINTS} valid `@gateway` hints are used. Duplicate
105
+ * gateways are dropped in both cases.
106
+ *
107
+ * @throws {TypeError} If an explicit gateway is not an HTTP(S) origin.
108
+ * @internal
109
+ */
110
+ function getPortableGatewayCandidates(url, gateways) {
111
+ const candidates = [];
112
+ const seen = /* @__PURE__ */ new Set();
113
+ const add = (gateway) => {
114
+ if (seen.has(gateway.href)) return;
115
+ seen.add(gateway.href);
116
+ candidates.push(gateway);
117
+ };
118
+ if (gateways != null) {
119
+ for (const gateway of gateways) {
120
+ const parsed = parseGatewayOrigin(gateway);
121
+ if (parsed == null) throw new TypeError("FEP-ef61 gateways must be HTTP(S) origins with no credentials, path, query, or fragment: " + String(gateway));
122
+ add(parsed);
123
+ }
124
+ return candidates;
125
+ }
126
+ for (const hint of new URLSearchParams(url.search).getAll(GATEWAY_HINT_PARAMETER)) {
127
+ if (candidates.length >= MAX_GATEWAY_HINTS) break;
128
+ const parsed = parseGatewayOrigin(hint);
129
+ if (parsed == null) {
130
+ logger.debug("Ignoring an invalid FEP-ef61 gateway hint {hint} in {url}.", {
131
+ hint,
132
+ url: formatIri(url)
133
+ });
134
+ continue;
135
+ }
136
+ add(parsed);
137
+ }
138
+ return candidates;
139
+ }
140
+ /**
141
+ * Gets the gateways through which a portable reference without location hints
142
+ * can be dereferenced, from the portable actor that the reference belongs to.
143
+ *
144
+ * The references in a portable actor's own document, such as its `outbox`,
145
+ * usually have no `@gateway` hints, as they are not needed there, since
146
+ * the actor's `gateways` already tells where to retrieve them. So this walks
147
+ * from the object whose property is being dereferenced up through the objects
148
+ * it was obtained from, e.g., from a collection page to the collection and
149
+ * then to the actor, and returns the `gateways` of the first object that has
150
+ * any, but only if that object has the same DID as the reference. The
151
+ * gateways only tell where to look; whatever they serve is still verified.
152
+ *
153
+ * @param object The object whose property is being dereferenced.
154
+ * @param url The portable IRI to dereference.
155
+ * @returns Up to {@link MAX_GATEWAY_HINTS} valid gateways, or `undefined` if
156
+ * the IRI has valid `@gateway` hints or no such object is found.
157
+ * @internal Technically exported for generated vocabulary classes, but not
158
+ * part of the public API contract. This is not considered public API for
159
+ * Semantic Versioning decisions.
160
+ */
161
+ function getReferrerGateways(object, url) {
162
+ if (getPortableGatewayCandidates(url).length > 0) return void 0;
163
+ const visited = /* @__PURE__ */ new Set();
164
+ let current = object;
165
+ while (current != null && !visited.has(current)) {
166
+ visited.add(current);
167
+ const gateways = "gateways" in current ? current.gateways : void 0;
168
+ if (Array.isArray(gateways) && gateways.length > 0) {
169
+ const id = getObjectId(current);
170
+ const portableId = id == null ? null : isPortableIri(id) ? id : getCompatibleEf61Target(id);
171
+ if (portableId == null || !haveSameFe34Origin(portableId, url)) return;
172
+ const candidates = [];
173
+ for (const gateway of gateways) {
174
+ if (candidates.length >= MAX_GATEWAY_HINTS) break;
175
+ if (typeof gateway !== "string" && !(gateway instanceof URL)) continue;
176
+ const parsed = parseGatewayOrigin(gateway);
177
+ if (parsed == null) continue;
178
+ if (candidates.some((c) => c.href === parsed.href)) continue;
179
+ candidates.push(parsed);
180
+ }
181
+ return candidates.length > 0 ? candidates : void 0;
182
+ }
183
+ current = provenances.get(current)?.referrer?.object;
184
+ }
185
+ }
186
+ function getCompatibleEf61Target(id) {
187
+ try {
188
+ return fromCompatibleEf61Id(id);
189
+ } catch {
190
+ return null;
191
+ }
192
+ }
193
+ /**
194
+ * Creates a context loader that returns the same context documents for the
195
+ * whole dereference operation, so that the identity check, the proof
196
+ * verifier, and the parser interpret the fetched document identically even
197
+ * if the underlying loader is nondeterministic. Failed loads are not
198
+ * remembered, so a transient failure does not affect the next gateway.
199
+ *
200
+ * The parsed object keeps the loader for its own later dereferences, so
201
+ * `release()` turns it into a plain pass-through to the underlying loader
202
+ * once the operation is over.
203
+ *
204
+ * @internal Technically exported for generated vocabulary classes, but not
205
+ * part of the public API contract. This is not considered public API for
206
+ * Semantic Versioning decisions.
207
+ */
208
+ function createSnapshotContextLoader(contextLoader, suppressError) {
209
+ contextLoader = unwrapReleasedDocumentLoader(contextLoader);
210
+ const cache = /* @__PURE__ */ new Map();
211
+ let released = false;
212
+ const release = () => {
213
+ released = true;
214
+ state.released = true;
215
+ cache.clear();
216
+ };
217
+ const loader = async (url, options) => {
218
+ if (released) return await contextLoader(url, options);
219
+ const key = URL.canParse(url) ? new URL(url).href : url;
220
+ if (BASELINE_CONTEXT_URLS.has(key)) return {
221
+ contextUrl: null,
222
+ document: structuredClone(preloadedContexts[key]),
223
+ documentUrl: key
224
+ };
225
+ let promise = cache.get(key);
226
+ if (promise == null) {
227
+ const loading = contextLoader(url, suppressError ? {
228
+ ...options,
229
+ suppressError: true
230
+ } : options).then((document) => structuredClone(document));
231
+ promise = loading;
232
+ cache.set(key, loading);
233
+ loading.catch(() => {
234
+ if (cache.get(key) === loading) cache.delete(key);
235
+ });
236
+ }
237
+ return structuredClone(await promise);
238
+ };
239
+ const state = {
240
+ base: contextLoader,
241
+ released: false
242
+ };
243
+ registerDocumentLoaderWrapper(loader, state);
244
+ return {
245
+ loader,
246
+ release
247
+ };
248
+ }
249
+ //#endregion
250
+ export { recordPortableReferrer as a, isPortableIri as i, getPortableGatewayCandidates as n, getReferrerGateways as r, createSnapshotContextLoader as t };