@fedify/vocab-runtime 2.3.11-dev.2296 → 2.3.11
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 +2 -2
- package/dist/mod.cjs +91 -4
- package/dist/mod.d.cts +30 -2
- package/dist/mod.d.ts +30 -2
- package/dist/mod.js +91 -5
- package/dist/tests/{body-B4vYiUPw.mjs → body-Cfk4XwBC.mjs} +1 -1
- package/dist/tests/{body-E_Ip3EI_.cjs → body-kujxx7yw.cjs} +1 -1
- package/dist/tests/body.test.cjs +1 -1
- package/dist/tests/body.test.mjs +1 -1
- package/dist/tests/decimal.test.cjs +3 -2
- package/dist/tests/decimal.test.mjs +3 -2
- package/dist/tests/{docloader-DBzA04Tp.mjs → docloader-BeuDl5a0.mjs} +43 -3
- package/dist/tests/{docloader-zA5iGORs.cjs → docloader-Bx_LR9xG.cjs} +43 -3
- package/dist/tests/docloader.test.cjs +168 -43
- package/dist/tests/docloader.test.mjs +158 -34
- package/dist/tests/{langstr-DDLc4833.mjs → langstr-ABdAOKlF.mjs} +5 -2
- package/dist/tests/{langstr-BOQHfJDr.cjs → langstr-BsqFJupv.cjs} +5 -2
- package/dist/tests/langstr.test.cjs +8 -1
- package/dist/tests/langstr.test.mjs +9 -2
- package/dist/tests/langtag-DgySESmk.cjs +50 -0
- package/dist/tests/langtag-LDBqlxHv.mjs +45 -0
- package/dist/tests/langtag.test.cjs +46 -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/multibase/multibase.test.cjs +7 -7
- package/dist/tests/multibase/multibase.test.mjs +5 -5
- package/dist/tests/{request-CzD6ie9f.mjs → request-D6bjY2cF.mjs} +1 -1
- package/dist/tests/{request-DfDR4M7o.cjs → request-DPh7-Q1i.cjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/package.json +6 -3
- package/scripts/test-bun.mjs +18 -0
- package/src/contexts/fep-22cd.json +14 -0
- package/src/contexts/fep-6757.json +12 -0
- package/src/contexts/joinmastodon.json +1 -1
- package/src/contexts.ts +16 -0
- package/src/docloader.test.ts +222 -67
- 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
- package/src/multibase/multibase.test.ts +5 -5
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { t as normalizeLanguageTag } from "./langtag-LDBqlxHv.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,9 +1,9 @@
|
|
|
1
1
|
require("../chunk-C2EiDwsr.cjs");
|
|
2
2
|
const require_multibase = require("../multibase-BL45eko3.cjs");
|
|
3
|
-
let node_test = require("node:test");
|
|
4
3
|
let node_assert = require("node:assert");
|
|
4
|
+
let _fedify_fixture = require("@fedify/fixture");
|
|
5
5
|
//#region src/multibase/multibase.test.ts
|
|
6
|
-
(0,
|
|
6
|
+
(0, _fedify_fixture.test)("multibase.encode and decode", async (t) => {
|
|
7
7
|
const testCases = [
|
|
8
8
|
[
|
|
9
9
|
"base16",
|
|
@@ -316,22 +316,22 @@ let node_assert = require("node:assert");
|
|
|
316
316
|
"Uw7fDr8O_8J-lsMO3w6_Dv_CfmI7wn6W28J-krw=="
|
|
317
317
|
]
|
|
318
318
|
];
|
|
319
|
-
for (const [name, input, expectedOutput] of testCases) await t.
|
|
319
|
+
for (const [name, input, expectedOutput] of testCases) await t.step(`Encoding/Decoding ${name} with ${input}`, () => {
|
|
320
320
|
(0, node_assert.deepStrictEqual)(require_multibase.decodeText(require_multibase.encodeMultibase(name, require_multibase.encodeText(input))), expectedOutput, `Encoding ${name} failed`);
|
|
321
321
|
(0, node_assert.deepStrictEqual)(require_multibase.decodeMultibase(expectedOutput), require_multibase.encodeText(input), `Decoding ${name} failed`);
|
|
322
322
|
(0, node_assert.deepStrictEqual)(require_multibase.decodeMultibase(require_multibase.encodeText(expectedOutput)), require_multibase.encodeText(input), `Decoding buffer of ${name} failed`);
|
|
323
323
|
});
|
|
324
|
-
await t.
|
|
324
|
+
await t.step("should allow base32pad full alphabet", () => {
|
|
325
325
|
const decoded = require_multibase.decodeMultibase("ctimaq4ygg2iegci7");
|
|
326
326
|
(0, node_assert.deepStrictEqual)(require_multibase.decodeMultibase(require_multibase.encodeMultibase("c", decoded)), decoded);
|
|
327
327
|
});
|
|
328
328
|
});
|
|
329
|
-
(0,
|
|
330
|
-
await t.
|
|
329
|
+
(0, _fedify_fixture.test)("constants", async (t) => {
|
|
330
|
+
await t.step("constants indexed by name", () => {
|
|
331
331
|
const names$1 = require_multibase.names;
|
|
332
332
|
(0, node_assert.deepStrictEqual)(Object.keys(names$1).length, 23);
|
|
333
333
|
});
|
|
334
|
-
await t.
|
|
334
|
+
await t.step("constants indexed by code", () => {
|
|
335
335
|
const codes$1 = require_multibase.codes;
|
|
336
336
|
(0, node_assert.deepStrictEqual)(Object.keys(codes$1).length, 23);
|
|
337
337
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as decodeText, i as names, n as encodeMultibase, o as encodeText, r as codes, t as decodeMultibase } from "../multibase-Da9VJCw8.mjs";
|
|
2
|
-
import { test } from "node:test";
|
|
3
2
|
import { deepStrictEqual } from "node:assert";
|
|
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.
|
|
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.
|
|
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.
|
|
329
|
+
await t.step("constants indexed by name", () => {
|
|
330
330
|
deepStrictEqual(Object.keys(names).length, 23);
|
|
331
331
|
});
|
|
332
|
-
await t.
|
|
332
|
+
await t.step("constants indexed by code", () => {
|
|
333
333
|
deepStrictEqual(Object.keys(codes).length, 23);
|
|
334
334
|
});
|
|
335
335
|
});
|
|
@@ -3,7 +3,7 @@ let node_process = require("node:process");
|
|
|
3
3
|
node_process = require_chunk.__toESM(node_process, 1);
|
|
4
4
|
//#region deno.json
|
|
5
5
|
var name = "@fedify/vocab-runtime";
|
|
6
|
-
var version = "2.3.11
|
|
6
|
+
var version = "2.3.11";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/request.ts
|
|
9
9
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-C2EiDwsr.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-DPh7-Q1i.cjs");
|
|
3
3
|
let node_test = require("node:test");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process, 1);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as version, r as getUserAgent } from "./request-
|
|
1
|
+
import { o as version, r as getUserAgent } from "./request-D6bjY2cF.mjs";
|
|
2
2
|
import { test } from "node:test";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { deepStrictEqual } from "node:assert";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/vocab-runtime",
|
|
3
|
-
"version": "2.3.11
|
|
3
|
+
"version": "2.3.11",
|
|
4
4
|
"homepage": "https://fedify.dev/",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -72,7 +72,8 @@
|
|
|
72
72
|
"@types/node": "^24.2.1",
|
|
73
73
|
"fetch-mock": "^12.5.4",
|
|
74
74
|
"tsdown": "^0.22.0",
|
|
75
|
-
"typescript": "^6.0.0"
|
|
75
|
+
"typescript": "^6.0.0",
|
|
76
|
+
"@fedify/fixture": "2.0.0"
|
|
76
77
|
},
|
|
77
78
|
"dependencies": {
|
|
78
79
|
"@js-temporal/polyfill": "^0.5.1",
|
|
@@ -89,6 +90,8 @@
|
|
|
89
90
|
"build": "pnpm --filter @fedify/vocab-runtime... run build:self",
|
|
90
91
|
"prepublish": "pnpm build",
|
|
91
92
|
"pretest": "pnpm build",
|
|
92
|
-
"test": "cd dist/tests && node --test"
|
|
93
|
+
"test": "cd dist/tests && node --test",
|
|
94
|
+
"pretest:bun": "pnpm build",
|
|
95
|
+
"test:bun": "node scripts/test-bun.mjs"
|
|
93
96
|
}
|
|
94
97
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { access, glob } from "node:fs/promises";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
|
|
5
|
+
const sources = await Array.fromAsync(glob("src/**/*.test.ts"));
|
|
6
|
+
if (sources.length === 0) throw new Error("No vocab-runtime tests found.");
|
|
7
|
+
|
|
8
|
+
const tests = sources.map((source) =>
|
|
9
|
+
source.replaceAll("\\", "/").replace(/^src\//, "dist/tests/")
|
|
10
|
+
.replace(/\.ts$/, ".mjs")
|
|
11
|
+
).sort();
|
|
12
|
+
for (const test of tests) await access(test);
|
|
13
|
+
|
|
14
|
+
const result = spawnSync("bun", ["test", "--timeout", "60000", ...tests], {
|
|
15
|
+
stdio: "inherit",
|
|
16
|
+
});
|
|
17
|
+
if (result.error) throw result.error;
|
|
18
|
+
process.exitCode = result.status ?? 1;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": {
|
|
3
|
+
"fep-22cd": "https://w3id.org/fep/22cd#",
|
|
4
|
+
"schema": "https://schema.org/",
|
|
5
|
+
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
|
6
|
+
"translations": { "@id": "fep-22cd:translations", "@container": "@set" },
|
|
7
|
+
"Translation": "fep-22cd:Translation",
|
|
8
|
+
"sourceUpdated": { "@id": "fep-22cd:sourceUpdated", "@type": "xsd:dateTime" },
|
|
9
|
+
"translator": { "@id": "schema:translator", "@type": "@id", "@container": "@set" },
|
|
10
|
+
"inLanguage": "schema:inLanguage",
|
|
11
|
+
"translationOfWork": { "@id": "schema:translationOfWork", "@type": "@id" },
|
|
12
|
+
"isBasedOn": { "@id": "schema:isBasedOn", "@type": "@id" }
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/contexts.ts
CHANGED
|
@@ -7,7 +7,9 @@ import activitystreams from "./contexts/activitystreams.json" with {
|
|
|
7
7
|
};
|
|
8
8
|
import cidV1Context from "./contexts/cid-v1.json" with { type: "json" };
|
|
9
9
|
import didV1 from "./contexts/did-v1.json" with { type: "json" };
|
|
10
|
+
import fep22cd from "./contexts/fep-22cd.json" with { type: "json" };
|
|
10
11
|
import fep5711 from "./contexts/fep-5711.json" with { type: "json" };
|
|
12
|
+
import fep6757 from "./contexts/fep-6757.json" with { type: "json" };
|
|
11
13
|
import fep7aa9 from "./contexts/fep-7aa9.json" with { type: "json" };
|
|
12
14
|
import fepEf61 from "./contexts/fep-ef61.json" with { type: "json" };
|
|
13
15
|
import gotosocial from "./contexts/gotosocial.json" with { type: "json" };
|
|
@@ -64,6 +66,20 @@ const preloadedContexts: Record<string, unknown> = {
|
|
|
64
66
|
// https://github.com/fedify-dev/fedify/issues/1078
|
|
65
67
|
"https://w3id.org/fep/7aa9": fep7aa9,
|
|
66
68
|
|
|
69
|
+
// The FEP-6757 context is hosted on Codeberg Pages, whose outages can
|
|
70
|
+
// prevent documents with license metadata from being parsed. Resolve it
|
|
71
|
+
// locally so parsing does not depend on the remote context server.
|
|
72
|
+
// See: https://w3id.org/fep/6757
|
|
73
|
+
// https://github.com/fedify-dev/fedify/issues/1211
|
|
74
|
+
"https://w3id.org/fep/6757": fep6757,
|
|
75
|
+
|
|
76
|
+
// Resolve translation metadata locally even on versions without Translation.
|
|
77
|
+
// Copied verbatim from the upstream context at the pinned revision below.
|
|
78
|
+
// See: https://w3id.org/fep/22cd
|
|
79
|
+
// https://github.com/fedify-dev/fedify/issues/1214
|
|
80
|
+
// Source: https://codeberg.org/fediverse/fep/src/commit/7526048b018ccc0a7d05597a8f1eb33518373066/fep/22cd/fep-22cd.jsonld
|
|
81
|
+
"https://w3id.org/fep/22cd": fep22cd,
|
|
82
|
+
|
|
67
83
|
// Lemmy's context document is served as application/json without the JSON-LD
|
|
68
84
|
// context Link header. The default document loader treats that as a regular
|
|
69
85
|
// JSON response instead of a JSON-LD context, so every Lemmy activity that
|