🎩 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.3.2-dev.1556
to
2.3.2
+1
-1
deno.json
{
"name": "@fedify/vocab-tools",
"version": "2.3.2-dev.1556+3e14f2d7",
"version": "2.3.2",
"license": "MIT",

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

{
"name": "@fedify/vocab-tools",
"version": "2.3.2-dev.1556+3e14f2d7",
"version": "2.3.2",
"description": "Code generator for Activity Vocabulary APIs",

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

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

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

@@ -96,2 +97,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;
}
`;

@@ -211,2 +226,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";

@@ -213,0 +239,0 @@ const moduleVarNames = new Map<string, string>();

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

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

@@ -504,19 +507,14 @@ const variable = await getFieldName(property.uri, "");

}
yield `
const decoded =
`;
if (property.range.length == 1) {
yield `
const decoded = ${
getDecoder(
property.range[0],
types,
"v",
"options",
propertyBaseUrl,
)
};
if (typeof decoded === "undefined") continue;
${variable}.push(decoded);`;
yield getDecoder(
property.range[0],
types,
"v",
"options",
propertyBaseUrl,
);
} else {
yield `
const decoded =
`;
const decoders = getDecoders(

@@ -530,8 +528,18 @@ property.range,

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

@@ -543,3 +551,7 @@ }

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

@@ -546,0 +558,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