@fedify/vocab-tools
Advanced tools
+1
-1
| { | ||
| "name": "@fedify/vocab-tools", | ||
| "version": "2.3.2-dev.1556+3e14f2d7", | ||
| "version": "2.3.2", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "exports": { |
+1
-1
| { | ||
| "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/", |
+26
-0
@@ -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>(); |
+32
-20
@@ -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); |
+2
-1
@@ -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
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
12388353
1.62%7916
1.44%0
-100%3
-25%21
5%