@fedify/vocab-tools 2.3.11-dev.2296 → 2.3.12-dev.2341
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 +566 -484
- package/src/__snapshots__/class.test.ts.node.snap +566 -484
- package/src/__snapshots__/class.test.ts.snap +566 -484
- 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.3.
|
|
11
|
+
var version = "2.3.12-dev.2341+eb343ebf";
|
|
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": {
|
|
@@ -1287,7 +1287,7 @@ async function* generateConstructor(typeUri, types) {
|
|
|
1287
1287
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
1288
1288
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
1289
1289
|
// @ts-ignore: type is checked above.
|
|
1290
|
-
this.${fieldName} = values.${property.pluralName};
|
|
1290
|
+
this.${fieldName} = values.${property.pluralName}.slice();
|
|
1291
1291
|
`;
|
|
1292
1292
|
if (!allScalarTypes) yield `
|
|
1293
1293
|
for (let i = 0; i < values.${property.pluralName}.length; i++) {
|
|
@@ -1314,7 +1314,8 @@ async function* generateCloner(typeUri, types) {
|
|
|
1314
1314
|
* Clones this instance, optionally updating it with the given values.
|
|
1315
1315
|
* @param values The values to update the clone with.
|
|
1316
1316
|
* @param options The options to use for cloning.
|
|
1317
|
-
* @returns The cloned instance.
|
|
1317
|
+
* @returns The cloned instance with its own property arrays. Nested objects
|
|
1318
|
+
* and URLs are shared with this instance.
|
|
1318
1319
|
*/
|
|
1319
1320
|
${emitOverride$1(typeUri, types)} clone(
|
|
1320
1321
|
values:
|
|
@@ -1348,7 +1349,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1348
1349
|
const fieldName = await getFieldName(property.uri);
|
|
1349
1350
|
const trustFieldName = await getFieldName(property.uri, "#_trust");
|
|
1350
1351
|
const allScalarTypes = areAllScalarTypes(property.range, types);
|
|
1351
|
-
yield `clone.${fieldName} = this.${fieldName};`;
|
|
1352
|
+
yield `clone.${fieldName} = this.${fieldName}.slice();`;
|
|
1352
1353
|
if (!allScalarTypes) yield `clone.${trustFieldName} = new Set(this.${trustFieldName});`;
|
|
1353
1354
|
if (hasSingularAccessor(property)) {
|
|
1354
1355
|
let typeGuards = getTypeGuards(property.range, types, `values.${property.singularName}`);
|
|
@@ -1399,7 +1400,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1399
1400
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
1400
1401
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
1401
1402
|
// @ts-ignore: type is checked above.
|
|
1402
|
-
clone.${fieldName} = values.${property.pluralName};
|
|
1403
|
+
clone.${fieldName} = values.${property.pluralName}.slice();
|
|
1403
1404
|
`;
|
|
1404
1405
|
if (!allScalarTypes) yield `
|
|
1405
1406
|
clone.${trustFieldName} = new Set();
|
|
@@ -2116,6 +2117,7 @@ async function* generateClasses(types) {
|
|
|
2116
2117
|
"importPem",
|
|
2117
2118
|
"isDecimal",
|
|
2118
2119
|
"LanguageString",
|
|
2120
|
+
"normalizeLanguageTag",
|
|
2119
2121
|
"parseDecimal",
|
|
2120
2122
|
"type RemoteDocument"
|
|
2121
2123
|
];
|
|
@@ -2143,7 +2145,7 @@ function decodeIri(iri: string): URL {
|
|
|
2143
2145
|
yield `
|
|
2144
2146
|
function isValidLanguageTag(language: string): boolean {
|
|
2145
2147
|
try {
|
|
2146
|
-
new Intl.Locale(language);
|
|
2148
|
+
new Intl.Locale(normalizeLanguageTag(language));
|
|
2147
2149
|
return true;
|
|
2148
2150
|
} catch (error) {
|
|
2149
2151
|
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.3.
|
|
10
|
+
var version = "2.3.12-dev.2341+eb343ebf";
|
|
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": {
|
|
@@ -1286,7 +1286,7 @@ async function* generateConstructor(typeUri, types) {
|
|
|
1286
1286
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
1287
1287
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
1288
1288
|
// @ts-ignore: type is checked above.
|
|
1289
|
-
this.${fieldName} = values.${property.pluralName};
|
|
1289
|
+
this.${fieldName} = values.${property.pluralName}.slice();
|
|
1290
1290
|
`;
|
|
1291
1291
|
if (!allScalarTypes) yield `
|
|
1292
1292
|
for (let i = 0; i < values.${property.pluralName}.length; i++) {
|
|
@@ -1313,7 +1313,8 @@ async function* generateCloner(typeUri, types) {
|
|
|
1313
1313
|
* Clones this instance, optionally updating it with the given values.
|
|
1314
1314
|
* @param values The values to update the clone with.
|
|
1315
1315
|
* @param options The options to use for cloning.
|
|
1316
|
-
* @returns The cloned instance.
|
|
1316
|
+
* @returns The cloned instance with its own property arrays. Nested objects
|
|
1317
|
+
* and URLs are shared with this instance.
|
|
1317
1318
|
*/
|
|
1318
1319
|
${emitOverride$1(typeUri, types)} clone(
|
|
1319
1320
|
values:
|
|
@@ -1347,7 +1348,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1347
1348
|
const fieldName = await getFieldName(property.uri);
|
|
1348
1349
|
const trustFieldName = await getFieldName(property.uri, "#_trust");
|
|
1349
1350
|
const allScalarTypes = areAllScalarTypes(property.range, types);
|
|
1350
|
-
yield `clone.${fieldName} = this.${fieldName};`;
|
|
1351
|
+
yield `clone.${fieldName} = this.${fieldName}.slice();`;
|
|
1351
1352
|
if (!allScalarTypes) yield `clone.${trustFieldName} = new Set(this.${trustFieldName});`;
|
|
1352
1353
|
if (hasSingularAccessor(property)) {
|
|
1353
1354
|
let typeGuards = getTypeGuards(property.range, types, `values.${property.singularName}`);
|
|
@@ -1398,7 +1399,7 @@ async function* generateCloner(typeUri, types) {
|
|
|
1398
1399
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
1399
1400
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
1400
1401
|
// @ts-ignore: type is checked above.
|
|
1401
|
-
clone.${fieldName} = values.${property.pluralName};
|
|
1402
|
+
clone.${fieldName} = values.${property.pluralName}.slice();
|
|
1402
1403
|
`;
|
|
1403
1404
|
if (!allScalarTypes) yield `
|
|
1404
1405
|
clone.${trustFieldName} = new Set();
|
|
@@ -2115,6 +2116,7 @@ async function* generateClasses(types) {
|
|
|
2115
2116
|
"importPem",
|
|
2116
2117
|
"isDecimal",
|
|
2117
2118
|
"LanguageString",
|
|
2119
|
+
"normalizeLanguageTag",
|
|
2118
2120
|
"parseDecimal",
|
|
2119
2121
|
"type RemoteDocument"
|
|
2120
2122
|
];
|
|
@@ -2142,7 +2144,7 @@ function decodeIri(iri: string): URL {
|
|
|
2142
2144
|
yield `
|
|
2143
2145
|
function isValidLanguageTag(language: string): boolean {
|
|
2144
2146
|
try {
|
|
2145
|
-
new Intl.Locale(language);
|
|
2147
|
+
new Intl.Locale(normalizeLanguageTag(language));
|
|
2146
2148
|
return true;
|
|
2147
2149
|
} catch (error) {
|
|
2148
2150
|
if (error instanceof RangeError) return false;
|