@fedify/vocab-runtime 2.0.31-dev.2297 → 2.0.31-dev.2308

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-runtime",
3
- "version": "2.0.31-dev.2297+58cbc917",
3
+ "version": "2.0.31-dev.2308+34090b3a",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts",
package/dist/mod.cjs CHANGED
@@ -128,6 +128,36 @@ var cid_v1_default = { "@context": {
128
128
  }
129
129
  } };
130
130
  //#endregion
131
+ //#region src/contexts/fep-22cd.json
132
+ var fep_22cd_default = { "@context": {
133
+ "fep-22cd": "https://w3id.org/fep/22cd#",
134
+ "schema": "https://schema.org/",
135
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
136
+ "translations": {
137
+ "@id": "fep-22cd:translations",
138
+ "@container": "@set"
139
+ },
140
+ "Translation": "fep-22cd:Translation",
141
+ "sourceUpdated": {
142
+ "@id": "fep-22cd:sourceUpdated",
143
+ "@type": "xsd:dateTime"
144
+ },
145
+ "translator": {
146
+ "@id": "schema:translator",
147
+ "@type": "@id",
148
+ "@container": "@set"
149
+ },
150
+ "inLanguage": "schema:inLanguage",
151
+ "translationOfWork": {
152
+ "@id": "schema:translationOfWork",
153
+ "@type": "@id"
154
+ },
155
+ "isBasedOn": {
156
+ "@id": "schema:isBasedOn",
157
+ "@type": "@id"
158
+ }
159
+ } };
160
+ //#endregion
131
161
  //#region src/contexts/fep-6757.json
