@fedify/vocab-runtime 2.4.0 → 2.4.2-dev.2347

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 (74) hide show
  1. package/deno.json +1 -1
  2. package/dist/{contexts-BK1CqBR5.cjs → contexts-B09jb9Pi.cjs} +11 -1
  3. package/dist/{contexts-DPuJ4UYL.js → contexts-DWrj4AGR.js} +11 -1
  4. package/dist/{docloader-CYwqh5Df.d.cts → docloader-BMHljyYb.d.cts} +2 -0
  5. package/dist/{docloader-CYwqh5Df.d.ts → docloader-BMHljyYb.d.ts} +2 -0
  6. package/dist/internal/jsonld-cache.d.cts +1 -1
  7. package/dist/internal/jsonld-cache.d.ts +1 -1
  8. package/dist/internal/portable-dereference.cjs +1 -1
  9. package/dist/internal/portable-dereference.d.cts +2 -2
  10. package/dist/internal/portable-dereference.d.ts +2 -2
  11. package/dist/internal/portable-dereference.js +1 -1
  12. package/dist/internal/signed-representation.cjs +1 -1
  13. package/dist/internal/signed-representation.js +1 -1
  14. package/dist/mod.cjs +53 -4
  15. package/dist/mod.d.cts +30 -4
  16. package/dist/mod.d.ts +30 -4
  17. package/dist/mod.js +53 -5
  18. package/dist/{portable-DqtfLy_1.d.cts → portable-6Aj-7dZJ.d.cts} +1 -1
  19. package/dist/{portable-DtWsu2yU.d.ts → portable-nkTiqH0w.d.ts} +1 -1
  20. package/dist/tests/{body-CkEwROsn.cjs → body-Bywt95mV.cjs} +1 -1
  21. package/dist/tests/{body-CYiu9CO-.mjs → body-DhoKpS4i.mjs} +1 -1
  22. package/dist/tests/body.test.cjs +1 -1
  23. package/dist/tests/body.test.mjs +1 -1
  24. package/dist/tests/{contexts-DizzBjz4.cjs → contexts-C9Lj11SC.cjs} +11 -1
  25. package/dist/tests/{contexts-CIKsin4e.mjs → contexts-duRA_dDC.mjs} +11 -1
  26. package/dist/tests/decimal.test.cjs +4 -3
  27. package/dist/tests/decimal.test.mjs +4 -3
  28. package/dist/tests/{docloader-CvmS4sVq.mjs → docloader-F9eibtd-.mjs} +5 -3
  29. package/dist/tests/{docloader-C3YFl6y4.cjs → docloader-hc9ofEeM.cjs} +5 -3
  30. package/dist/tests/docloader.test.cjs +127 -3
  31. package/dist/tests/docloader.test.mjs +127 -3
  32. package/dist/tests/internal/portable-dereference.test.cjs +2 -2
  33. package/dist/tests/internal/portable-dereference.test.mjs +2 -2
  34. package/dist/tests/jsonld-CmDhHNTx.cjs +12 -0
  35. package/dist/tests/jsonld-DweIJ07b.mjs +5 -0
  36. package/dist/tests/{jsonld-cache-C07AyNOY.cjs → jsonld-cache-BEXiiM-V.cjs} +6 -17
  37. package/dist/tests/{jsonld-cache-BPQmOZWD.mjs → jsonld-cache-DFnWsLuZ.mjs} +2 -5
  38. package/dist/tests/jsonld-cache.test.cjs +13 -12
  39. package/dist/tests/jsonld-cache.test.mjs +2 -1
  40. package/dist/tests/{langstr-CQ26J_L7.mjs → langstr-DYRmJqFn.mjs} +5 -2
  41. package/dist/tests/{langstr-C4Fl80ae.cjs → langstr-_PqsL1ae.cjs} +5 -2
  42. package/dist/tests/langstr.test.cjs +8 -1
  43. package/dist/tests/langstr.test.mjs +9 -2
  44. package/dist/tests/langtag-CUppHs_s.mjs +45 -0
  45. package/dist/tests/langtag-Czjvxfzx.cjs +50 -0
  46. package/dist/tests/langtag.test.cjs +45 -0
  47. package/dist/tests/langtag.test.d.cts +1 -0
  48. package/dist/tests/langtag.test.d.mts +1 -0
  49. package/dist/tests/langtag.test.mjs +46 -0
  50. package/dist/tests/{portable-dereference-DRE5bz-l.mjs → portable-dereference-DmTYDy2p.mjs} +3 -2
  51. package/dist/tests/{portable-dereference-BNXtgg5U.cjs → portable-dereference-qTLMqe2_.cjs} +3 -2
  52. package/dist/tests/{portable-media-BLKllU56.cjs → portable-media-9D7T-9in.cjs} +2 -2
  53. package/dist/tests/{portable-media-DRSGBORB.mjs → portable-media-DBxgc6mz.mjs} +2 -2
  54. package/dist/tests/portable-media.test.cjs +1 -1
  55. package/dist/tests/portable-media.test.mjs +1 -1
  56. package/dist/tests/portable-workers.test.cjs +1 -1
  57. package/dist/tests/portable-workers.test.mjs +1 -1
  58. package/dist/tests/{request-8vPWtV1-.cjs → request-BgjEQaAz.cjs} +1 -1
  59. package/dist/tests/{request-DRaOaTqD.mjs → request-CVzAcZiq.mjs} +1 -1
  60. package/dist/tests/request.test.cjs +1 -1
  61. package/dist/tests/request.test.mjs +1 -1
  62. package/dist/tests/signed-representation.test.cjs +1 -1
  63. package/dist/tests/signed-representation.test.mjs +1 -1
  64. package/package.json +1 -1
  65. package/src/contexts/fep-6757.json +12 -0
  66. package/src/contexts/joinmastodon.json +1 -1
  67. package/src/contexts.ts +8 -0
  68. package/src/docloader.test.ts +148 -0
  69. package/src/docloader.ts +2 -0
  70. package/src/langstr.test.ts +18 -1
  71. package/src/langstr.ts +6 -2
  72. package/src/langtag.test.ts +53 -0
  73. package/src/langtag.ts +76 -0
  74. package/src/mod.ts +1 -0
