@monokle/validation
Advanced tools
Comparing version 0.7.1 to 0.7.2
@@ -43,3 +43,12 @@ import difference from "lodash/difference.js"; | ||
default: | ||
throw new Error("plugin_not_found"); | ||
try { | ||
const url = `https://plugins.monokle.com/validation/${pluginName}/latest.js`; | ||
const customPlugin = await import(/* @vite-ignore */ url); | ||
return new SimpleCustomValidator(customPlugin.default, parser); | ||
} | ||
catch (err) { | ||
throw new Error(err instanceof Error | ||
? `plugin_not_found: ${err.message}` | ||
: `plugin_not_found: ${String(err)}`); | ||
} | ||
} | ||
@@ -46,0 +55,0 @@ }); |
@@ -27,3 +27,4 @@ import { ResourceParser } from "./common/resourceParser.js"; | ||
try { | ||
const customPlugin = await importWithDataUrl("http://localhost:4111/plugin.js"); | ||
const url = `https://plugins.monokle.com/validation/${pluginName}/latest.js`; | ||
const customPlugin = await importWithDataUrl(url); | ||
return new SimpleCustomValidator(customPlugin.default, parser); | ||
@@ -30,0 +31,0 @@ } |
@@ -16,2 +16,3 @@ import { JsonObject } from "type-fest"; | ||
private _lastConfig?; | ||
private _debug; | ||
constructor(parser: ResourceParser); | ||
@@ -18,0 +19,0 @@ onReload(callback: (hash: String) => void): void; |
@@ -7,3 +7,2 @@ import { DEV_MODE_TOKEN } from "./constants.js"; | ||
displayName: "Developer mode", | ||
icon: "k8s-schema", | ||
learnMoreUrl: "https://github.com/kubeshop/monokle-community-plugins#readme", | ||
@@ -23,2 +22,3 @@ description: "Develop custom validators in minutes. Enable your plugin's development server to get started. HMR will show your latest code directly in the browser.", | ||
_lastConfig; | ||
_debug = false; | ||
constructor(parser) { | ||
@@ -34,3 +34,5 @@ this.parser = parser; | ||
this._source.onerror = (err) => { | ||
console.error(err); | ||
if (this._debug) { | ||
console.log("[validator-dev] event source failed", err); | ||
} | ||
}; | ||
@@ -43,2 +45,5 @@ this._source.onmessage = (event) => { | ||
} | ||
if (this._debug) { | ||
console.log("[validator-dev] bundle received", bundle.hash); | ||
} | ||
this._currentHash = bundle.hash; | ||
@@ -54,5 +59,15 @@ const encodedSource = btoa(bundle.code); | ||
.configure(this._lastConfig) | ||
.then(() => this._handleReload?.(bundle.hash)); | ||
.then(() => { | ||
if (this._debug) | ||
console.log("[validator-dev] bundle loaded"); | ||
this._handleReload?.(bundle.hash); | ||
}) | ||
.catch((err) => { | ||
if (this._debug) | ||
console.log("[validator-dev] bundle load failed", err instanceof Error ? err.message : "reason unknown"); | ||
}); | ||
} | ||
else { | ||
if (this._debug) | ||
console.log("[validator-dev] bundle loaded"); | ||
this._handleReload?.(bundle.hash); | ||
@@ -63,3 +78,5 @@ } | ||
catch (err) { | ||
console.error(err); | ||
if (this._debug) { | ||
console.error("[validator-dev] bundle failure", err instanceof Error ? err.message : "reason unknown"); | ||
} | ||
} | ||
@@ -114,2 +131,3 @@ }; | ||
configure(config) { | ||
this._debug = Boolean(config?.settings?.debug); | ||
if (!this._currentValidator) { | ||
@@ -116,0 +134,0 @@ this._lastConfig = config; |
@@ -89,3 +89,2 @@ import { paramCase, sentenceCase } from "change-case"; | ||
displayName: plugin.displayName ?? sentenceCase(plugin.name), | ||
icon: plugin.icon ?? "k8s-schema", | ||
}; | ||
@@ -92,0 +91,0 @@ } |
{ | ||
"name": "@monokle/validation", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "Kubernetes resource validation", | ||
@@ -5,0 +5,0 @@ "author": "Kubeshop", |
260806
150
6507