132
162
  var fep_6757_default = { "@context": {
133
163
  "license": {
@@ -4441,6 +4471,7 @@ const preloadedContexts = {
4441
4471
  "https://w3id.org/fep/ef61": fep_ef61_default,
4442
4472
  "https://w3id.org/fep/7aa9": fep_7aa9_default,
4443
4473
  "https://w3id.org/fep/6757": fep_6757_default,
4474
+ "https://w3id.org/fep/22cd": fep_22cd_default,
4444
4475
  "https://join-lemmy.org/context.json": join_lemmy_default,
4445
4476
  "http://joinmastodon.org/ns": { "@context": {
4446
4477
  "toot": "http://joinmastodon.org/ns#",
@@ -4473,7 +4504,7 @@ const preloadedContexts = {
4473
4504
  //#endregion
4474
4505
  //#region deno.json
4475
4506
  var name = "@fedify/vocab-runtime";
4476
- var version = "2.0.31-dev.2297+58cbc917";
4507
+ var version = "2.0.31-dev.2308+34090b3a";
4477
4508
  //#endregion
4478
4509
  //#region src/request.ts
4479
4510
  /**
@@ -5116,6 +5147,7 @@ async function getRemoteDocument(url, response, fetch) {
5116
5147
  * - <https://w3id.org/fep/ef61>
5117
5148
  * - <https://w3id.org/fep/7aa9>
5118
5149
  * - <https://w3id.org/fep/6757>
5150
+ * - <https://w3id.org/fep/22cd>
5119
5151
  * - <https://purl.archive.org/socialweb/webfinger>
5120
5152
  * - <http://schema.org/>
5121
5153
  * @param options Options for the document loader.
@@ -5698,6 +5730,50 @@ async function exportMultibaseKey(key) {
5698
5730
  return new TextDecoder().decode(encoded);
5699
5731
  }
5700
5732
  //#endregion
5733
+ //#region src/langtag.ts
5734
+ const EXTLANG_PAIRS = new Set(Object.entries({
5735
+ 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",
5736
+ kok: "gom knn",
5737
+ lv: "ltg lvs",
5738
+ 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",
5739
+ 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",
5740
+ sw: "swc swh",
5741
+ uz: "uzn uzs",
5742
+ zh: "cdo cjy cmn cnp cpx csp czh czo gan hak hnm hsn luh lzh mnp nan sjc wuu yue"
5743
+ }).flatMap(([prefix, extlangs]) => extlangs.split(" ").map((extlang) => `${prefix}-${extlang}`)));
5744
+ const PREFIX_PATTERN = /^[A-Za-z]{2,3}$/;
5745
+ const EXTLANG_PATTERN = /^[A-Za-z]{3}$/;
5746
+ /**
5747
+ * Normalizes a BCP 47 language tag that has an extended language subtag
5748
+ * (extlang), such as `zh-yue`, into its canonical form, such as `yue`, as
5749
+ * described in [RFC 5646, Section 4.5][1]. `Intl.Locale` rejects extlang
5750
+ * tags, so tags should be normalized before being passed to it.
5751
+ *
5752
+ * Only registered extlangs that follow their registered prefix are removed;
5753
+ * any other tag is returned unchanged, so the result still needs to be
5754
+ * validated, e.g., by `Intl.Locale`.
5755
+ *
5756
+ * NOTE: This function is marked as internal in the 2.0.x–2.4.x patch
5757
+ * releases. When merging it into the *main* branch, remove the `@internal`
5758
+ * tag, formalize it as a public API (`@since 2.5.0`), and add it to
5759
+ * the changelog fragment.
5760
+ *
5761
+ * [1]: https://www.rfc-editor.org/rfc/rfc5646.html#section-4.5
5762
+ *
5763
+ * @param tag The BCP 47 language tag to normalize.
5764
+ * @returns The normalized language tag.
5765
+ * @internal
5766
+ */
5767
+ function normalizeLanguageTag(tag) {
5768
+ const subtags = tag.split("-");
5769
+ if (subtags.length < 2) return tag;
5770
+ const [prefix, extlang, ...rest] = subtags;
5771
+ if (!PREFIX_PATTERN.test(prefix) || !EXTLANG_PATTERN.test(extlang)) return tag;
5772
+ const language = extlang.toLowerCase();
5773
+ if (!EXTLANG_PAIRS.has(`${prefix.toLowerCase()}-${language}`)) return tag;
5774
+ return [language, ...rest].join("-");
5775
+ }
5776
+ //#endregion
5701
5777
  //#region src/langstr.ts
5702
5778
  /**
5703
5779
  * A language-tagged string which corresponds to the `rdf:langString` type.
@@ -5712,11 +5788,13 @@ var LanguageString = class extends String {
5712
5788
  * Constructs a new `LanguageString`.
5713
5789
  * @param value A string value written in the given language.
5714
5790
  * @param language The language of the string. If a string is given, it will
5715
- * be parsed as a `Intl.Locale` object.
5791
+ * be parsed as a `Intl.Locale` object. Extended language
5792
+ * subtags are normalized first, e.g., `zh-yue` is parsed as
5793
+ * `yue`.
5716
5794
  */
5717
5795
  constructor(value, language) {
5718
5796
  super(value);
5719
- this.locale = typeof language === "string" ? new Intl.Locale(language) : language;
5797
+ this.locale = typeof language === "string" ? new Intl.Locale(normalizeLanguageTag(language)) : language;
5720
5798
  }
5721
5799
  };
5722
5800
  LanguageString.prototype[Symbol.for("Deno.customInspect")] = function(inspect, options) {
@@ -5746,5 +5824,6 @@ exports.importSpki = importSpki;
5746
5824
  exports.isValidPublicIPv4Address = isValidPublicIPv4Address;
5747
5825
  exports.isValidPublicIPv6Address = isValidPublicIPv6Address;
5748
5826
  exports.logRequest = logRequest;
5827
+ exports.normalizeLanguageTag = normalizeLanguageTag;
5749
5828
  exports.preloadedContexts = preloadedContexts;
5750
5829
  exports.validatePublicUrl = validatePublicUrl;
package/dist/mod.d.cts CHANGED
@@ -184,6 +184,7 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
184
184
  * - <https://w3id.org/fep/ef61>
185
185
  * - <https://w3id.org/fep/7aa9>
186
186
  * - <https://w3id.org/fep/6757>
187
+ * - <https://w3id.org/fep/22cd>
187
188
  * - <https://purl.archive.org/socialweb/webfinger>
188
189
  * - <http://schema.org/>
189
190
  * @param options Options for the document loader.
@@ -264,11 +265,37 @@ declare class LanguageString extends String {
264
265
  * Constructs a new `LanguageString`.
265
266
  * @param value A string value written in the given language.
266
267
  * @param language The language of the string. If a string is given, it will
267
- * be parsed as a `Intl.Locale` object.
268
+ * be parsed as a `Intl.Locale` object. Extended language
269
+ * subtags are normalized first, e.g., `zh-yue` is parsed as
270
+ * `yue`.
268
271
  */
269
272
  constructor(value: string, language: Intl.Locale | string);
270
273
  }
271
274
  //#endregion
275
+ //#region src/langtag.d.ts
276
+ /**
277
+ * Normalizes a BCP 47 language tag that has an extended language subtag
278
+ * (extlang), such as `zh-yue`, into its canonical form, such as `yue`, as
279
+ * described in [RFC 5646, Section 4.5][1]. `Intl.Locale` rejects extlang
280
+ * tags, so tags should be normalized before being passed to it.
281
+ *
282
+ * Only registered extlangs that follow their registered prefix are removed;
283
+ * any other tag is returned unchanged, so the result still needs to be
284
+ * validated, e.g., by `Intl.Locale`.
285
+ *
286
+ * NOTE: This function is marked as internal in the 2.0.x–2.4.x patch
287
+ * releases. When merging it into the *main* branch, remove the `@internal`
288
+ * tag, formalize it as a public API (`@since 2.5.0`), and add it to
289
+ * the changelog fragment.
290
+ *
291
+ * [1]: https://www.rfc-editor.org/rfc/rfc5646.html#section-4.5
292
+ *
293
+ * @param tag The BCP 47 language tag to normalize.
294
+ * @returns The normalized language tag.
295
+ * @internal
296
+ */
297
+ declare function normalizeLanguageTag(tag: string): string;
298
+ //#endregion
272
299
  //#region src/multibase/types.d.ts
273
300
  type BaseCode = "\x00" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U";
274
301
  /**
@@ -343,4 +370,4 @@ declare function isValidPublicIPv4Address(address: string): boolean;
343
370
  declare function isValidPublicIPv6Address(address: string): boolean;
344
371
  declare function expandIPv6Address(address: string): string;
345
372
  //#endregion
346
- export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, LanguageString, type RemoteDocument, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, preloadedContexts, validatePublicUrl };
373
+ export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, LanguageString, type RemoteDocument, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, normalizeLanguageTag, preloadedContexts, validatePublicUrl };
package/dist/mod.d.ts CHANGED
@@ -183,6 +183,7 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
183
183
  * - <https://w3id.org/fep/ef61>
184
184
  * - <https://w3id.org/fep/7aa9>
185
185
  * - <https://w3id.org/fep/6757>
186
+ * - <https://w3id.org/fep/22cd>
186
187
  * - <https://purl.archive.org/socialweb/webfinger>
187
188
  * - <http://schema.org/>
188
189
  * @param options Options for the document loader.
@@ -263,11 +264,37 @@ declare class LanguageString extends String {
263
264
  * Constructs a new `LanguageString`.
264
265
  * @param value A string value written in the given language.
265
266
  * @param language The language of the string. If a string is given, it will
266
- * be parsed as a `Intl.Locale` object.
267
+ * be parsed as a `Intl.Locale` object. Extended language
268
+ * subtags are normalized first, e.g., `zh-yue` is parsed as
269
+ * `yue`.
267
270
  */
268
271
  constructor(value: string, language: Intl.Locale | string);
269
272
  }
270
273
  //#endregion
274
+ //#region src/langtag.d.ts
275
+ /**
276
+ * Normalizes a BCP 47 language tag that has an extended language subtag
277
+ * (extlang), such as `zh-yue`, into its canonical form, such as `yue`, as
278
+ * described in [RFC 5646, Section 4.5][1]. `Intl.Locale` rejects extlang
279
+ * tags, so tags should be normalized before being passed to it.
280
+ *
281
+ * Only registered extlangs that follow their registered prefix are removed;
282
+ * any other tag is returned unchanged, so the result still needs to be
283
+ * validated, e.g., by `Intl.Locale`.
284
+ *
285
+ * NOTE: This function is marked as internal in the 2.0.x–2.4.x patch
286
+ * releases. When merging it into the *main* branch, remove the `@internal`
287
+ * tag, formalize it as a public API (`@since 2.5.0`), and add it to
288
+ * the changelog fragment.
289
+ *
290
+ * [1]: https://www.rfc-editor.org/rfc/rfc5646.html#section-4.5
291
+ *
292
+ * @param tag The BCP 47 language tag to normalize.
293
+ * @returns The normalized language tag.
294
+ * @internal
295
+ */
296
+ declare function normalizeLanguageTag(tag: string): string;
297
+ //#endregion
271
298
  //#region src/multibase/types.d.ts
272
299
  type BaseCode = "\x00" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U";
273
300
  /**
@@ -342,4 +369,4 @@ declare function isValidPublicIPv4Address(address: string): boolean;
342
369
  declare function isValidPublicIPv6Address(address: string): boolean;
343
370
  declare function expandIPv6Address(address: string): string;
344
371
  //#endregion
345
- export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, LanguageString, type RemoteDocument, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, preloadedContexts, validatePublicUrl };
372
+ export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, LanguageString, type RemoteDocument, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, normalizeLanguageTag, preloadedContexts, validatePublicUrl };
package/dist/mod.js CHANGED
@@ -123,6 +123,36 @@ var cid_v1_default = { "@context": {
123
123
  }
124
124
  } };
125
125
  //#endregion
126
+ //#region src/contexts/fep-22cd.json
127
+ var fep_22cd_default = { "@context": {
128
+ "fep-22cd": "https://w3id.org/fep/22cd#",
129
+ "schema": "https://schema.org/",
130
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
131
+ "translations": {
132
+ "@id": "fep-22cd:translations",
133
+ "@container": "@set"
134
+ },
135
+ "Translation": "fep-22cd:Translation",
136
+ "sourceUpdated": {
137
+ "@id": "fep-22cd:sourceUpdated",
138
+ "@type": "xsd:dateTime"
139
+ },
140
+ "translator": {
141
+ "@id": "schema:translator",
142
+ "@type": "@id",
143
+ "@container": "@set"
144
+ },
145
+ "inLanguage": "schema:inLanguage",
146
+ "translationOfWork": {
147
+ "@id": "schema:translationOfWork",
148
+ "@type": "@id"
149
+ },
150
+ "isBasedOn": {
151
+ "@id": "schema:isBasedOn",
152
+ "@type": "@id"
153
+ }
154
+ } };
155
+ //#endregion
126
156
  //#region src/contexts/fep-6757.json
127
157
  var fep_6757_default = { "@context": {
128
158
  "license": {
@@ -4436,6 +4466,7 @@ const preloadedContexts = {
4436
4466
  "https://w3id.org/fep/ef61": fep_ef61_default,
4437
4467
  "https://w3id.org/fep/7aa9": fep_7aa9_default,
4438
4468
  "https://w3id.org/fep/6757": fep_6757_default,
4469
+ "https://w3id.org/fep/22cd": fep_22cd_default,
4439
4470
  "https://join-lemmy.org/context.json": join_lemmy_default,
4440
4471
  "http://joinmastodon.org/ns": { "@context": {
4441
4472
  "toot": "http://joinmastodon.org/ns#",
@@ -4468,7 +4499,7 @@ const preloadedContexts = {
4468
4499
  //#endregion
4469
4500
  //#region deno.json
4470
4501
  var name = "@fedify/vocab-runtime";
4471
- var version = "2.0.31-dev.2297+58cbc917";
4502
+ var version = "2.0.31-dev.2308+34090b3a";
4472
4503
  //#endregion
4473
4504
  //#region src/request.ts
4474
4505
  /**
@@ -5111,6 +5142,7 @@ async function getRemoteDocument(url, response, fetch) {
5111
5142
  * - <https://w3id.org/fep/ef61>
5112
5143
  * - <https://w3id.org/fep/7aa9>
5113
5144
  * - <https://w3id.org/fep/6757>
5145
+ * - <https://w3id.org/fep/22cd>
5114
5146
  * - <https://purl.archive.org/socialweb/webfinger>
5115
5147
  * - <http://schema.org/>
5116
5148
  * @param options Options for the document loader.
@@ -5693,6 +5725,50 @@ async function exportMultibaseKey(key) {
5693
5725
  return new TextDecoder().decode(encoded);
5694
5726
  }
5695
5727
  //#endregion
5728
+ //#region src/langtag.ts
5729
+ const EXTLANG_PAIRS = new Set(Object.entries({
5730
+ 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",
5731
+ kok: "gom knn",
5732
+ lv: "ltg lvs",
5733
+ 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",
5734
+ 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",
5735
+ sw: "swc swh",
5736
+ uz: "uzn uzs",
5737
+ zh: "cdo cjy cmn cnp cpx csp czh czo gan hak hnm hsn luh lzh mnp nan sjc wuu yue"
5738
+ }).flatMap(([prefix, extlangs]) => extlangs.split(" ").map((extlang) => `${prefix}-${extlang}`)));
5739
+ const PREFIX_PATTERN = /^[A-Za-z]{2,3}$/;
5740
+ const EXTLANG_PATTERN = /^[A-Za-z]{3}$/;
5741
+ /**
5742
+ * Normalizes a BCP 47 language tag that has an extended language subtag
5743
+ * (extlang), such as `zh-yue`, into its canonical form, such as `yue`, as
5744
+ * described in [RFC 5646, Section 4.5][1]. `Intl.Locale` rejects extlang
5745
+ * tags, so tags should be normalized before being passed to it.
5746
+ *
5747
+ * Only registered extlangs that follow their registered prefix are removed;
5748
+ * any other tag is returned unchanged, so the result still needs to be
5749
+ * validated, e.g., by `Intl.Locale`.
5750
+ *
5751
+ * NOTE: This function is marked as internal in the 2.0.x–2.4.x patch
5752
+ * releases. When merging it into the *main* branch, remove the `@internal`
5753
+ * tag, formalize it as a public API (`@since 2.5.0`), and add it to
5754
+ * the changelog fragment.
5755
+ *
5756
+ * [1]: https://www.rfc-editor.org/rfc/rfc5646.html#section-4.5
5757
+ *
5758
+ * @param tag The BCP 47 language tag to normalize.
5759
+ * @returns The normalized language tag.
5760
+ * @internal
5761
+ */
5762
+ function normalizeLanguageTag(tag) {
5763
+ const subtags = tag.split("-");
5764
+ if (subtags.length < 2) return tag;
5765
+ const [prefix, extlang, ...rest] = subtags;
5766
+ if (!PREFIX_PATTERN.test(prefix) || !EXTLANG_PATTERN.test(extlang)) return tag;
5767
+ const language = extlang.toLowerCase();
5768
+ if (!EXTLANG_PAIRS.has(`${prefix.toLowerCase()}-${language}`)) return tag;
5769
+ return [language, ...rest].join("-");
5770
+ }
5771
+ //#endregion
5696
5772
  //#region src/langstr.ts
5697
5773
  /**
5698
5774
  * A language-tagged string which corresponds to the `rdf:langString` type.
@@ -5707,11 +5783,13 @@ var LanguageString = class extends String {
5707
5783
  * Constructs a new `LanguageString`.
5708
5784
  * @param value A string value written in the given language.
5709
5785
  * @param language The language of the string. If a string is given, it will
5710
- * be parsed as a `Intl.Locale` object.
5786
+ * be parsed as a `Intl.Locale` object. Extended language
5787
+ * subtags are normalized first, e.g., `zh-yue` is parsed as
5788
+ * `yue`.
5711
5789
  */
5712
5790
  constructor(value, language) {
5713
5791
  super(value);
5714
- this.locale = typeof language === "string" ? new Intl.Locale(language) : language;
5792
+ this.locale = typeof language === "string" ? new Intl.Locale(normalizeLanguageTag(language)) : language;
5715
5793
  }
5716
5794
  };
5717
5795
  LanguageString.prototype[Symbol.for("Deno.customInspect")] = function(inspect, options) {
@@ -5721,4 +5799,4 @@ LanguageString.prototype[Symbol.for("nodejs.util.inspect.custom")] = function(_d
5721
5799
  return `<${this.locale.baseName}> ${inspect(this.toString(), options)}`;
5722
5800
  };
5723
5801
  //#endregion
5724
- export { FetchError, LanguageString, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, preloadedContexts, validatePublicUrl };
5802
+ export { FetchError, LanguageString, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, normalizeLanguageTag, preloadedContexts, validatePublicUrl };
@@ -1,4 +1,4 @@
1
- import { t as FetchError } from "./request-DlZHvlsq.mjs";
1
+ import { t as FetchError } from "./request-BV7yaWdl.mjs";
2
2
  import { getLogger } from "@logtape/logtape";
3
3
  //#region src/body.ts
4
4
  /** Decoded JSON body limit: 16 MiB. @internal */
@@ -1,5 +1,5 @@
1
1
  require("./chunk-Do9eywBl.cjs");
2
- const require_request = require("./request-ClhOmVbs.cjs");
2
+ const require_request = require("./request-Ban3HXuI.cjs");
3
3
  let _logtape_logtape = require("@logtape/logtape");
4
4
  //#region src/body.ts
5
5
  /** Decoded JSON body limit: 16 MiB. @internal */
@@ -1,5 +1,5 @@
1
1
  require("./chunk-Do9eywBl.cjs");
2
- const require_body = require("./body-B1TX2GGC.cjs");
2
+ const require_body = require("./body-DGmcZ1Kz.cjs");
3
3
  let node_assert_strict = require("node:assert/strict");
4
4
  let node_test = require("node:test");
5
5
  let node_zlib = require("node:zlib");
@@ -1,4 +1,4 @@
1
- import { r as readBoundedText, t as BodyTooLargeError } from "./body-DkPsw4D7.mjs";
1
+ import { r as readBoundedText, t as BodyTooLargeError } from "./body-Bx6-vXo_.mjs";
2
2
  import { deepStrictEqual, ok, rejects } from "node:assert/strict";
3
3
  import { test } from "node:test";
4
4
  import { gunzipSync, gzipSync } from "node:zlib";
@@ -1,6 +1,6 @@
1
1
  const require_chunk = require("./chunk-Do9eywBl.cjs");
2
- const require_request = require("./request-ClhOmVbs.cjs");
3
- const require_body = require("./body-B1TX2GGC.cjs");
2
+ const require_request = require("./request-Ban3HXuI.cjs");
3
+ const require_body = require("./body-DGmcZ1Kz.cjs");
4
4
  const require_link = require("./link-FguCydMA.cjs");
5
5
  const require_url = require("./url-Qk1svKZU.cjs");
6
6
  let node_test = require("node:test");
@@ -1327,6 +1327,36 @@ var cid_v1_default = { "@context": {
1327
1327
  }
1328
1328
  } };
1329
1329
  //#endregion
1330
+ //#region src/contexts/fep-22cd.json
1331
+ var fep_22cd_default = { "@context": {
1332
+ "fep-22cd": "https://w3id.org/fep/22cd#",
1333
+ "schema": "https://schema.org/",
1334
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
1335
+ "translations": {
1336
+ "@id": "fep-22cd:translations",
1337
+ "@container": "@set"
1338
+ },
1339
+ "Translation": "fep-22cd:Translation",
1340
+ "sourceUpdated": {
1341
+ "@id": "fep-22cd:sourceUpdated",
1342
+ "@type": "xsd:dateTime"
1343
+ },
1344
+ "translator": {
1345
+ "@id": "schema:translator",
1346
+ "@type": "@id",
1347
+ "@container": "@set"
1348
+ },
1349
+ "inLanguage": "schema:inLanguage",
1350
+ "translationOfWork": {
1351
+ "@id": "schema:translationOfWork",
1352
+ "@type": "@id"
1353
+ },
1354
+ "isBasedOn": {
1355
+ "@id": "schema:isBasedOn",
1356
+ "@type": "@id"
1357
+ }
1358
+ } };
1359
+ //#endregion
1330
1360
  //#region src/contexts/fep-6757.json
1331
1361
  var fep_6757_default = { "@context": {
1332
1362
  "license": {
@@ -5640,6 +5670,7 @@ const preloadedContexts = {
5640
5670
  "https://w3id.org/fep/ef61": fep_ef61_default,
5641
5671
  "https://w3id.org/fep/7aa9": fep_7aa9_default,
5642
5672
  "https://w3id.org/fep/6757": fep_6757_default,
5673
+ "https://w3id.org/fep/22cd": fep_22cd_default,
5643
5674
  "https://join-lemmy.org/context.json": join_lemmy_default,
5644
5675
  "http://joinmastodon.org/ns": { "@context": {
5645
5676
  "toot": "http://joinmastodon.org/ns#",
@@ -5782,6 +5813,7 @@ async function getRemoteDocument(url, response, fetch) {
5782
5813
  * - <https://w3id.org/fep/ef61>
5783
5814
  * - <https://w3id.org/fep/7aa9>
5784
5815
  * - <https://w3id.org/fep/6757>
5816
+ * - <https://w3id.org/fep/22cd>
5785
5817
  * - <https://purl.archive.org/socialweb/webfinger>
5786
5818
  * - <http://schema.org/>
5787
5819
  * @param options Options for the document loader.
@@ -6180,6 +6212,85 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
6180
6212
  }]);
6181
6213
  (0, node_assert.deepStrictEqual)(esm_default.callHistory.calls(url).length, 0);
6182
6214
  });
6215
+ esm_default.get("https://w3id.org/fep/22cd", { status: 502 });
6216
+ await t.test("preloaded FEP-22cd context", async () => {
6217
+ const url = "https://w3id.org/fep/22cd";
6218
+ const articleId = "https://example.com/articles/1";
6219
+ const translatorId = "https://example.com/users/alice";
6220
+ const revisionId = "https://example.com/articles/1/revisions/1";
6221
+ (0, node_assert.deepStrictEqual)(await fetchDocumentLoader(url), {
6222
+ contextUrl: null,
6223
+ documentUrl: url,
6224
+ document: { "@context": {
6225
+ "fep-22cd": "https://w3id.org/fep/22cd#",
6226
+ schema: "https://schema.org/",
6227
+ xsd: "http://www.w3.org/2001/XMLSchema#",
6228
+ translations: {
6229
+ "@id": "fep-22cd:translations",
6230
+ "@container": "@set"
6231
+ },
6232
+ Translation: "fep-22cd:Translation",
6233
+ sourceUpdated: {
6234
+ "@id": "fep-22cd:sourceUpdated",
6235
+ "@type": "xsd:dateTime"
6236
+ },
6237
+ translator: {
6238
+ "@id": "schema:translator",
6239
+ "@type": "@id",
6240
+ "@container": "@set"
6241
+ },
6242
+ inLanguage: "schema:inLanguage",
6243
+ translationOfWork: {
6244
+ "@id": "schema:translationOfWork",
6245
+ "@type": "@id"
6246
+ },
6247
+ isBasedOn: {
6248
+ "@id": "schema:isBasedOn",
6249
+ "@type": "@id"
6250
+ }
6251
+ } }
6252
+ });
6253
+ (0, node_assert.deepStrictEqual)(await jsonld_default.expand({
6254
+ "@context": ["https://www.w3.org/ns/activitystreams", url],
6255
+ id: articleId,
6256
+ type: "Article",
6257
+ contentMap: {
6258
+ en: "Original",
6259
+ ko: "Translation"
6260
+ },
6261
+ translations: [{
6262
+ type: "Translation",
6263
+ inLanguage: "ko",
6264
+ translator: [translatorId],
6265
+ translationOfWork: articleId,
6266
+ sourceUpdated: "2026-09-01T00:00:00Z",
6267
+ isBasedOn: revisionId
6268
+ }]
6269
+ }, { documentLoader: fetchDocumentLoader }), [{
6270
+ "@id": articleId,
6271
+ "@type": ["https://www.w3.org/ns/activitystreams#Article"],
6272
+ "https://www.w3.org/ns/activitystreams#content": [{
6273
+ "@language": "en",
6274
+ "@value": "Original"
6275
+ }, {
6276
+ "@language": "ko",
6277
+ "@value": "Translation"
6278
+ }],
6279
+ "https://w3id.org/fep/22cd#translations": [{
6280
+ "@type": ["https://w3id.org/fep/22cd#Translation"],
6281
+ "https://schema.org/inLanguage": [{ "@value": "ko" }],
6282
+ "https://schema.org/translator": [{ "@id": translatorId }],
6283
+ "https://schema.org/translationOfWork": [{ "@id": articleId }],
6284
+ "https://w3id.org/fep/22cd#sourceUpdated": [{
6285
+ "@type": "http://www.w3.org/2001/XMLSchema#dateTime",
6286
+ "@value": "2026-09-01T00:00:00Z"
6287
+ }],
6288
+ "https://schema.org/isBasedOn": [{ "@id": revisionId }]
6289
+ }]
6290
+ }]);
6291
+ (0, node_assert.deepStrictEqual)(esm_default.callHistory.calls(url).length, 0);
6292
+ (0, node_assert.deepStrictEqual)(esm_default.callHistory.calls("https://www.w3.org/ns/activitystreams").length, 0);
6293
+ });
6183
6294
  await t.test("deny non-HTTP/HTTPS", async () => {
6184
6295
  await (0, node_assert.rejects)(() => fetchDocumentLoader("ftp://localhost"), require_url.UrlError);
6185
6296
  });