@fedify/vocab-tools 2.2.15 → 2.2.17
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/src/class.ts
CHANGED
|
@@ -196,6 +196,7 @@ export async function* generateClasses(
|
|
|
196
196
|
"importPem",
|
|
197
197
|
"isDecimal",
|
|
198
198
|
"LanguageString",
|
|
199
|
+
"normalizeLanguageTag",
|
|
199
200
|
"parseDecimal",
|
|
200
201
|
"type RemoteDocument",
|
|
201
202
|
];
|
|
@@ -225,7 +226,7 @@ function decodeIri(iri: string): URL {
|
|
|
225
226
|
yield `
|
|
226
227
|
function isValidLanguageTag(language: string): boolean {
|
|
227
228
|
try {
|
|
228
|
-
new Intl.Locale(language);
|
|
229
|
+
new Intl.Locale(normalizeLanguageTag(language));
|
|
229
230
|
return true;
|
|
230
231
|
} catch (error) {
|
|
231
232
|
if (error instanceof RangeError) return false;
|
package/src/constructor.ts
CHANGED
|
@@ -175,7 +175,7 @@ export async function* generateConstructor(
|
|
|
175
175
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
176
176
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
177
177
|
// @ts-ignore: type is checked above.
|
|
178
|
-
this.${fieldName} = values.${property.pluralName};
|
|
178
|
+
this.${fieldName} = values.${property.pluralName}.slice();
|
|
179
179
|
`;
|
|
180
180
|
if (!allScalarTypes) {
|
|
181
181
|
yield `
|
|
@@ -208,7 +208,8 @@ export async function* generateCloner(
|
|
|
208
208
|
* Clones this instance, optionally updating it with the given values.
|
|
209
209
|
* @param values The values to update the clone with.
|
|
210
210
|
* @param options The options to use for cloning.
|
|
211
|
-
* @returns The cloned instance.
|
|
211
|
+
* @returns The cloned instance with its own property arrays. Nested objects
|
|
212
|
+
* and URLs are shared with this instance.
|
|
212
213
|
*/
|
|
213
214
|
${emitOverride(typeUri, types)} clone(
|
|
214
215
|
values:
|
|
@@ -245,7 +246,7 @@ export async function* generateCloner(
|
|
|
245
246
|
const fieldName = await getFieldName(property.uri);
|
|
246
247
|
const trustFieldName = await getFieldName(property.uri, "#_trust");
|
|
247
248
|
const allScalarTypes = areAllScalarTypes(property.range, types);
|
|
248
|
-
yield `clone.${fieldName} = this.${fieldName};`;
|
|
249
|
+
yield `clone.${fieldName} = this.${fieldName}.slice();`;
|
|
249
250
|
if (!allScalarTypes) {
|
|
250
251
|
yield `clone.${trustFieldName} = new Set(this.${trustFieldName});`;
|
|
251
252
|
}
|
|
@@ -309,7 +310,7 @@ export async function* generateCloner(
|
|
|
309
310
|
if (Array.isArray(values.${property.pluralName}) &&
|
|
310
311
|
values.${property.pluralName}.every(v => ${typeGuards})) {
|
|
311
312
|
// @ts-ignore: type is checked above.
|
|
312
|
-
clone.${fieldName} = values.${property.pluralName};
|
|
313
|
+
clone.${fieldName} = values.${property.pluralName}.slice();
|
|
313
314
|
`;
|
|
314
315
|
if (!allScalarTypes) {
|
|
315
316
|
yield `
|
package/src/type.ts
CHANGED
|
@@ -323,7 +323,7 @@ const scalarTypes: Record<string, ScalarType> = {
|
|
|
323
323
|
&& typeof ${v}["@value"] === "string" && !("@language" in ${v})`;
|
|
324
324
|
},
|
|
325
325
|
decoder(v) {
|
|
326
|
-
return `new Intl.Locale(${v}["@value"])`;
|
|
326
|
+
return `new Intl.Locale(normalizeLanguageTag(${v}["@value"]))`;
|
|
327
327
|
},
|
|
328
328
|
},
|
|
329
329
|
"fedify:url": {
|