@fedify/vocab-tools 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/mod.cjs +9 -7
- package/dist/mod.js +9 -7
- package/package.json +1 -1
- package/src/__snapshots__/class.test.ts.deno.snap +620 -533
- package/src/__snapshots__/class.test.ts.node.snap +620 -533
- package/src/__snapshots__/class.test.ts.snap +620 -533
- package/src/class.ts +2 -1
- package/src/constructor.ts +5 -4
- package/src/type.ts +1 -1
package/deno.json
CHANGED
package/dist/mod.cjs
CHANGED
|
@@ -8,7 +8,7 @@ let yaml = require("yaml");
|
|
|
8
8
|
let es_toolkit = require("es-toolkit");
|
|
9
9
|
//#region deno.json
|
|
10
10
|
var name = "@fedify/vocab-tools";
|
|
11
|
-
var version = "2.4.
|
|
11
|
+
var version = "2.4.1";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/type.ts
|
|
14
14
|
const HEURISTICS_CONTEXTS = [
|
|
@@ -303,7 +303,7 @@ const scalarTypes = {
|
|
|
303
303
|
&& typeof ${v}["@value"] === "string" && !("@language" in ${v})`;
|
|
304
304
|
},
|
|
305
305
|
decoder(v) {
|
|
306
|
-
return `new Intl.Locale(${v}["@value"])`;
|
|
306
|
+
return `new Intl.Locale(normalizeLanguageTag(${v}["@value"]))`;
|
|
307
307
|
}
|
|
308
308
|
},
|
|
309
309
|
"fedify:url": {
|
|
@@ -1383,7 +1383,7 @@ async function* generateConstructor(typeUri, types) {
|
|
|
1383
1383
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
1384
1384
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
1385
1385
|
// @ts-ignore: type is checked above.
|
|
1386
|
-
this.${fieldName} = values.${property.pluralName};
|
|
1386
|
+
this.${fieldName} = values.${property.pluralName}.slice();
|
|
1387
1387
|
`;
|
|
1388
1388
|
if (!allScalarTypes) yield `
|
|
1389
1389
|
for (let i = 0; i < values.${property.pluralName}.length; i++) {
|
|
@@ -1417,7 +1417,8 @@ async function* generateCloner(typeUri, types) {
|
|
|
1417
1417
|
*
|
|
1418
1418
|
* @param values The values to update the clone with.
|
|
1419
1419
|
* @param options The options to use for cloning.
|
|
1420
|
-
* @returns The cloned instance.
|
|
1420
|
+
* @returns The cloned instance with its own property arrays. Nested objects
|
|
1421
|
+
* and URLs are shared with this instance.
|
|
1421
1422
|
*/
|
|
1422
1423
|
${emitOverride$1(typeUri, types)} clone(
|
|
1423
1424
|
values:
|
|
@@ -1453,7 +1454,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1453
1454
|
const fieldName = await getFieldName(property.uri);
|
|
1454
1455
|
const trustFieldName = await getFieldName(property.uri, "#_trust");
|
|
1455
1456
|
const allScalarTypes = areAllScalarTypes(property.range, types);
|
|
1456
|
-
yield `clone.${fieldName} = this.${fieldName};`;
|
|
1457
|
+
yield `clone.${fieldName} = this.${fieldName}.slice();`;
|
|
1457
1458
|
if (!allScalarTypes) yield `clone.${trustFieldName} = new Set(this.${trustFieldName});`;
|
|
1458
1459
|
if (hasSingularAccessor(property)) {
|
|
1459
1460
|
let typeGuards = getTypeGuards(property.range, types, `values.${property.singularName}`);
|
|
@@ -1504,7 +1505,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1504
1505
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
1505
1506
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
1506
1507
|
// @ts-ignore: type is checked above.
|
|
1507
|
-
clone.${fieldName} = values.${property.pluralName};
|
|
1508
|
+
clone.${fieldName} = values.${property.pluralName}.slice();
|
|
1508
1509
|
`;
|
|
1509
1510
|
if (!allScalarTypes) yield `
|
|
1510
1511
|
clone.${trustFieldName} = new Set();
|
|
@@ -2336,6 +2337,7 @@ const RUNTIME_IMPORTS = [
|
|
|
2336
2337
|
"isDecimal",
|
|
2337
2338
|
"isGatewayUrl",
|
|
2338
2339
|
"LanguageString",
|
|
2340
|
+
"normalizeLanguageTag",
|
|
2339
2341
|
"parseDecimal",
|
|
2340
2342
|
"parseGatewayUrl",
|
|
2341
2343
|
"parseIri",
|
|
@@ -2548,7 +2550,7 @@ function inspectIri(iri: URL): string {
|
|
|
2548
2550
|
yield `
|
|
2549
2551
|
function isValidLanguageTag(language: string): boolean {
|
|
2550
2552
|
try {
|
|
2551
|
-
new Intl.Locale(language);
|
|
2553
|
+
new Intl.Locale(normalizeLanguageTag(language));
|
|
2552
2554
|
return true;
|
|
2553
2555
|
} catch (error) {
|
|
2554
2556
|
if (error instanceof RangeError) return false;
|
package/dist/mod.js
CHANGED
|
@@ -7,7 +7,7 @@ import { parse } from "yaml";
|
|
|
7
7
|
import { pascalCase } from "es-toolkit";
|
|
8
8
|
//#region deno.json
|
|
9
9
|
var name = "@fedify/vocab-tools";
|
|
10
|
-
var version = "2.4.
|
|
10
|
+
var version = "2.4.1";
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/type.ts
|
|
13
13
|
const HEURISTICS_CONTEXTS = [
|
|
@@ -302,7 +302,7 @@ const scalarTypes = {
|
|
|
302
302
|
&& typeof ${v}["@value"] === "string" && !("@language" in ${v})`;
|
|
303
303
|
},
|
|
304
304
|
decoder(v) {
|
|
305
|
-
return `new Intl.Locale(${v}["@value"])`;
|
|
305
|
+
return `new Intl.Locale(normalizeLanguageTag(${v}["@value"]))`;
|
|
306
306
|
}
|
|
307
307
|
},
|
|
308
308
|
"fedify:url": {
|
|
@@ -1382,7 +1382,7 @@ async function* generateConstructor(typeUri, types) {
|
|
|
1382
1382
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
1383
1383
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
1384
1384
|
// @ts-ignore: type is checked above.
|
|
1385
|
-
this.${fieldName} = values.${property.pluralName};
|
|
1385
|
+
this.${fieldName} = values.${property.pluralName}.slice();
|
|
1386
1386
|
`;
|
|
1387
1387
|
if (!allScalarTypes) yield `
|
|
1388
1388
|
for (let i = 0; i < values.${property.pluralName}.length; i++) {
|
|
@@ -1416,7 +1416,8 @@ async function* generateCloner(typeUri, types) {
|
|
|
1416
1416
|
*
|
|
1417
1417
|
* @param values The values to update the clone with.
|
|
1418
1418
|
* @param options The options to use for cloning.
|
|
1419
|
-
* @returns The cloned instance.
|
|
1419
|
+
* @returns The cloned instance with its own property arrays. Nested objects
|
|
1420
|
+
* and URLs are shared with this instance.
|
|
1420
1421
|
*/
|
|
1421
1422
|
${emitOverride$1(typeUri, types)} clone(
|
|
1422
1423
|
values:
|
|
@@ -1452,7 +1453,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1452
1453
|
const fieldName = await getFieldName(property.uri);
|
|
1453
1454
|
const trustFieldName = await getFieldName(property.uri, "#_trust");
|
|
1454
1455
|
const allScalarTypes = areAllScalarTypes(property.range, types);
|
|
1455
|
-
yield `clone.${fieldName} = this.${fieldName};`;
|
|
1456
|
+
yield `clone.${fieldName} = this.${fieldName}.slice();`;
|
|
1456
1457
|
if (!allScalarTypes) yield `clone.${trustFieldName} = new Set(this.${trustFieldName});`;
|
|
1457
1458
|
if (hasSingularAccessor(property)) {
|
|
1458
1459
|
let typeGuards = getTypeGuards(property.range, types, `values.${property.singularName}`);
|
|
@@ -1503,7 +1504,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1503
1504
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
1504
1505
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
1505
1506
|
// @ts-ignore: type is checked above.
|
|
1506
|
-
clone.${fieldName} = values.${property.pluralName};
|
|
1507
|
+
clone.${fieldName} = values.${property.pluralName}.slice();
|
|
1507
1508
|
`;
|
|
1508
1509
|
if (!allScalarTypes) yield `
|
|
1509
1510
|
clone.${trustFieldName} = new Set();
|
|
@@ -2335,6 +2336,7 @@ const RUNTIME_IMPORTS = [
|
|
|
2335
2336
|
"isDecimal",
|
|
2336
2337
|
"isGatewayUrl",
|
|
2337
2338
|
"LanguageString",
|
|
2339
|
+
"normalizeLanguageTag",
|
|
2338
2340
|
"parseDecimal",
|
|
2339
2341
|
"parseGatewayUrl",
|
|
2340
2342
|
"parseIri",
|
|
@@ -2547,7 +2549,7 @@ function inspectIri(iri: URL): string {
|
|
|
2547
2549
|
yield `
|
|
2548
2550
|
function isValidLanguageTag(language: string): boolean {
|
|
2549
2551
|
try {
|
|
2550
|
-
new Intl.Locale(language);
|
|
2552
|
+
new Intl.Locale(normalizeLanguageTag(language));
|
|
2551
2553
|
return true;
|
|
2552
2554
|
} catch (error) {
|
|
2553
2555
|
if (error instanceof RangeError) return false;
|