@fedify/vocab-tools 2.2.15 → 2.2.16
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 +558 -478
- package/src/__snapshots__/class.test.ts.node.snap +558 -478
- package/src/__snapshots__/class.test.ts.snap +558 -478
- 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.2.
|
|
11
|
+
var version = "2.2.16";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/type.ts
|
|
14
14
|
const HEURISTICS_CONTEXTS = [
|
|
@@ -316,7 +316,7 @@ const scalarTypes = {
|
|
|
316
316
|
&& typeof ${v}["@value"] === "string" && !("@language" in ${v})`;
|
|
317
317
|
},
|
|
318
318
|
decoder(v) {
|
|
319
|
-
return `new Intl.Locale(${v}["@value"])`;
|
|
319
|
+
return `new Intl.Locale(normalizeLanguageTag(${v}["@value"]))`;
|
|
320
320
|
}
|
|
321
321
|
},
|
|
322
322
|
"fedify:url": {
|
|
@@ -1247,7 +1247,7 @@ async function* generateConstructor(typeUri, types) {
|
|
|
1247
1247
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
1248
1248
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
1249
1249
|
// @ts-ignore: type is checked above.
|
|
1250
|
-
this.${fieldName} = values.${property.pluralName};
|
|
1250
|
+
this.${fieldName} = values.${property.pluralName}.slice();
|
|
1251
1251
|
`;
|
|
1252
1252
|
if (!allScalarTypes) yield `
|
|
1253
1253
|
for (let i = 0; i < values.${property.pluralName}.length; i++) {
|
|
@@ -1274,7 +1274,8 @@ async function* generateCloner(typeUri, types) {
|
|
|
1274
1274
|
* Clones this instance, optionally updating it with the given values.
|
|
1275
1275
|
* @param values The values to update the clone with.
|
|
1276
1276
|
* @param options The options to use for cloning.
|
|
1277
|
-
* @returns The cloned instance.
|
|
1277
|
+
* @returns The cloned instance with its own property arrays. Nested objects
|
|
1278
|
+
* and URLs are shared with this instance.
|
|
1278
1279
|
*/
|
|
1279
1280
|
${emitOverride$1(typeUri, types)} clone(
|
|
1280
1281
|
values:
|
|
@@ -1308,7 +1309,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1308
1309
|
const fieldName = await getFieldName(property.uri);
|
|
1309
1310
|
const trustFieldName = await getFieldName(property.uri, "#_trust");
|
|
1310
1311
|
const allScalarTypes = areAllScalarTypes(property.range, types);
|
|
1311
|
-
yield `clone.${fieldName} = this.${fieldName};`;
|
|
1312
|
+
yield `clone.${fieldName} = this.${fieldName}.slice();`;
|
|
1312
1313
|
if (!allScalarTypes) yield `clone.${trustFieldName} = new Set(this.${trustFieldName});`;
|
|
1313
1314
|
if (hasSingularAccessor(property)) {
|
|
1314
1315
|
let typeGuards = getTypeGuards(property.range, types, `values.${property.singularName}`);
|
|
@@ -1359,7 +1360,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1359
1360
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
1360
1361
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
1361
1362
|
// @ts-ignore: type is checked above.
|
|
1362
|
-
clone.${fieldName} = values.${property.pluralName};
|
|
1363
|
+
clone.${fieldName} = values.${property.pluralName}.slice();
|
|
1363
1364
|
`;
|
|
1364
1365
|
if (!allScalarTypes) yield `
|
|
1365
1366
|
clone.${trustFieldName} = new Set();
|
|
@@ -2028,6 +2029,7 @@ async function* generateClasses(types) {
|
|
|
2028
2029
|
"importPem",
|
|
2029
2030
|
"isDecimal",
|
|
2030
2031
|
"LanguageString",
|
|
2032
|
+
"normalizeLanguageTag",
|
|
2031
2033
|
"parseDecimal",
|
|
2032
2034
|
"type RemoteDocument"
|
|
2033
2035
|
];
|
|
@@ -2055,7 +2057,7 @@ function decodeIri(iri: string): URL {
|
|
|
2055
2057
|
yield `
|
|
2056
2058
|
function isValidLanguageTag(language: string): boolean {
|
|
2057
2059
|
try {
|
|
2058
|
-
new Intl.Locale(language);
|
|
2060
|
+
new Intl.Locale(normalizeLanguageTag(language));
|
|
2059
2061
|
return true;
|
|
2060
2062
|
} catch (error) {
|
|
2061
2063
|
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.2.
|
|
10
|
+
var version = "2.2.16";
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/type.ts
|
|
13
13
|
const HEURISTICS_CONTEXTS = [
|
|
@@ -315,7 +315,7 @@ const scalarTypes = {
|
|
|
315
315
|
&& typeof ${v}["@value"] === "string" && !("@language" in ${v})`;
|
|
316
316
|
},
|
|
317
317
|
decoder(v) {
|
|
318
|
-
return `new Intl.Locale(${v}["@value"])`;
|
|
318
|
+
return `new Intl.Locale(normalizeLanguageTag(${v}["@value"]))`;
|
|
319
319
|
}
|
|
320
320
|
},
|
|
321
321
|
"fedify:url": {
|
|
@@ -1246,7 +1246,7 @@ async function* generateConstructor(typeUri, types) {
|
|
|
1246
1246
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
1247
1247
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
1248
1248
|
// @ts-ignore: type is checked above.
|
|
1249
|
-
this.${fieldName} = values.${property.pluralName};
|
|
1249
|
+
this.${fieldName} = values.${property.pluralName}.slice();
|
|
1250
1250
|
`;
|
|
1251
1251
|
if (!allScalarTypes) yield `
|
|
1252
1252
|
for (let i = 0; i < values.${property.pluralName}.length; i++) {
|
|
@@ -1273,7 +1273,8 @@ async function* generateCloner(typeUri, types) {
|
|
|
1273
1273
|
* Clones this instance, optionally updating it with the given values.
|
|
1274
1274
|
* @param values The values to update the clone with.
|
|
1275
1275
|
* @param options The options to use for cloning.
|
|
1276
|
-
* @returns The cloned instance.
|
|
1276
|
+
* @returns The cloned instance with its own property arrays. Nested objects
|
|
1277
|
+
* and URLs are shared with this instance.
|
|
1277
1278
|
*/
|
|
1278
1279
|
${emitOverride$1(typeUri, types)} clone(
|
|
1279
1280
|
values:
|
|
@@ -1307,7 +1308,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1307
1308
|
const fieldName = await getFieldName(property.uri);
|
|
1308
1309
|
const trustFieldName = await getFieldName(property.uri, "#_trust");
|
|
1309
1310
|
const allScalarTypes = areAllScalarTypes(property.range, types);
|
|
1310
|
-
yield `clone.${fieldName} = this.${fieldName};`;
|
|
1311
|
+
yield `clone.${fieldName} = this.${fieldName}.slice();`;
|
|
1311
1312
|
if (!allScalarTypes) yield `clone.${trustFieldName} = new Set(this.${trustFieldName});`;
|
|
1312
1313
|
if (hasSingularAccessor(property)) {
|
|
1313
1314
|
let typeGuards = getTypeGuards(property.range, types, `values.${property.singularName}`);
|
|
@@ -1358,7 +1359,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1358
1359
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
1359
1360
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
1360
1361
|
// @ts-ignore: type is checked above.
|
|
1361
|
-
clone.${fieldName} = values.${property.pluralName};
|
|
1362
|
+
clone.${fieldName} = values.${property.pluralName}.slice();
|
|
1362
1363
|
`;
|
|
1363
1364
|
if (!allScalarTypes) yield `
|
|
1364
1365
|
clone.${trustFieldName} = new Set();
|
|
@@ -2027,6 +2028,7 @@ async function* generateClasses(types) {
|
|
|
2027
2028
|
"importPem",
|
|
2028
2029
|
"isDecimal",
|
|
2029
2030
|
"LanguageString",
|
|
2031
|
+
"normalizeLanguageTag",
|
|
2030
2032
|
"parseDecimal",
|
|
2031
2033
|
"type RemoteDocument"
|
|
2032
2034
|
];
|
|
@@ -2054,7 +2056,7 @@ function decodeIri(iri: string): URL {
|
|
|
2054
2056
|
yield `
|
|
2055
2057
|
function isValidLanguageTag(language: string): boolean {
|
|
2056
2058
|
try {
|
|
2057
|
-
new Intl.Locale(language);
|
|
2059
|
+
new Intl.Locale(normalizeLanguageTag(language));
|
|
2058
2060
|
return true;
|
|
2059
2061
|
} catch (error) {
|
|
2060
2062
|
if (error instanceof RangeError) return false;
|