🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@fedify/vocab-tools

Package Overview
Dependencies
Maintainers
3
Versions
298
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fedify/vocab-tools - npm Package Compare versions

Comparing version
2.1.17
to
2.1.18
+1
-1
deno.json
{
"name": "@fedify/vocab-tools",
"version": "2.1.17",
"version": "2.1.18",
"license": "MIT",

@@ -5,0 +5,0 @@ "exports": {

{
"name": "@fedify/vocab-tools",
"version": "2.1.17",
"version": "2.1.18",
"description": "Code generator for Activity Vocabulary APIs",

@@ -5,0 +5,0 @@ "homepage": "https://fedify.dev/",

@@ -60,2 +60,3 @@ import { generateDecoder, generateEncoder } from "./codec.ts";

#cachedJsonLd?: unknown;
#shouldCacheJsonLd = true;
readonly id: URL | null;

@@ -90,2 +91,16 @@

}
protected get _shouldCacheJsonLd(): boolean {
return this.#shouldCacheJsonLd;
}
protected set _shouldCacheJsonLd(value: boolean) {
this.#shouldCacheJsonLd = value;
}
protected static _shouldCacheDecodedJsonLd(value: unknown): boolean {
if (value == null || typeof value !== "object") return true;
if (!("_shouldCacheJsonLd" in value)) return true;
return (value as { _shouldCacheJsonLd: boolean })._shouldCacheJsonLd;
}
`;

@@ -151,2 +166,13 @@ }

} from "@fedify/vocab-runtime/temporal";\n`;
yield `
function isValidLanguageTag(language: string): boolean {
try {
new Intl.Locale(language);
return true;
} catch (error) {
if (error instanceof RangeError) return false;
throw error;
}
}
`;
yield "\n\n";

@@ -153,0 +179,0 @@ const sorted = sortTopologically(types);

@@ -403,2 +403,5 @@ import metadata from "../deno.json" with { type: "json" };

}
yield `
let shouldCacheJsonLd = instance._shouldCacheJsonLd;
`;
for (const property of type.properties) {

@@ -443,16 +446,14 @@ const variable = await getFieldName(property.uri, "");

}
yield `
const decoded =
`;
if (property.range.length == 1) {
yield `${variable}.push(${
getDecoder(
property.range[0],
types,
"v",
"options",
`(values["@id"] == null ? options.baseUrl : new URL(values["@id"]))`,
)
})`;
yield getDecoder(
property.range[0],
types,
"v",
"options",
`(values["@id"] == null ? options.baseUrl : new URL(values["@id"]))`,
);
} else {
yield `
const decoded =
`;
const decoders = getDecoders(

@@ -466,9 +467,21 @@ property.range,

for (const code of decoders) yield code;
}
yield `
;
`;
if (property.range.length > 1) {
yield `
;
if (typeof decoded === "undefined") continue;
${variable}.push(decoded);
if (typeof decoded === "undefined") {
shouldCacheJsonLd = false;
continue;
}
`;
}
yield `
if (!this._shouldCacheDecodedJsonLd(decoded)) {
shouldCacheJsonLd = false;
}
${variable}.push(decoded);
`;
yield `
}

@@ -479,3 +492,7 @@ instance.${await getFieldName(property.uri)} = ${variable};

yield `
if (!("_fromSubclass" in options) || !options._fromSubclass) {
instance._shouldCacheJsonLd = shouldCacheJsonLd;
if (
shouldCacheJsonLd &&
(!("_fromSubclass" in options) || !options._fromSubclass)
) {
try {

@@ -482,0 +499,0 @@ instance._cachedJsonLd = structuredClone(json);

@@ -203,3 +203,4 @@ import type { PropertySchema, TypeSchema } from "./schema.ts";

&& typeof ${v}["@language"] === "string"
&& typeof ${v}["@value"] === "string"`;
&& typeof ${v}["@value"] === "string"
&& isValidLanguageTag(${v}["@language"])`;
},

@@ -206,0 +207,0 @@ decoder(v) {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet