@fedify/vocab-runtime 2.4.0 → 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.
- package/deno.json +1 -1
- package/dist/{contexts-BK1CqBR5.cjs → contexts-B09jb9Pi.cjs} +11 -1
- package/dist/{contexts-DPuJ4UYL.js → contexts-DWrj4AGR.js} +11 -1
- package/dist/{docloader-CYwqh5Df.d.cts → docloader-BMHljyYb.d.cts} +2 -0
- package/dist/{docloader-CYwqh5Df.d.ts → docloader-BMHljyYb.d.ts} +2 -0
- package/dist/internal/jsonld-cache.d.cts +1 -1
- package/dist/internal/jsonld-cache.d.ts +1 -1
- package/dist/internal/portable-dereference.cjs +1 -1
- package/dist/internal/portable-dereference.d.cts +2 -2
- package/dist/internal/portable-dereference.d.ts +2 -2
- package/dist/internal/portable-dereference.js +1 -1
- package/dist/internal/signed-representation.cjs +1 -1
- package/dist/internal/signed-representation.js +1 -1
- package/dist/mod.cjs +53 -4
- package/dist/mod.d.cts +30 -4
- package/dist/mod.d.ts +30 -4
- package/dist/mod.js +53 -5
- package/dist/{portable-DqtfLy_1.d.cts → portable-6Aj-7dZJ.d.cts} +1 -1
- package/dist/{portable-DtWsu2yU.d.ts → portable-nkTiqH0w.d.ts} +1 -1
- package/dist/tests/{body-CYiu9CO-.mjs → body-DpC9p-iG.mjs} +1 -1
- package/dist/tests/{body-CkEwROsn.cjs → body-cKLBprYm.cjs} +1 -1
- package/dist/tests/body.test.cjs +1 -1
- package/dist/tests/body.test.mjs +1 -1
- package/dist/tests/{contexts-DizzBjz4.cjs → contexts-C9Lj11SC.cjs} +11 -1
- package/dist/tests/{contexts-CIKsin4e.mjs → contexts-duRA_dDC.mjs} +11 -1
- package/dist/tests/decimal.test.cjs +4 -3
- package/dist/tests/decimal.test.mjs +4 -3
- package/dist/tests/{docloader-C3YFl6y4.cjs → docloader-DyZ1JGIl.cjs} +5 -3
- package/dist/tests/{docloader-CvmS4sVq.mjs → docloader-tUmMeXjU.mjs} +5 -3
- package/dist/tests/docloader.test.cjs +127 -3
- package/dist/tests/docloader.test.mjs +127 -3
- package/dist/tests/internal/portable-dereference.test.cjs +2 -2
- package/dist/tests/internal/portable-dereference.test.mjs +2 -2
- package/dist/tests/jsonld-CmDhHNTx.cjs +12 -0
- package/dist/tests/jsonld-DweIJ07b.mjs +5 -0
- package/dist/tests/{jsonld-cache-C07AyNOY.cjs → jsonld-cache-BEXiiM-V.cjs} +6 -17
- package/dist/tests/{jsonld-cache-BPQmOZWD.mjs → jsonld-cache-DFnWsLuZ.mjs} +2 -5
- package/dist/tests/jsonld-cache.test.cjs +13 -12
- package/dist/tests/jsonld-cache.test.mjs +2 -1
- package/dist/tests/{langstr-CQ26J_L7.mjs → langstr-DYRmJqFn.mjs} +5 -2
- package/dist/tests/{langstr-C4Fl80ae.cjs → langstr-_PqsL1ae.cjs} +5 -2
- package/dist/tests/langstr.test.cjs +8 -1
- package/dist/tests/langstr.test.mjs +9 -2
- package/dist/tests/langtag-CUppHs_s.mjs +45 -0
- package/dist/tests/langtag-Czjvxfzx.cjs +50 -0
- package/dist/tests/langtag.test.cjs +45 -0
- package/dist/tests/langtag.test.d.cts +1 -0
- package/dist/tests/langtag.test.d.mts +1 -0
- package/dist/tests/langtag.test.mjs +46 -0
- package/dist/tests/{portable-dereference-DRE5bz-l.mjs → portable-dereference-DmTYDy2p.mjs} +3 -2
- package/dist/tests/{portable-dereference-BNXtgg5U.cjs → portable-dereference-qTLMqe2_.cjs} +3 -2
- package/dist/tests/{portable-media-BLKllU56.cjs → portable-media-5p8azal0.cjs} +2 -2
- package/dist/tests/{portable-media-DRSGBORB.mjs → portable-media-B_lt9MMA.mjs} +2 -2
- package/dist/tests/portable-media.test.cjs +1 -1
- package/dist/tests/portable-media.test.mjs +1 -1
- package/dist/tests/portable-workers.test.cjs +1 -1
- package/dist/tests/portable-workers.test.mjs +1 -1
- package/dist/tests/{request-8vPWtV1-.cjs → request-BgjA9wyl.cjs} +1 -1
- package/dist/tests/{request-DRaOaTqD.mjs → request-DodZNukP.mjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/dist/tests/signed-representation.test.cjs +1 -1
- package/dist/tests/signed-representation.test.mjs +1 -1
- package/package.json +1 -1
- package/src/contexts/fep-6757.json +12 -0
- package/src/contexts/joinmastodon.json +1 -1
- package/src/contexts.ts +8 -0
- package/src/docloader.test.ts +148 -0
- package/src/docloader.ts +2 -0
- package/src/langstr.test.ts +18 -1
- package/src/langstr.ts +6 -2
- package/src/langtag.test.ts +53 -0
- package/src/langtag.ts +76 -0
- 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-
|
|
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
|
|
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-
|
|
1
|
+
const require_contexts = require("./contexts-C9Lj11SC.cjs");
|
|
2
2
|
const require_url = require("./url-BNakuZ8k.cjs");
|
|
3
|
-
|
|
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-
|
|
2
|
-
const require_body = require("./body-
|
|
1
|
+
const require_request = require("./request-BgjA9wyl.cjs");
|
|
2
|
+
const require_body = require("./body-cKLBprYm.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-
|
|
2
|
-
import { r as readBoundedBytes } from "./body-
|
|
1
|
+
import { r as getUserAgent } from "./request-DodZNukP.mjs";
|
|
2
|
+
import { r as readBoundedBytes } from "./body-DpC9p-iG.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-
|
|
2
|
+
const require_portable_media = require("./portable-media-5p8azal0.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-
|
|
2
|
+
import { t as fetchPortableMedia } from "./portable-media-B_lt9MMA.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-
|
|
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-
|
|
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.
|
|
6
|
+
var version = "2.4.1";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/request.ts
|
|
9
9
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-BgjA9wyl.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-
|
|
1
|
+
import { n as createActivityPubRequest, o as version, r as getUserAgent } from "./request-DodZNukP.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
|
-
import { t as preloadedContexts } from "./contexts-
|
|
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
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
|
package/src/docloader.test.ts
CHANGED
|
@@ -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.
|
package/src/langstr.test.ts
CHANGED
|
@@ -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
|
}
|