@@ -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,6 +1,7 @@
1
- import { t as preloadedContexts } from "./contexts-CIKsin4e.mjs";
1
+ import { t as preloadedContexts } from "./contexts-duRA_dDC.mjs";
2
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 { c as unwrapReleasedDocumentLoader, s as registerDocumentLoaderWrapper } from "./jsonld-cache-BPQmOZWD.mjs";
3
+ import "./jsonld-DweIJ07b.mjs";
4
+ import { c as unwrapReleasedDocumentLoader, s as registerDocumentLoaderWrapper } from "./jsonld-cache-DFnWsLuZ.mjs";
4
5
  import { getLogger } from "@logtape/logtape";
5
6
  import "@opentelemetry/api";
6
7
  //#region src/internal/portable-dereference.ts
@@ -1,6 +1,7 @@
1
- const require_contexts = require("./contexts-DizzBjz4.cjs");
1
+ const require_contexts = require("./contexts-C9Lj11SC.cjs");
2
2
  const require_url = require("./url-BNakuZ8k.cjs");
3
- const require_jsonld_cache = require("./jsonld-cache-C07AyNOY.cjs");
3
+ require("./jsonld-CmDhHNTx.cjs");
4
+ const require_jsonld_cache = require("./jsonld-cache-BEXiiM-V.cjs");
4
5
  let _logtape_logtape = require("@logtape/logtape");
5
6
  require("@opentelemetry/api");
6
7
  //#region src/internal/portable-dereference.ts
