@fedify/vocab-tools 2.4.0-dev.2247 → 2.4.0-dev.2256
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 +15 -8
- package/dist/mod.js +15 -8
- package/package.json +1 -1
- package/src/__snapshots__/class.test.ts.deno.snap +624 -617
- package/src/__snapshots__/class.test.ts.node.snap +624 -617
- package/src/__snapshots__/class.test.ts.snap +624 -617
- package/src/class.ts +7 -0
- package/src/codec.ts +4 -1
- package/src/inspector.ts +4 -4
- package/src/type.ts +2 -2
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.0-dev.
|
|
11
|
+
var version = "2.4.0-dev.2256+683c50ba";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/type.ts
|
|
14
14
|
const HEURISTICS_CONTEXTS = [
|
|
@@ -333,10 +333,10 @@ const scalarTypes = {
|
|
|
333
333
|
return `${v} instanceof URL && isGatewayUrl(${v})`;
|
|
334
334
|
},
|
|
335
335
|
encoder(v) {
|
|
336
|
-
return `{ "@id":
|
|
336
|
+
return `{ "@id": ${v}.origin }`;
|
|
337
337
|
},
|
|
338
338
|
compactEncoder(v) {
|
|
339
|
-
return
|
|
339
|
+
return `${v}.origin`;
|
|
340
340
|
},
|
|
341
341
|
dataCheck(v) {
|
|
342
342
|
return `${v} != null && typeof ${v} === "object" &&
|
|
@@ -1165,7 +1165,7 @@ async function* generateDecoder(typeUri, types, moduleVarNames) {
|
|
|
1165
1165
|
yield await generateField(property, types, "const ");
|
|
1166
1166
|
const arrayVariable = `${variable}__array`;
|
|
1167
1167
|
yield `
|
|
1168
|
-
let ${arrayVariable} = values[${JSON.stringify(property.uri)}];
|
|
1168
|
+
let ${arrayVariable} = ${property.uri === "https://w3id.org/fep/ef61/gateways" ? "getPortableActorGateways(values) as typeof values[string]" : `values[${JSON.stringify(property.uri)}]`};
|
|
1169
1169
|
`;
|
|
1170
1170
|
if (property.functional && property.redundantProperties != null) for (const prop of property.redundantProperties) yield `
|
|
1171
1171
|
if (${arrayVariable} == null || ${arrayVariable}.length < 1) {
|
|
@@ -1542,12 +1542,12 @@ async function* generateInspector(typeUri, types) {
|
|
|
1542
1542
|
[Symbol.for("Deno.customInspect")]: (
|
|
1543
1543
|
inspect: typeof Deno.inspect,
|
|
1544
1544
|
options: Deno.InspectOptions,
|
|
1545
|
-
): string => "URL " + inspect(this.id
|
|
1545
|
+
): string => "URL " + inspect(inspectIri(this.id!), options),
|
|
1546
1546
|
[Symbol.for("nodejs.util.inspect.custom")]: (
|
|
1547
1547
|
_depth: number,
|
|
1548
1548
|
options: unknown,
|
|
1549
1549
|
inspect: (value: unknown, options: unknown) => string,
|
|
1550
|
-
): string => "URL " + inspect(this.id
|
|
1550
|
+
): string => "URL " + inspect(inspectIri(this.id!), options),
|
|
1551
1551
|
};
|
|
1552
1552
|
}
|
|
1553
1553
|
`;
|
|
@@ -1563,12 +1563,12 @@ async function* generateInspector(typeUri, types) {
|
|
|
1563
1563
|
[Symbol.for("Deno.customInspect")]: (
|
|
1564
1564
|
inspect: typeof Deno.inspect,
|
|
1565
1565
|
options: Deno.InspectOptions,
|
|
1566
|
-
): string => "URL " + inspect(v
|
|
1566
|
+
): string => "URL " + inspect(inspectIri(v), options),
|
|
1567
1567
|
[Symbol.for("nodejs.util.inspect.custom")]: (
|
|
1568
1568
|
_depth: number,
|
|
1569
1569
|
options: unknown,
|
|
1570
1570
|
inspect: (value: unknown, options: unknown) => string,
|
|
1571
|
-
): string => "URL " + inspect(v
|
|
1571
|
+
): string => "URL " + inspect(inspectIri(v), options),
|
|
1572
1572
|
}
|
|
1573
1573
|
: v);
|
|
1574
1574
|
`;
|
|
@@ -2285,6 +2285,7 @@ const INTERNAL_RUNTIME_IMPORTS = [
|
|
|
2285
2285
|
"compactJsonLdCache",
|
|
2286
2286
|
"createScopedContextLoader",
|
|
2287
2287
|
"getJsonLdContext",
|
|
2288
|
+
"getPortableActorGateways",
|
|
2288
2289
|
"isTrustedIriOrigin",
|
|
2289
2290
|
"normalizeJsonLdIris"
|
|
2290
2291
|
].join(",\n ");
|
|
@@ -2527,6 +2528,12 @@ function decodeIri(iri: string): URL {
|
|
|
2527
2528
|
? new URL("at://" + encodeURIComponent(iri.substring(5)))
|
|
2528
2529
|
: parseIri(iri);
|
|
2529
2530
|
}
|
|
2531
|
+
|
|
2532
|
+
function inspectIri(iri: URL): string {
|
|
2533
|
+
// Inspecting an object must not throw, even for a URL that cannot be
|
|
2534
|
+
// formatted as an IRI, e.g., a malformed portable ID:
|
|
2535
|
+
try { return formatIri(iri); } catch { return iri.href; }
|
|
2536
|
+
}
|
|
2530
2537
|
`;
|
|
2531
2538
|
yield `
|
|
2532
2539
|
function isValidLanguageTag(language: string): boolean {
|
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.0-dev.
|
|
10
|
+
var version = "2.4.0-dev.2256+683c50ba";
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/type.ts
|
|
13
13
|
const HEURISTICS_CONTEXTS = [
|
|
@@ -332,10 +332,10 @@ const scalarTypes = {
|
|
|
332
332
|
return `${v} instanceof URL && isGatewayUrl(${v})`;
|
|
333
333
|
},
|
|
334
334
|
encoder(v) {
|
|
335
|
-
return `{ "@id":
|
|
335
|
+
return `{ "@id": ${v}.origin }`;
|
|
336
336
|
},
|
|
337
337
|
compactEncoder(v) {
|
|
338
|
-
return
|
|
338
|
+
return `${v}.origin`;
|
|
339
339
|
},
|
|
340
340
|
dataCheck(v) {
|
|
341
341
|
return `${v} != null && typeof ${v} === "object" &&
|
|
@@ -1164,7 +1164,7 @@ async function* generateDecoder(typeUri, types, moduleVarNames) {
|
|
|
1164
1164
|
yield await generateField(property, types, "const ");
|
|
1165
1165
|
const arrayVariable = `${variable}__array`;
|
|
1166
1166
|
yield `
|
|
1167
|
-
let ${arrayVariable} = values[${JSON.stringify(property.uri)}];
|
|
1167
|
+
let ${arrayVariable} = ${property.uri === "https://w3id.org/fep/ef61/gateways" ? "getPortableActorGateways(values) as typeof values[string]" : `values[${JSON.stringify(property.uri)}]`};
|
|
1168
1168
|
`;
|
|
1169
1169
|
if (property.functional && property.redundantProperties != null) for (const prop of property.redundantProperties) yield `
|
|
1170
1170
|
if (${arrayVariable} == null || ${arrayVariable}.length < 1) {
|
|
@@ -1541,12 +1541,12 @@ async function* generateInspector(typeUri, types) {
|
|
|
1541
1541
|
[Symbol.for("Deno.customInspect")]: (
|
|
1542
1542
|
inspect: typeof Deno.inspect,
|
|
1543
1543
|
options: Deno.InspectOptions,
|
|
1544
|
-
): string => "URL " + inspect(this.id
|
|
1544
|
+
): string => "URL " + inspect(inspectIri(this.id!), options),
|
|
1545
1545
|
[Symbol.for("nodejs.util.inspect.custom")]: (
|
|
1546
1546
|
_depth: number,
|
|
1547
1547
|
options: unknown,
|
|
1548
1548
|
inspect: (value: unknown, options: unknown) => string,
|
|
1549
|
-
): string => "URL " + inspect(this.id
|
|
1549
|
+
): string => "URL " + inspect(inspectIri(this.id!), options),
|
|
1550
1550
|
};
|
|
1551
1551
|
}
|
|
1552
1552
|
`;
|
|
@@ -1562,12 +1562,12 @@ async function* generateInspector(typeUri, types) {
|
|
|
1562
1562
|
[Symbol.for("Deno.customInspect")]: (
|
|
1563
1563
|
inspect: typeof Deno.inspect,
|
|
1564
1564
|
options: Deno.InspectOptions,
|
|
1565
|
-
): string => "URL " + inspect(v
|
|
1565
|
+
): string => "URL " + inspect(inspectIri(v), options),
|
|
1566
1566
|
[Symbol.for("nodejs.util.inspect.custom")]: (
|
|
1567
1567
|
_depth: number,
|
|
1568
1568
|
options: unknown,
|
|
1569
1569
|
inspect: (value: unknown, options: unknown) => string,
|
|
1570
|
-
): string => "URL " + inspect(v
|
|
1570
|
+
): string => "URL " + inspect(inspectIri(v), options),
|
|
1571
1571
|
}
|
|
1572
1572
|
: v);
|
|
1573
1573
|
`;
|
|
@@ -2284,6 +2284,7 @@ const INTERNAL_RUNTIME_IMPORTS = [
|
|
|
2284
2284
|
"compactJsonLdCache",
|
|
2285
2285
|
"createScopedContextLoader",
|
|
2286
2286
|
"getJsonLdContext",
|
|
2287
|
+
"getPortableActorGateways",
|
|
2287
2288
|
"isTrustedIriOrigin",
|
|
2288
2289
|
"normalizeJsonLdIris"
|
|
2289
2290
|
].join(",\n ");
|
|
@@ -2526,6 +2527,12 @@ function decodeIri(iri: string): URL {
|
|
|
2526
2527
|
? new URL("at://" + encodeURIComponent(iri.substring(5)))
|
|
2527
2528
|
: parseIri(iri);
|
|
2528
2529
|
}
|
|
2530
|
+
|
|
2531
|
+
function inspectIri(iri: URL): string {
|
|
2532
|
+
// Inspecting an object must not throw, even for a URL that cannot be
|
|
2533
|
+
// formatted as an IRI, e.g., a malformed portable ID:
|
|
2534
|
+
try { return formatIri(iri); } catch { return iri.href; }
|
|
2535
|
+
}
|
|
2529
2536
|
`;
|
|
2530
2537
|
yield `
|
|
2531
2538
|
function isValidLanguageTag(language: string): boolean {
|