@fedify/vocab-tools 2.5.0-dev.2314 → 2.5.0-dev.2332

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-tools",
3
- "version": "2.5.0-dev.2314+d73be480",
3
+ "version": "2.5.0-dev.2332+d4e3f91f",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts"
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.5.0-dev.2314+d73be480";
11
+ var version = "2.5.0-dev.2332+d4e3f91f";
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": {
@@ -1386,7 +1386,7 @@ async function* generateConstructor(typeUri, types) {
1386
1386
  if (Array.isArray(values.${property.pluralName}) &&
1387
1387
  values.${property.pluralName}.every(v => ${typeGuards})) {
1388
1388
  // @ts-ignore: type is checked above.
1389
- this.${fieldName} = values.${property.pluralName};
1389
+ this.${fieldName} = values.${property.pluralName}.slice();
1390
1390
  `;
1391
1391
  if (!allScalarTypes) yield `
1392
1392
  for (let i = 0; i < values.${property.pluralName}.length; i++) {
@@ -1420,7 +1420,8 @@ async function* generateCloner(typeUri, types) {
1420
1420
  *
1421
1421
  * @param values The values to update the clone with.
1422
1422
  * @param options The options to use for cloning.
1423
- * @returns The cloned instance.
1423
+ * @returns The cloned instance with its own property arrays. Nested objects
1424
+ * and URLs are shared with this instance.
1424
1425
  */
1425
1426
  ${emitOverride$1(typeUri, types)} clone(
1426
1427
  values:
@@ -1456,7 +1457,7 @@ async function* generateCloner(typeUri, types) {
1456
1457
  const fieldName = await getFieldName(property.uri);
1457
1458
  const trustFieldName = await getFieldName(property.uri, "#_trust");
1458
1459
  const allScalarTypes = areAllScalarTypes(property.range, types);
1459
- yield `clone.${fieldName} = this.${fieldName};`;
1460
+ yield `clone.${fieldName} = this.${fieldName}.slice();`;
1460
1461
  if (!allScalarTypes) yield `clone.${trustFieldName} = new Set(this.${trustFieldName});`;
1461
1462
  if (hasSingularAccessor(property)) {
1462
1463
  let typeGuards = getTypeGuards(property.range, types, `values.${property.singularName}`);
@@ -1507,7 +1508,7 @@ async function* generateCloner(typeUri, types) {
1507
1508
  if (Array.isArray(values.${property.pluralName}) &&
1508
1509
  values.${property.pluralName}.every(v => ${typeGuards})) {
1509
1510
  // @ts-ignore: type is checked above.
1510
- clone.${fieldName} = values.${property.pluralName};
1511
+ clone.${fieldName} = values.${property.pluralName}.slice();
1511
1512
  `;
1512
1513
  if (!allScalarTypes) yield `
1513
1514
  clone.${trustFieldName} = new Set();
@@ -2339,6 +2340,7 @@ const RUNTIME_IMPORTS = [
2339
2340
  "isDecimal",
2340
2341
  "isGatewayUrl",
2341
2342
  "LanguageString",
2343
+ "normalizeLanguageTag",
2342
2344
  "parseDecimal",
2343
2345
  "parseGatewayUrl",
2344
2346
  "parseIri",
@@ -2551,7 +2553,7 @@ function inspectIri(iri: URL): string {
2551
2553
  yield `
2552
2554
  function isValidLanguageTag(language: string): boolean {
2553
2555
  try {
2554
- new Intl.Locale(language);
2556
+ new Intl.Locale(normalizeLanguageTag(language));
2555
2557
  return true;
2556
2558
  } catch (error) {
2557
2559
  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.5.0-dev.2314+d73be480";
10
+ var version = "2.5.0-dev.2332+d4e3f91f";
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": {
@@ -1385,7 +1385,7 @@ async function* generateConstructor(typeUri, types) {
1385
1385
  if (Array.isArray(values.${property.pluralName}) &&
1386
1386
  values.${property.pluralName}.every(v => ${typeGuards})) {
1387
1387
  // @ts-ignore: type is checked above.
1388
- this.${fieldName} = values.${property.pluralName};
1388
+ this.${fieldName} = values.${property.pluralName}.slice();
1389
1389
  `;
1390
1390
  if (!allScalarTypes) yield `
1391
1391
  for (let i = 0; i < values.${property.pluralName}.length; i++) {
@@ -1419,7 +1419,8 @@ async function* generateCloner(typeUri, types) {
1419
1419
  *
1420
1420
  * @param values The values to update the clone with.
1421
1421
  * @param options The options to use for cloning.
1422
- * @returns The cloned instance.
1422
+ * @returns The cloned instance with its own property arrays. Nested objects
1423
+ * and URLs are shared with this instance.
1423
1424
  */
1424
1425
  ${emitOverride$1(typeUri, types)} clone(
1425
1426
  values:
@@ -1455,7 +1456,7 @@ async function* generateCloner(typeUri, types) {
1455
1456
  const fieldName = await getFieldName(property.uri);
1456
1457
  const trustFieldName = await getFieldName(property.uri, "#_trust");
1457
1458
  const allScalarTypes = areAllScalarTypes(property.range, types);
1458
- yield `clone.${fieldName} = this.${fieldName};`;
1459
+ yield `clone.${fieldName} = this.${fieldName}.slice();`;
1459
1460
  if (!allScalarTypes) yield `clone.${trustFieldName} = new Set(this.${trustFieldName});`;
1460
1461
  if (hasSingularAccessor(property)) {
1461
1462
  let typeGuards = getTypeGuards(property.range, types, `values.${property.singularName}`);
@@ -1506,7 +1507,7 @@ async function* generateCloner(typeUri, types) {
1506
1507
  if (Array.isArray(values.${property.pluralName}) &&
1507
1508
  values.${property.pluralName}.every(v => ${typeGuards})) {
1508
1509
  // @ts-ignore: type is checked above.
1509
- clone.${fieldName} = values.${property.pluralName};
1510
+ clone.${fieldName} = values.${property.pluralName}.slice();
1510
1511
  `;
1511
1512
  if (!allScalarTypes) yield `
1512
1513
  clone.${trustFieldName} = new Set();
@@ -2338,6 +2339,7 @@ const RUNTIME_IMPORTS = [
2338
2339
  "isDecimal",
2339
2340
  "isGatewayUrl",
2340
2341
  "LanguageString",
2342
+ "normalizeLanguageTag",
2341
2343
  "parseDecimal",
2342
2344
  "parseGatewayUrl",
2343
2345
  "parseIri",
@@ -2550,7 +2552,7 @@ function inspectIri(iri: URL): string {
2550
2552
  yield `
2551
2553
  function isValidLanguageTag(language: string): boolean {
2552
2554
  try {
2553
- new Intl.Locale(language);
2555
+ new Intl.Locale(normalizeLanguageTag(language));
2554
2556
  return true;
2555
2557
  } catch (error) {
2556
2558
  if (error instanceof RangeError) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-tools",
3
- "version": "2.5.0-dev.2314+d73be480",
3
+ "version": "2.5.0-dev.2332+d4e3f91f",
4
4
  "description": "Code generator for Activity Vocabulary APIs",
5
5
  "homepage": "https://fedify.dev/",
6
6
  "repository": {
@@ -51,7 +51,7 @@
51
51
  "@types/node": "^24.12.2",
52
52
  "tsdown": "^0.22.0",
53
53
  "typescript": "^6.0.0",
54
- "@fedify/vocab-runtime": "^2.5.0-dev.2314+d73be480"
54
+ "@fedify/vocab-runtime": "^2.5.0-dev.2332+d4e3f91f"
55
55
  },
56
56
  "dependencies": {
57
57
  "@cfworker/json-schema": "^4.1.1",