@@ -1,5 +1,5 @@
1
- const require_request = require("./request-8vPWtV1-.cjs");
2
- const require_body = require("./body-CkEwROsn.cjs");
1
+ const require_request = require("./request-BgjEQaAz.cjs");
2
+ const require_body = require("./body-Bywt95mV.cjs");
3
3
  const require_url = require("./url-BNakuZ8k.cjs");
4
4
  const require_digest = require("./digest-3FeH2Y-Q.cjs");
5
5
  //#region src/portable-media.ts
@@ -1,5 +1,5 @@
1
- import { r as getUserAgent } from "./request-DRaOaTqD.mjs";
2
- import { r as readBoundedBytes } from "./body-CYiu9CO-.mjs";
1
+ import { r as getUserAgent } from "./request-CVzAcZiq.mjs";
2
+ import { r as readBoundedBytes } from "./body-DhoKpS4i.mjs";
3
3
  import { g as parseGatewayUrl, x as validatePublicUrl } from "./url-DMxmp7ZG.mjs";
4
4
  import { a as verifyDigestMultibase, i as parseHashlink, r as parseDigestMultibase } from "./digest-COC7xDiQ.mjs";
5
5
  //#region src/portable-media.ts
@@ -1,5 +1,5 @@
1
1
  const require_digest = require("./digest-3FeH2Y-Q.cjs");
2
- const require_portable_media = require("./portable-media-BLKllU56.cjs");
2
+ const require_portable_media = require("./portable-media-9D7T-9in.cjs");
3
3
  let node_assert_strict = require("node:assert/strict");
4
4
  let node_test = require("node:test");
5
5
  let node_http = require("node:http");
@@ -1,5 +1,5 @@
1
1
  import { n as createHashlink, t as computeDigestMultibase } from "./digest-COC7xDiQ.mjs";
2
- import { t as fetchPortableMedia } from "./portable-media-DRSGBORB.mjs";
2
+ import { t as fetchPortableMedia } from "./portable-media-DBxgc6mz.mjs";
3
3
  import { deepStrictEqual, equal, rejects } from "node:assert/strict";
4
4
  import { test } from "node:test";
5
5
  import { createServer } from "node:http";
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_url = require("./url-BNakuZ8k.cjs");
3
3
  const require_key = require("./key-C-AYkdJJ.cjs");
4
4
  const require_digest = require("./digest-3FeH2Y-Q.cjs");
5
- const require_portable_dereference = require("./portable-dereference-BNXtgg5U.cjs");
5
+ const require_portable_dereference = require("./portable-dereference-qTLMqe2_.cjs");
6
6
  let node_assert_strict = require("node:assert/strict");
7
7
  let _fedify_fixture = require("@fedify/fixture");
8
8
  //#region src/portable-workers.test.ts
@@ -1,7 +1,7 @@
1
1
  import { _ as parseIri, i as canonicalizePortableUri, o as formatIri, s as fromCompatibleEf61Id, y as toCompatibleEf61Id } from "./url-DMxmp7ZG.mjs";
2
2
  import { i as importDidKey, t as exportDidKey } from "./key-C2Db_TAJ.mjs";
3
3
  import { n as createHashlink, o as verifyHashlink, t as computeDigestMultibase } from "./digest-COC7xDiQ.mjs";
4
- import { n as getPortableGatewayCandidates } from "./portable-dereference-DRE5bz-l.mjs";
4
+ import { n as getPortableGatewayCandidates } from "./portable-dereference-DmTYDy2p.mjs";
5
5
  import { deepStrictEqual, equal } from "node:assert/strict";
6
6
  import { test, testDefinitions } from "@fedify/fixture";
7
7
  //#region src/portable-workers.test.ts
@@ -3,7 +3,7 @@ let node_process = require("node:process");
3
3
  node_process = require_rolldown_runtime.__toESM(node_process, 1);
4
4
  //#region deno.json
