@cccsaurora/clue-ui 1.3.0-dev.390 → 1.3.0-dev.404

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.
@@ -3,7 +3,7 @@ import { Stack } from "@mui/material";
3
3
  import { J as JSONViewer } from "../../../index-DUEubgWN.js";
4
4
  import Markdown from "../../display/markdown/index.js";
5
5
  import ErrorBoundary from "../../ErrorBoundary.js";
6
- import { u as usePluginStore, c as clueUIPluginStore } from "../../../store-DMdRx9g0.js";
6
+ import { u as usePluginStore, c as clueUIPluginStore } from "../../../store-B9sjQbcS.js";
7
7
  import { useTranslation } from "react-i18next";
8
8
  const Result = ({
9
9
  pluginName,
@@ -216,7 +216,8 @@ const Graph = ({ graph, sx = {} }) => {
216
216
  "& .path": {
217
217
  transition: theme.transitions.create(["opacity"], {
218
218
  duration: theme.transitions.duration.short
219
- })
219
+ }),
220
+ transform: "translateY(-10px)"
220
221
  },
221
222
  "& .node": {
222
223
  cursor: "pointer",
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Stack } from "@mui/material";
3
3
  import { J as JSONViewer } from "../../index-DUEubgWN.js";
4
4
  import Markdown from "../display/markdown/index.js";
5
- import { u as usePluginStore, c as clueUIPluginStore } from "../../store-DMdRx9g0.js";
5
+ import { u as usePluginStore, c as clueUIPluginStore } from "../../store-B9sjQbcS.js";
6
6
  import { useTranslation } from "react-i18next";
7
7
  import ErrorBoundary from "../ErrorBoundary.js";
8
8
  const FetcherResultView = ({
@@ -116,6 +116,13 @@
116
116
  "route.login.button.oauth.keycloak": "Keycloak",
117
117
  "route.plugin": "Plugin",
118
118
  "route.plugin.active": "Active",
119
+ "route.plugins": "UI Plugins",
120
+ "route.plugins.description": "Test out Clue UI Plugins",
121
+ "route.plugins.format": "Plugin supported format",
122
+ "route.plugins.input": "Enter some input to render with the Plugin",
123
+ "route.plugins.plugin": "Plugin Name",
124
+ "route.plugins.submit": "Show Plugin",
125
+ "route.plugins.validation.select.plugin": "Select a plugin name",
119
126
  "selected": "selected",
120
127
  "sources": "Sources",
121
128
  "sources.select.all": "Select All Sources",
@@ -116,6 +116,13 @@
116
116
  "route.login.button.oauth.keycloak": "Keycloak",
117
117
  "route.plugin": "Plugin",
118
118
  "route.plugin.active": "Actif",
119
+ "route.plugins": "Plugins d'IU",
120
+ "route.plugins.description": "Test out Clue UI Plugins",
121
+ "route.plugins.format": "Plugin supported format",
122
+ "route.plugins.input": "Enter some input to render with the Plugin",
123
+ "route.plugins.plugin": "Plugin Name",
124
+ "route.plugins.submit": "Show Plugin",
125
+ "route.plugins.validation.select.plugin": "Select a plugin name",
119
126
  "selected": "sélectionné(s)",
120
127
  "sources": "Sources",
121
128
  "sources.select.all": "Sélectionner toutes les sources",
@@ -1,4 +1,5 @@
1
1
  import { ClueUIPluginDefinition } from "../main";
2
+ import { ClueUIPluginStore } from "../plugins/store";
2
3
  import { FC, PropsWithChildren } from 'react';
3
4
 
4
5
  export type ClueUIPluginProviderProps = {
@@ -17,5 +18,9 @@ export type ClueUIPluginProviderProps = {
17
18
  */
18
19
  excludeBuiltInPlugins?: boolean;
19
20
  };
21
+ export type ClueUIPluginContextType = {
22
+ clueUIPluginStore: ClueUIPluginStore;
23
+ };
24
+ export declare const ClueUIPluginContext: import('react').Context<ClueUIPluginContextType>;
20
25
  declare const ClueUIPluginProvider: FC<PropsWithChildren<ClueUIPluginProviderProps>>;
21
26
  export { ClueUIPluginProvider as ClueUIPluginProvider };
@@ -1,7 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import ClueUIPluginsRegistry from "../plugins/registry.js";
3
- import { c as clueUIPluginStore, P as PluginProvider } from "../store-DMdRx9g0.js";
4
- import { useState, useEffect } from "react";
3
+ import { c as clueUIPluginStore, P as PluginProvider } from "../store-B9sjQbcS.js";
4
+ import { createContext, useState, useEffect } from "react";
5
+ const ClueUIPluginContext = createContext(null);
5
6
  const ClueUIPluginProvider = ({
6
7
  plugins,
7
8
  excludePlugins,
@@ -50,8 +51,9 @@ const ClueUIPluginProvider = ({
50
51
  });
51
52
  return () => abortController.abort();
52
53
  }, [excludeBuiltInPlugins, excludePlugins, plugins]);
53
- return /* @__PURE__ */ jsx(PluginProvider, { pluginStore, children });
54
+ return /* @__PURE__ */ jsx(ClueUIPluginContext.Provider, { value: { clueUIPluginStore }, children: /* @__PURE__ */ jsx(PluginProvider, { pluginStore, children }) });
54
55
  };
55
56
  export {
57
+ ClueUIPluginContext,
56
58
  ClueUIPluginProvider
57
59
  };
@@ -0,0 +1,4 @@
1
+ import { ClueUIPluginContextType } from './ClueUIPluginContext';
2
+
3
+ declare const useClueUIPlugins: () => ClueUIPluginContextType;
4
+ export default useClueUIPlugins;
@@ -0,0 +1,12 @@
1
+ import { useContext } from "react";
2
+ import { ClueUIPluginContext } from "./ClueUIPluginContext.js";
3
+ const useClueUIPlugins = () => {
4
+ const context = useContext(ClueUIPluginContext);
5
+ if (!context) {
6
+ throw new Error("useClueUIPlugins must be used within a ClueUIPluginProvider");
7
+ }
8
+ return context;
9
+ };
10
+ export {
11
+ useClueUIPlugins as default
12
+ };
package/package.json CHANGED
@@ -67,7 +67,7 @@
67
67
  },
68
68
  "type": "module",
69
69
  "types": "main.d.ts",
70
- "version": "1.3.0-dev.390",
70
+ "version": "1.3.0-dev.404",
71
71
  "exports": {
72
72
  ".": "./main.js",
73
73
  "./index.css": "./index.css",
@@ -120,6 +120,7 @@
120
120
  "./plugins/graph/*": "./plugins/graph/*.js",
121
121
  "./plugins/graph": "./plugins/graph/index.js",
122
122
  "./plugins/file/*": "./plugins/file/*.js",
123
- "./plugins/file": "./plugins/file/index.js"
123
+ "./plugins/file": "./plugins/file/index.js",
124
+ "./plugins/graph/example/*": "./plugins/graph/example/*.js"
124
125
  }
125
126
  }
@@ -9,9 +9,11 @@ export type RenderResultProps = {
9
9
  [additionalProps: string]: any;
10
10
  };
11
11
  export interface RenderFetcherResultProps extends RenderResultProps {
12
+ pluginId?: string;
12
13
  result: FetcherResult;
13
14
  }
14
15
  export interface RenderActionResultProps extends RenderResultProps {
16
+ pluginId?: string;
15
17
  result: WithActionData<ActionResult>;
16
18
  }
17
19
  declare abstract class ClueUIPlugin implements IPlugin {
@@ -35,6 +37,8 @@ declare abstract class ClueUIPlugin implements IPlugin {
35
37
  actionResult?(_props: RenderActionResultProps): ReactNode;
36
38
  fetcherResult?(_props: RenderFetcherResultProps): ReactNode;
37
39
  localization(_i18n: I18N): void;
38
- documentation(md: string): string;
40
+ exampleInput(): string | undefined;
41
+ editorLanguage(): string | undefined;
42
+ documentation(): string | undefined;
39
43
  }
40
44
  export default ClueUIPlugin;
@@ -180,6 +180,13 @@ const translationEN = {
180
180
  "route.login.button.oauth.keycloak": "Keycloak",
181
181
  "route.plugin": "Plugin",
182
182
  "route.plugin.active": "Active",
183
+ "route.plugins": "UI Plugins",
184
+ "route.plugins.description": "Test out Clue UI Plugins",
185
+ "route.plugins.format": "Plugin supported format",
186
+ "route.plugins.input": "Enter some input to render with the Plugin",
187
+ "route.plugins.plugin": "Plugin Name",
188
+ "route.plugins.submit": "Show Plugin",
189
+ "route.plugins.validation.select.plugin": "Select a plugin name",
183
190
  selected: selected$1,
184
191
  sources: sources$1,
185
192
  "sources.select.all": "Select All Sources",
@@ -329,6 +336,13 @@ const translationFR = {
329
336
  "route.login.button.oauth.keycloak": "Keycloak",
330
337
  "route.plugin": "Plugin",
331
338
  "route.plugin.active": "Actif",
339
+ "route.plugins": "Plugins d'IU",
340
+ "route.plugins.description": "Test out Clue UI Plugins",
341
+ "route.plugins.format": "Plugin supported format",
342
+ "route.plugins.input": "Enter some input to render with the Plugin",
343
+ "route.plugins.plugin": "Plugin Name",
344
+ "route.plugins.submit": "Show Plugin",
345
+ "route.plugins.validation.select.plugin": "Select a plugin name",
332
346
  selected,
333
347
  sources,
334
348
  "sources.select.all": "Sélectionner toutes les sources",
@@ -372,7 +386,16 @@ i18n.use(LanguageDetector).use(initReactI18next).init({
372
386
  },
373
387
  resources
374
388
  });
375
- const INTERNAL_FUNCTIONS = ["constructor", "getPluginName", "getDependencies", "init", "activate", "deactivate"];
389
+ const INTERNAL_FUNCTIONS = [
390
+ "constructor",
391
+ "getPluginFormat",
392
+ "getPluginActionIds",
393
+ "getPluginFetcherIds",
394
+ "getDependencies",
395
+ "init",
396
+ "activate",
397
+ "deactivate"
398
+ ];
376
399
  class ClueUIPlugin {
377
400
  constructor() {
378
401
  __publicField(this, "actionIds");
@@ -433,8 +456,14 @@ class ClueUIPlugin {
433
456
  }
434
457
  localization(_i18n) {
435
458
  }
436
- documentation(md) {
437
- return md;
459
+ exampleInput() {
460
+ return void 0;
461
+ }
462
+ editorLanguage() {
463
+ return void 0;
464
+ }
465
+ documentation() {
466
+ return void 0;
438
467
  }
439
468
  }
440
469
  export {
@@ -0,0 +1,91 @@
1
+ declare const _default: {
2
+ "id": "tree",
3
+ "metadata": {
4
+ "type": "nested"
5
+ },
6
+ "data": [
7
+ [{ "id": "Chaos", "edges": ["Gaea"] }],
8
+ [
9
+ { "id": "Gaea", "edges": ["Chaos"] },
10
+ { "id": "Uranus", "edges": ["Gaea"] }
11
+ ],
12
+ [
13
+ { "id": "Oceanus", "edges": ["Gaea", "Uranus"], "icons": ["bug"] },
14
+ { "id": "Thethys", "edges": ["Gaea", "Uranus"] },
15
+ { "id": "Pontus", "edges": ["Dionne"] },
16
+ { "id": "Rhea", "edges": ["Gaea", "Uranus"] },
17
+ { "id": "Cronus", "edges": ["Gaea", "Uranus"] },
18
+ { "id": "Coeus", "edges": ["Gaea", "Uranus"] },
19
+ { "id": "Phoebe", "edges": ["Gaea", "Uranus"] },
20
+ { "id": "Crius", "edges": ["Gaea", "Uranus"] },
21
+ { "id": "Hyperion", "edges": ["Gaea", "Uranus"] },
22
+ { "id": "Iapetus", "edges": ["Gaea", "Uranus"] },
23
+ { "id": "Thea", "edges": ["Gaea", "Uranus"] },
24
+ { "id": "Themis", "edges": ["Gaea", "Uranus"] },
25
+ { "id": "Mnemosyne", "edges": ["Gaea", "Uranus"] }
26
+ ],
27
+ [
28
+ { "id": "Doris", "edges": ["Oceanus", "Thethys"] },
29
+ { "id": "Neures", "edges": ["Pontus", "Gaea"] },
30
+ { "id": "Dionne" },
31
+ { "id": "Demeter", "edges": ["Rhea", "Cronus"] },
32
+ { "id": "Hades", "edges": ["Rhea", "Cronus"] },
33
+ { "id": "Hera", "edges": ["Rhea", "Cronus"] },
34
+ { "id": "Alcmene" },
35
+ { "id": "Zeus", "edges": ["Rhea", "Cronus"] },
36
+ { "id": "Eris" },
37
+ { "id": "Leto", "edges": ["Coeus", "Phoebe"] },
38
+ { "id": "Amphitrite" },
39
+ { "id": "Medusa" },
40
+ { "id": "Poseidon", "edges": ["Rhea", "Cronus"] },
41
+ { "id": "Hestia", "edges": ["Rhea", "Cronus"] }
42
+ ],
43
+ [
44
+ { "id": "Thetis", "edges": ["Zeus", "Doris", "Neures"] },
45
+ { "id": "Peleus" },
46
+ { "id": "Anchises" },
47
+ { "id": "Adonis" },
48
+ { "id": "Aphrodite", "edges": ["Zeus", "Dionne"] },
49
+ { "id": "Persephone", "edges": ["Zeus", "Demeter"] },
50
+ { "id": "Ares", "edges": ["Zeus", "Hera"] },
51
+ { "id": "Hephaestus", "edges": ["Zeus", "Hera"] },
52
+ { "id": "Hebe", "edges": ["Zeus", "Hera", "Hestia"] },
53
+ { "id": "Hercules", "edges": ["Zeus", "Alcmene"] },
54
+ { "id": "Megara" },
55
+ { "id": "Deianira" },
56
+ { "id": "Eileithya", "edges": ["Zeus", "Hera"] },
57
+ { "id": "Ate", "edges": ["Zeus", "Eris"] },
58
+ { "id": "Leda" },
59
+ { "id": "Athena", "edges": ["Zeus"] },
60
+ { "id": "Apollo", "edges": ["Zeus", "Leto"] },
61
+ { "id": "Artemis", "edges": ["Zeus", "Leto"] },
62
+ { "id": "Triton", "edges": ["Poseidon", "Amphitrite"] },
63
+ { "id": "Pegasus", "edges": ["Poseidon", "Medusa"] },
64
+ { "id": "Orion", "edges": ["Poseidon"] },
65
+ { "id": "Polyphemus", "edges": ["Poseidon"] }
66
+ ],
67
+ [
68
+ { "id": "Deidamia" },
69
+ { "id": "Achilles", "edges": ["Peleus", "Thetis"] },
70
+ { "id": "Creusa" },
71
+ { "id": "Aeneas", "edges": ["Anchises", "Aphrodite"] },
72
+ { "id": "Lavinia", "edges": ["Lavinia(2)"] },
73
+ { "id": "Lavinia(2)", "edges": ["Lavinia"] },
74
+ { "id": "Eros", "edges": ["Hephaestus", "Aphrodite"] },
75
+ { "id": "Helen", "edges": ["Leda", "Zeus"] },
76
+ { "id": "Menelaus", "edges": ["Lavinia"] },
77
+ { "id": "Polydueces", "edges": ["Leda", "Zeus"] }
78
+ ],
79
+ [
80
+ { "id": "Andromache" },
81
+ { "id": "Neoptolemus", "edges": ["Deidamia", "Achilles"] },
82
+ { "id": "Aeneas(2)", "edges": ["Creusa", "Aeneas"] },
83
+ { "id": "Pompilius", "edges": ["Creusa", "Aeneas"] },
84
+ { "id": "Iulus", "edges": ["Lavinia", "Aeneas"] },
85
+ { "id": "Hermione", "edges": ["Helen", "Menelaus"] }
86
+ ]
87
+ ]
88
+ }
89
+ ;
90
+
91
+ export default _default;
@@ -13,5 +13,8 @@ declare class GraphPlugin extends ClueUIPlugin {
13
13
  fetcherResult({ result }: {
14
14
  result: FetcherResult;
15
15
  }): import("react/jsx-runtime").JSX.Element;
16
+ editorLanguage(): string;
17
+ exampleInput(): string;
18
+ documentation(): string;
16
19
  }
17
20
  export default GraphPlugin;
@@ -4,6 +4,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  import Graph from "../../components/display/graph/index.js";
6
6
  import ClueUIPlugin from "../ClueUIPlugin.js";
7
+ import { validateJsonData } from "../utils.js";
8
+ const id = "tree";
9
+ const metadata = { "type": "nested" };
10
+ const data = [[{ "id": "Chaos", "edges": ["Gaea"] }], [{ "id": "Gaea", "edges": ["Chaos"] }, { "id": "Uranus", "edges": ["Gaea"] }], [{ "id": "Oceanus", "edges": ["Gaea", "Uranus"], "icons": ["bug"] }, { "id": "Thethys", "edges": ["Gaea", "Uranus"] }, { "id": "Pontus", "edges": ["Dionne"] }, { "id": "Rhea", "edges": ["Gaea", "Uranus"] }, { "id": "Cronus", "edges": ["Gaea", "Uranus"] }, { "id": "Coeus", "edges": ["Gaea", "Uranus"] }, { "id": "Phoebe", "edges": ["Gaea", "Uranus"] }, { "id": "Crius", "edges": ["Gaea", "Uranus"] }, { "id": "Hyperion", "edges": ["Gaea", "Uranus"] }, { "id": "Iapetus", "edges": ["Gaea", "Uranus"] }, { "id": "Thea", "edges": ["Gaea", "Uranus"] }, { "id": "Themis", "edges": ["Gaea", "Uranus"] }, { "id": "Mnemosyne", "edges": ["Gaea", "Uranus"] }], [{ "id": "Doris", "edges": ["Oceanus", "Thethys"] }, { "id": "Neures", "edges": ["Pontus", "Gaea"] }, { "id": "Dionne" }, { "id": "Demeter", "edges": ["Rhea", "Cronus"] }, { "id": "Hades", "edges": ["Rhea", "Cronus"] }, { "id": "Hera", "edges": ["Rhea", "Cronus"] }, { "id": "Alcmene" }, { "id": "Zeus", "edges": ["Rhea", "Cronus"] }, { "id": "Eris" }, { "id": "Leto", "edges": ["Coeus", "Phoebe"] }, { "id": "Amphitrite" }, { "id": "Medusa" }, { "id": "Poseidon", "edges": ["Rhea", "Cronus"] }, { "id": "Hestia", "edges": ["Rhea", "Cronus"] }], [{ "id": "Thetis", "edges": ["Zeus", "Doris", "Neures"] }, { "id": "Peleus" }, { "id": "Anchises" }, { "id": "Adonis" }, { "id": "Aphrodite", "edges": ["Zeus", "Dionne"] }, { "id": "Persephone", "edges": ["Zeus", "Demeter"] }, { "id": "Ares", "edges": ["Zeus", "Hera"] }, { "id": "Hephaestus", "edges": ["Zeus", "Hera"] }, { "id": "Hebe", "edges": ["Zeus", "Hera", "Hestia"] }, { "id": "Hercules", "edges": ["Zeus", "Alcmene"] }, { "id": "Megara" }, { "id": "Deianira" }, { "id": "Eileithya", "edges": ["Zeus", "Hera"] }, { "id": "Ate", "edges": ["Zeus", "Eris"] }, { "id": "Leda" }, { "id": "Athena", "edges": ["Zeus"] }, { "id": "Apollo", "edges": ["Zeus", "Leto"] }, { "id": "Artemis", "edges": ["Zeus", "Leto"] }, { "id": "Triton", "edges": ["Poseidon", "Amphitrite"] }, { "id": "Pegasus", "edges": ["Poseidon", "Medusa"] }, { "id": "Orion", "edges": ["Poseidon"] }, { "id": "Polyphemus", "edges": ["Poseidon"] }], [{ "id": "Deidamia" }, { "id": "Achilles", "edges": ["Peleus", "Thetis"] }, { "id": "Creusa" }, { "id": "Aeneas", "edges": ["Anchises", "Aphrodite"] }, { "id": "Lavinia", "edges": ["Lavinia(2)"] }, { "id": "Lavinia(2)", "edges": ["Lavinia"] }, { "id": "Eros", "edges": ["Hephaestus", "Aphrodite"] }, { "id": "Helen", "edges": ["Leda", "Zeus"] }, { "id": "Menelaus", "edges": ["Lavinia"] }, { "id": "Polydueces", "edges": ["Leda", "Zeus"] }], [{ "id": "Andromache" }, { "id": "Neoptolemus", "edges": ["Deidamia", "Achilles"] }, { "id": "Aeneas(2)", "edges": ["Creusa", "Aeneas"] }, { "id": "Pompilius", "edges": ["Creusa", "Aeneas"] }, { "id": "Iulus", "edges": ["Lavinia", "Aeneas"] }, { "id": "Hermione", "edges": ["Helen", "Menelaus"] }]];
11
+ const tree_example = {
12
+ id,
13
+ metadata,
14
+ data
15
+ };
7
16
  class GraphPlugin extends ClueUIPlugin {
8
17
  constructor() {
9
18
  super(...arguments);
@@ -14,10 +23,21 @@ class GraphPlugin extends ClueUIPlugin {
14
23
  __publicField(this, "description", "Renders an interactive tree visualization.");
15
24
  }
16
25
  actionResult({ result }) {
17
- return /* @__PURE__ */ jsx(Graph, { graph: result.output, sx: { minHeight: "600px" } });
26
+ const json = validateJsonData(result.output);
27
+ return /* @__PURE__ */ jsx(Graph, { graph: json, sx: { minHeight: "600px" } });
18
28
  }
19
29
  fetcherResult({ result }) {
20
- return /* @__PURE__ */ jsx(Graph, { graph: result.data, sx: { minHeight: "600px" } });
30
+ const json = validateJsonData(result.data);
31
+ return /* @__PURE__ */ jsx(Graph, { graph: json, sx: { minHeight: "600px" } });
32
+ }
33
+ editorLanguage() {
34
+ return "json";
35
+ }
36
+ exampleInput() {
37
+ return JSON.stringify(tree_example, null, 2);
38
+ }
39
+ documentation() {
40
+ return `This plugin renders an interactive tree visualization. It can be used by specifying "graph" as the format in the plugin configuration.`;
21
41
  }
22
42
  }
23
43
  export {
@@ -8,5 +8,8 @@ declare class ImagePlugin extends ClueUIPlugin {
8
8
  description: string;
9
9
  actionResult(props: RenderActionResultProps): import("react/jsx-runtime").JSX.Element;
10
10
  fetcherResult(props: RenderFetcherResultProps): import("react/jsx-runtime").JSX.Element;
11
+ editorLanguage(): string;
12
+ exampleInput(): string;
13
+ documentation(): string;
11
14
  }
12
15
  export default ImagePlugin;
@@ -3,6 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  import ClueUIPlugin from "../ClueUIPlugin.js";
6
+ import { validateJsonData } from "../utils.js";
6
7
  class ImagePlugin extends ClueUIPlugin {
7
8
  constructor() {
8
9
  super(...arguments);
@@ -13,12 +14,31 @@ class ImagePlugin extends ClueUIPlugin {
13
14
  __publicField(this, "description", "Renders images.");
14
15
  }
15
16
  actionResult(props) {
16
- const { result, fetcherId: _fetcherId, ...additionalProps } = props;
17
- return /* @__PURE__ */ jsx("img", { src: result.output.image, alt: result.output.alt, ...additionalProps });
17
+ const { result, pluginId, ...additionalProps } = props;
18
+ const json = validateJsonData(result.output);
19
+ if (typeof json.image !== "string" || json.image.length === 0) {
20
+ throw new Error('ImagePlugin expects a JSON object with a non-empty "image" string property.');
21
+ }
22
+ const { image, alt } = json;
23
+ return /* @__PURE__ */ jsx("img", { src: image, alt: alt ?? "", ...additionalProps });
18
24
  }
19
25
  fetcherResult(props) {
20
- const { result, fetcherId: _fetcherId, ...additionalProps } = props;
21
- return /* @__PURE__ */ jsx("img", { src: result.data.image, alt: result.data.alt, ...additionalProps });
26
+ const { result, fetcherId, ...additionalProps } = props;
27
+ const json = validateJsonData(result.data);
28
+ if (typeof json.image !== "string" || json.image.length === 0) {
29
+ throw new Error('ImagePlugin expects a JSON object with a non-empty "image" string property.');
30
+ }
31
+ const { image, alt } = json;
32
+ return /* @__PURE__ */ jsx("img", { src: image, alt: alt ?? "", ...additionalProps });
33
+ }
34
+ editorLanguage() {
35
+ return "json";
36
+ }
37
+ exampleInput() {
38
+ return JSON.stringify({ image: "/svg/dark/clue-icon2.svg", alt: "Clue Logo" }, null, 2);
39
+ }
40
+ documentation() {
41
+ return `This plugin renders images. It can be used by specifying "image" as the format in the plugin configuration. The input should be a json object with an "image" property that is the URL of the image, and an optional "alt" property for the alt text of the image.`;
22
42
  }
23
43
  }
24
44
  export {
@@ -13,5 +13,8 @@ declare class JsonPlugin extends ClueUIPlugin {
13
13
  fetcherResult({ result }: {
14
14
  result: FetcherResult;
15
15
  }): import("react/jsx-runtime").JSX.Element;
16
+ editorLanguage(): string;
17
+ exampleInput(): string;
18
+ documentation(): string;
16
19
  }
17
20
  export default JsonPlugin;
@@ -4,6 +4,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  import { J as JSONViewer } from "../../index-DUEubgWN.js";
6
6
  import ClueUIPlugin from "../ClueUIPlugin.js";
7
+ import { validateJsonData } from "../utils.js";
7
8
  class JsonPlugin extends ClueUIPlugin {
8
9
  constructor() {
9
10
  super(...arguments);
@@ -14,10 +15,21 @@ class JsonPlugin extends ClueUIPlugin {
14
15
  __publicField(this, "description", "Renders JSON with the default renderer or the overridden json component defined in the clue component provider.");
15
16
  }
16
17
  actionResult({ result }) {
17
- return /* @__PURE__ */ jsx(JSONViewer, { data: result.output, collapse: true, forceCompact: true });
18
+ const json = validateJsonData(result.output);
19
+ return /* @__PURE__ */ jsx(JSONViewer, { data: json, collapse: true, forceCompact: true });
18
20
  }
19
21
  fetcherResult({ result }) {
20
- return /* @__PURE__ */ jsx(JSONViewer, { data: result.data });
22
+ const json = validateJsonData(result.data);
23
+ return /* @__PURE__ */ jsx(JSONViewer, { data: json, collapse: true, forceCompact: true });
24
+ }
25
+ editorLanguage() {
26
+ return "json";
27
+ }
28
+ exampleInput() {
29
+ return '{ "key": "value" }';
30
+ }
31
+ documentation() {
32
+ return `This plugin renders JSON. It can be used by specifying "json" as the format in the plugin configuration. The input should be a JSON object or a stringified JSON.`;
21
33
  }
22
34
  }
23
35
  export {
@@ -13,5 +13,8 @@ declare class MarkdownPlugin extends ClueUIPlugin {
13
13
  fetcherResult({ result }: {
14
14
  result: FetcherResult;
15
15
  }): import("react/jsx-runtime").JSX.Element;
16
+ editorLanguage(): string;
17
+ exampleInput(): string;
18
+ documentation(): string;
16
19
  }
17
20
  export default MarkdownPlugin;
@@ -19,6 +19,17 @@ class MarkdownPlugin extends ClueUIPlugin {
19
19
  fetcherResult({ result }) {
20
20
  return /* @__PURE__ */ jsx(Markdown, { md: result.data });
21
21
  }
22
+ editorLanguage() {
23
+ return "markdown";
24
+ }
25
+ exampleInput() {
26
+ return `# Markdown Plugin
27
+ This is an example of the Markdown plugin.
28
+ You can use **Markdown** syntax to format your text.`;
29
+ }
30
+ documentation() {
31
+ return `This plugin renders Markdown. It can be used by specifying "markdown" as the format in the plugin configuration. The input should be a string in Markdown format.`;
32
+ }
22
33
  }
23
34
  export {
24
35
  MarkdownPlugin as default
@@ -34,6 +34,7 @@ export declare class ClueUIPluginStore {
34
34
  */
35
35
  getPlugins(format?: string, resultType?: 'action' | 'fetcher', actionId?: string, fetcherId?: string): string[];
36
36
  getPlugin(format: string, resultType: 'action' | 'fetcher', actionId?: string, fetcherId?: string): string | undefined;
37
+ getAvailableFormats(pluginName?: string): string[];
37
38
  get pluginStore(): import('react-pluggable').PluginStore;
38
39
  }
39
40
  declare const clueUIPluginStore: ClueUIPluginStore;
package/plugins/store.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C, c } from "../store-DMdRx9g0.js";
1
+ import { C, c } from "../store-B9sjQbcS.js";
2
2
  import "../uniq-CahZPAwp.js";
3
3
  export {
4
4
  C as ClueUIPluginStore,
@@ -0,0 +1 @@
1
+ export declare const validateJsonData: (data: unknown) => object;
@@ -0,0 +1,20 @@
1
+ const validateJsonData = (data) => {
2
+ let json = data;
3
+ if (typeof json === "string") {
4
+ try {
5
+ json = JSON.parse(json);
6
+ } catch (err) {
7
+ throw new Error(`Failed to parse JSON string: ${String(err)}`, {
8
+ cause: err instanceof Error ? err : void 0
9
+ });
10
+ }
11
+ }
12
+ if (json === null || typeof json !== "object") {
13
+ const receivedType = json === null ? "null" : typeof json;
14
+ throw new Error(`Input must be a JSON object or a JSON object encoded as a string. Got: ${receivedType}`);
15
+ }
16
+ return json;
17
+ };
18
+ export {
19
+ validateJsonData
20
+ };
@@ -2143,6 +2143,13 @@ class ClueUIPluginStore {
2143
2143
  const availablePlugins = this.getPlugins(format, resultType, actionId, fetcherId);
2144
2144
  return availablePlugins.length > 0 ? availablePlugins[0] : void 0;
2145
2145
  }
2146
+ getAvailableFormats(pluginName) {
2147
+ const formats = Object.keys(this.pluginsByFormat);
2148
+ if (pluginName) {
2149
+ return formats.filter((format) => this.pluginsByFormat[format].includes(pluginName));
2150
+ }
2151
+ return formats;
2152
+ }
2146
2153
  get pluginStore() {
2147
2154
  return this._pluginStore;
2148
2155
  }