5
5
  var name = "@fedify/vocab-runtime";
6
- var version = "2.4.0";
6
+ var version = "2.4.2-dev.2347+09a41add";
7
7
  //#endregion
8
8
  //#region src/request.ts
9
9
  /**
@@ -1,7 +1,7 @@
1
1
  import process from "node:process";
2
2
  //#region deno.json
3
3
  var name = "@fedify/vocab-runtime";
4
- var version = "2.4.0";
4
+ var version = "2.4.2-dev.2347+09a41add";
5
5
  //#endregion
6
6
  //#region src/request.ts
7
7
  /**
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs");
2
- const require_request = require("./request-8vPWtV1-.cjs");
2
+ const require_request = require("./request-BgjEQaAz.cjs");
3
3
  let node_test = require("node:test");
4
4
  let node_process = require("node:process");
5
5
  node_process = require_rolldown_runtime.__toESM(node_process, 1);
@@ -1,4 +1,4 @@
1
- import { n as createActivityPubRequest, o as version, r as getUserAgent } from "./request-DRaOaTqD.mjs";
1
+ import { n as createActivityPubRequest, o as version, r as getUserAgent } from "./request-CVzAcZiq.mjs";
2
2
  import { test } from "node:test";
3
3
  import process from "node:process";
4
4
  import { deepStrictEqual } from "node:assert";
@@ -1,4 +1,4 @@
1
- const require_contexts = require("./contexts-DizzBjz4.cjs");
1
+ const require_contexts = require("./contexts-C9Lj11SC.cjs");
2
2
  let node_test = require("node:test");
3
3
  let node_assert = require("node:assert");
4
4
  //#region src/internal/signed-representation.ts
@@ -1,4 +1,4 @@
1
- import { t as preloadedContexts } from "./contexts-CIKsin4e.mjs";
1
+ import { t as preloadedContexts } from "./contexts-duRA_dDC.mjs";
2
2
  import { test } from "node:test";
3
3
  import { deepStrictEqual, ok, strictEqual, throws } from "node:assert";
4
4
  //#region src/internal/signed-representation.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-runtime",
3
- "version": "2.4.0",
3
+ "version": "2.4.2-dev.2347+09a41add",
4
4
  "homepage": "https://fedify.dev/",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,12 @@
1
+ {
2
+ "@context": {
3
+ "license": {
4
+ "@id": "http://purl.org/dc/terms/license",
5
+ "@type": "@id"
6
+ },
7
+ "preferredLicense": {
8
+ "@id": "https://w3id.org/fep/6757#preferredLicense",
9
+ "@type": "@id"
10
+ }
11
+ }
12
+ }
@@ -22,7 +22,7 @@
22
22
  "suspended": "toot:suspended",
23
23
  "attributionDomains": {
24
24
  "@id": "toot:attributionDomains",
25
- "@type": "@id"
25
+ "@container": "@set"
26
26
  }
27
27
  }
28
28
  }
package/src/contexts.ts CHANGED
@@ -9,6 +9,7 @@ import cidV1Context from "./contexts/cid-v1.json" with { type: "json" };
9
9
  import didV1 from "./contexts/did-v1.json" with { type: "json" };
10
10
  import fep22cd from "./contexts/fep-22cd.json" with { type: "json" };
11
11
  import fep5711 from "./contexts/fep-5711.json" with { type: "json" };
12
+ import fep6757 from "./contexts/fep-6757.json" with { type: "json" };
12
13
  import fep7aa9 from "./contexts/fep-7aa9.json" with { type: "json" };
13
14
  import fepEf61 from "./contexts/fep-ef61.json" with { type: "json" };
14
15
  import gotosocial from "./contexts/gotosocial.json" with { type: "json" };
@@ -66,6 +67,13 @@ const preloadedContexts: Record<string, unknown> = {
66
67
  // https://github.com/fedify-dev/fedify/issues/1078
67
68
  "https://w3id.org/fep/7aa9": fep7aa9,
68
69
 
70
+ // The FEP-6757 context is hosted on Codeberg Pages, whose outages can
71
+ // prevent documents with license metadata from being parsed. Resolve it
72
+ // locally so parsing does not depend on the remote context server.
73
+ // See: https://w3id.org/fep/6757
74
+ // https://github.com/fedify-dev/fedify/issues/1211
75
+ "https://w3id.org/fep/6757": fep6757,
76
+
69
77
  // Lemmy's context document is served as application/json without the JSON-LD
70
78
  // context Link header. The default document loader treats that as a regular
71
79
  // JSON response instead of a JSON-LD context, so every Lemmy activity that
@@ -17,6 +17,7 @@ import {
17
17
  resolveDocumentLoaderTimeout,
18
18
  withDocumentLoaderTimeout,
19
19
  } from "./docloader.ts";
20
+ import jsonld from "./jsonld.ts";
20
21
  import { FetchError } from "./request.ts";
21
22
  import { UrlError } from "./url.ts";
22
23
 
@@ -477,6 +478,30 @@ test("getDocumentLoader()", async (t) => {
477
478
  }
478
479
  });
479
480
 
481
+ await t.step("preloaded Mastodon attribution domains", async () => {
482
+ const context = [
483
+ "https://www.w3.org/ns/activitystreams",
484
+ "http://joinmastodon.org/ns",
485
+ ];
486
+ const expanded = await jsonld.expand({
487
+ "@context": context,
488
+ id: "https://social.example/users/alice",
489
+ type: "Person",
490
+ attributionDomains: ["blog.example"],
491
+ }, { documentLoader: fetchDocumentLoader });
492
+ deepStrictEqual(expanded, [{
493
+ "@id": "https://social.example/users/alice",
494
+ "@type": ["https://www.w3.org/ns/activitystreams#Person"],
495
+ "http://joinmastodon.org/ns#attributionDomains": [
496
+ { "@value": "blog.example" },
497
+ ],
498
+ }]);
499
+ const compacted = await jsonld.compact(expanded, context, {
500
+ documentLoader: fetchDocumentLoader,
501
+ });
502
+ deepStrictEqual(compacted.attributionDomains, ["blog.example"]);
503
+ });
504
+
480
505
  // Controlled Identifiers v1.0 requires JSON-LD processors to treat this
481
506
  // context URL as already resolved. A temporary W3C outage must not prevent
482
507
  // an otherwise valid document from being processed.
@@ -554,6 +579,129 @@ test("getDocumentLoader()", async (t) => {
554
579
  deepStrictEqual(fetchMock.callHistory.calls(url).length, 0);
555
580
  });
556
581
 
582
+ // A Codeberg Pages outage must not prevent loading or expanding FEP-6757.
583
+ // See: https://github.com/fedify-dev/fedify/issues/1211
584
+ fetchMock.get("https://w3id.org/fep/6757", { status: 502 });
585
+ await t.step("preloaded FEP-6757 context", async () => {
586
+ const url = "https://w3id.org/fep/6757";
587
+ deepStrictEqual(await fetchDocumentLoader(url), {
588
+ contextUrl: null,
589
+ documentUrl: url,
590
+ document: {
591
+ "@context": {
592
+ license: {
593
+ "@id": "http://purl.org/dc/terms/license",
594
+ "@type": "@id",
595
+ },
596
+ preferredLicense: {
597
+ "@id": "https://w3id.org/fep/6757#preferredLicense",
598
+ "@type": "@id",
599
+ },
600
+ },
601
+ },
602
+ });
603
+ deepStrictEqual(
604
+ await jsonld.expand({
605
+ "@context": ["https://www.w3.org/ns/activitystreams", url],
606
+ type: "Person",
607
+ license: "https://creativecommons.org/licenses/by/4.0/",
608
+ preferredLicense: "https://creativecommons.org/licenses/by-nc/4.0/",
609
+ }, { documentLoader: fetchDocumentLoader }),
610
+ [{
611
+ "@type": ["https://www.w3.org/ns/activitystreams#Person"],
612
+ "http://purl.org/dc/terms/license": [{
613
+ "@id": "https://creativecommons.org/licenses/by/4.0/",
614
+ }],
615
+ "https://w3id.org/fep/6757#preferredLicense": [{
616
+ "@id": "https://creativecommons.org/licenses/by-nc/4.0/",
617
+ }],
618
+ }],
619
+ );
620
+ deepStrictEqual(fetchMock.callHistory.calls(url).length, 0);
621
+ });
622
+
623
+ // A Codeberg Pages outage must not prevent expanding translation metadata.
624
+ // See: https://github.com/fedify-dev/fedify/issues/1214
625
+ fetchMock.get("https://w3id.org/fep/22cd", { status: 502 });
626
+ await t.step("preloaded FEP-22cd context", async () => {
627
+ const url = "https://w3id.org/fep/22cd";
628
+ const articleId = "https://example.com/articles/1";
629
+ const translatorId = "https://example.com/users/alice";
630
+ const revisionId = "https://example.com/articles/1/revisions/1";
631
+ deepStrictEqual(await fetchDocumentLoader(url), {
632
+ contextUrl: null,
633
+ documentUrl: url,
634
+ document: {
635
+ "@context": {
636
+ "fep-22cd": "https://w3id.org/fep/22cd#",
637
+ schema: "https://schema.org/",
638
+ xsd: "http://www.w3.org/2001/XMLSchema#",
639
+ translations: {
640
+ "@id": "fep-22cd:translations",
641
+ "@container": "@set",
642
+ },
643
+ Translation: "fep-22cd:Translation",
644
+ sourceUpdated: {
645
+ "@id": "fep-22cd:sourceUpdated",
646
+ "@type": "xsd:dateTime",
647
+ },
648
+ translator: {
649
+ "@id": "schema:translator",
650
+ "@type": "@id",
651
+ "@container": "@set",
652
+ },
653
+ inLanguage: "schema:inLanguage",
654
+ translationOfWork: {
655
+ "@id": "schema:translationOfWork",
656
+ "@type": "@id",
657
+ },
658
+ isBasedOn: { "@id": "schema:isBasedOn", "@type": "@id" },
659
+ },
660
+ },
661
+ });
662
+ deepStrictEqual(
663
+ await jsonld.expand({
664
+ "@context": ["https://www.w3.org/ns/activitystreams", url],
665
+ id: articleId,
666
+ type: "Article",
667
+ contentMap: { en: "Original", ko: "Translation" },
668
+ translations: [{
669
+ type: "Translation",
670
+ inLanguage: "ko",
671
+ translator: [translatorId],
672
+ translationOfWork: articleId,
673
+ sourceUpdated: "2026-09-01T00:00:00Z",
674
+ isBasedOn: revisionId,
675
+ }],
676
+ }, { documentLoader: fetchDocumentLoader }),
677
+ [{
678
+ "@id": articleId,
679
+ "@type": ["https://www.w3.org/ns/activitystreams#Article"],
680
+ "https://www.w3.org/ns/activitystreams#content": [
681
+ { "@language": "en", "@value": "Original" },
682
+ { "@language": "ko", "@value": "Translation" },
683
+ ],
684
+ "https://w3id.org/fep/22cd#translations": [{
685
+ "@type": ["https://w3id.org/fep/22cd#Translation"],
686
+ "https://schema.org/inLanguage": [{ "@value": "ko" }],
687
+ "https://schema.org/translator": [{ "@id": translatorId }],
688
+ "https://schema.org/translationOfWork": [{ "@id": articleId }],
689
+ "https://w3id.org/fep/22cd#sourceUpdated": [{
690
+ "@type": "http://www.w3.org/2001/XMLSchema#dateTime",
691
+ "@value": "2026-09-01T00:00:00Z",
692
+ }],
693
+ "https://schema.org/isBasedOn": [{ "@id": revisionId }],
694
+ }],
695
+ }],
696
+ );
697
+ deepStrictEqual(fetchMock.callHistory.calls(url).length, 0);
698
+ deepStrictEqual(
699
+ fetchMock.callHistory.calls("https://www.w3.org/ns/activitystreams")
700
+ .length,
701
+ 0,
702
+ );
703
+ });
704
+
557
705
  await t.step("deny non-HTTP/HTTPS", async () => {
558
706
  await rejects(
559
707
  () => fetchDocumentLoader("ftp://localhost"),
package/src/docloader.ts CHANGED
@@ -528,6 +528,8 @@ export interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
528
528
  * - <https://w3id.org/security/multikey/v1>
529
529
  * - <https://w3id.org/fep/ef61>
530
530
  * - <https://w3id.org/fep/7aa9>
531
+ * - <https://w3id.org/fep/6757>
532
+ * - <https://w3id.org/fep/22cd>
531
533
  * - <https://purl.archive.org/socialweb/webfinger>
532
534
  * - <http://schema.org/>
533
535
  * @param options Options for the document loader.
@@ -1,4 +1,4 @@
1
- import { deepStrictEqual } from "node:assert";
1
+ import { deepStrictEqual, throws } from "node:assert";
2
2
  import { test } from "node:test";
3
3
  import util from "node:util";
4
4
  import { LanguageString } from "./langstr.ts";
@@ -11,6 +11,23 @@ test("new LanguageString()", () => {
11
11
  deepStrictEqual(new LanguageString("Hello", new Intl.Locale("en")), langStr);
12
12
  });
13
13
 
14
+ test("new LanguageString() with extlang tags", () => {
15
+ // Intl.Locale objects have no own enumerable properties, so their base names
16
+ // are compared instead:
17
+ deepStrictEqual(new LanguageString("你好", "zh-YUE").locale.baseName, "yue");
18
+ deepStrictEqual(
19
+ new LanguageString("你好", "zh-yue-HK").locale.baseName,
20
+ "yue-HK",
21
+ );
22
+ // Whether cmn is canonicalized to zh depends on the runtime:
23
+ deepStrictEqual(
24
+ new LanguageString("你好", "zh-cmn-Hant").locale.baseName,
25
+ new Intl.Locale("cmn-Hant").baseName,
26
+ );
27
+ throws(() => new LanguageString("Hello", "en-USA"), RangeError);
28
+ throws(() => new LanguageString("你好", "zh-yue-"), RangeError);
29
+ });
30
+
14
31
  test("Deno.inspect(LanguageString)", () => {
15
32
  const langStr = new LanguageString("Hello, 'world'", "en");
16
33
  deepStrictEqual(
package/src/langstr.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { normalizeLanguageTag } from "./langtag.ts";
2
+
1
3
  /**
2
4
  * A language-tagged string which corresponds to the `rdf:langString` type.
3
5
  */
@@ -12,12 +14,14 @@ export class LanguageString extends String {
12
14
  * Constructs a new `LanguageString`.
13
15
  * @param value A string value written in the given language.
14
16
  * @param language The language of the string. If a string is given, it will
15
- * be parsed as a `Intl.Locale` object.
17
+ * be parsed as a `Intl.Locale` object. Extended language
18
+ * subtags are normalized first, e.g., `zh-yue` is parsed as
19
+ * `yue`.
16
20
  */
17
21
  constructor(value: string, language: Intl.Locale | string) {
18
22
  super(value);
19
23
  this.locale = typeof language === "string"
20
- ? new Intl.Locale(language)
24
+ ? new Intl.Locale(normalizeLanguageTag(language))
21
25
  : language;
22
26
  }
23
27
  }