@cccsaurora/clue-ui 1.4.0 → 1.4.1

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.
@@ -1,31 +1,33 @@
1
- import { jsx as u } from "react/jsx-runtime";
1
+ import { jsx as m } from "react/jsx-runtime";
2
2
  import { Tooltip as p, Chip as x } from "@mui/material";
3
3
  import D from "../hooks/useClueConfig.js";
4
4
  import { getParts as C, normalizedClassification as _ } from "../utils/classificationParser.js";
5
- import v, { useMemo as s, memo as y } from "react";
6
- const g = ["default", "primary", "secondary", "error", "info", "success", "warning"], A = v.memo(
7
- ({ classification: r, ...n }) => {
8
- var i, f;
9
- const { config: e } = D(), t = s(() => e.c12nDef ? C(r, e.c12nDef, "short", !0) : null, [r, e.c12nDef]), d = s(() => !e.c12nDef || !t ? r : _(t, e.c12nDef, "short", !0), [r, e.c12nDef, t]), o = s(() => {
10
- var c, a, m;
11
- const l = (m = (a = e.c12nDef) == null ? void 0 : a.levels_styles_map[(c = e.c12nDef) == null ? void 0 : c.levels_map[t.lvlIdx]]) == null ? void 0 : m.color;
5
+ import y, { useMemo as s, memo as v } from "react";
6
+ const g = ["default", "primary", "secondary", "error", "info", "success", "warning"], A = y.memo(
7
+ ({ classification: n, ...t }) => {
8
+ var f, i;
9
+ const { config: r } = D(), e = s(() => r.c12nDef ? C(n, r.c12nDef, "short", !0) : null, [n, r.c12nDef]), d = s(() => !r.c12nDef || !e ? n : _(e, r.c12nDef, "short", !0), [n, r.c12nDef, e]), o = s(() => {
10
+ var c, a, u;
11
+ if (!e)
12
+ return { color: "default" };
13
+ const l = (u = (a = r.c12nDef) == null ? void 0 : a.levels_styles_map[(c = r.c12nDef) == null ? void 0 : c.levels_map[e.lvlIdx]]) == null ? void 0 : u.color;
12
14
  return g.includes(l) ? { color: l } : l ? { sx: { color: l } } : { color: "default" };
13
- }, [(i = e.c12nDef) == null ? void 0 : i.levels_map, (f = e.c12nDef) == null ? void 0 : f.levels_styles_map, t.lvlIdx]);
14
- return /* @__PURE__ */ u(p, { title: r, children: /* @__PURE__ */ u(
15
+ }, [(f = r.c12nDef) == null ? void 0 : f.levels_map, (i = r.c12nDef) == null ? void 0 : i.levels_styles_map, e]);
16
+ return /* @__PURE__ */ m(p, { title: n, children: /* @__PURE__ */ m(
15
17
  x,
16
18
  {
17
- variant: n.variant || "outlined",
19
+ variant: t.variant || "outlined",
18
20
  label: d,
19
21
  ...o,
20
- ...n,
22
+ ...t,
21
23
  sx: [
22
24
  ...Array.isArray(o.sx) ? o.sx : [o.sx],
23
- ...Array.isArray(n.sx) ? n.sx : [n.sx]
25
+ ...Array.isArray(t.sx) ? t.sx : [t.sx]
24
26
  ]
25
27
  }
26
28
  ) });
27
29
  }
28
- ), M = y(A);
30
+ ), b = v(A);
29
31
  export {
30
- M as default
32
+ b as default
31
33
  };
@@ -3,7 +3,7 @@ import { Stack as i } from "@mui/material";
3
3
  import { J as m } from "../../../index-Cj4d5cGz.js";
4
4
  import f from "../../display/markdown/index.js";
5
5
  import t from "../../ErrorBoundary.js";
6
- import { u as p, c as s } from "../../../store-DClHBq7r.js";
6
+ import { u as p, c as s } from "../../../store-D4aFUWxi.js";
7
7
  import { useTranslation as g } from "react-i18next";
8
8
  const k = ({
9
9
  pluginName: u,
@@ -2,7 +2,7 @@ import { jsx as r, jsxs as i } from "react/jsx-runtime";
2
2
  import { Stack as c } from "@mui/material";
3
3
  import { J as m } from "../../index-Cj4d5cGz.js";
4
4
  import f from "../display/markdown/index.js";
5
- import { u as p, c as g } from "../../store-DClHBq7r.js";
5
+ import { u as p, c as g } from "../../store-D4aFUWxi.js";
6
6
  import { useTranslation as h } from "react-i18next";
7
7
  import u from "../ErrorBoundary.js";
8
8
  const y = ({
@@ -17,6 +17,10 @@ export type ClueUIPluginProviderProps = {
17
17
  * If true, do not load any plugins from the ClueUIPluginsRegistry, only load plugins passed in via props
18
18
  */
19
19
  excludeBuiltInPlugins?: boolean;
20
+ /**
21
+ * If true, don't print the author information of loaded plugins
22
+ */
23
+ silent?: boolean;
20
24
  };
21
25
  export type ClueUIPluginContextType = {
22
26
  clueUIPluginStore: ClueUIPluginStore;
@@ -1,45 +1,46 @@
1
- import { jsx as s } from "react/jsx-runtime";
2
- import b from "../plugins/registry.js";
3
- import { c as i, P as m } from "../store-DClHBq7r.js";
4
- import { createContext as p, useState as C, useEffect as P } from "react";
5
- const v = p(null), U = ({
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import m from "../plugins/registry.js";
3
+ import { c as i, P as p } from "../store-D4aFUWxi.js";
4
+ import { createContext as C, useState as P, useEffect as v } from "react";
5
+ const w = C(null), h = ({
6
6
  plugins: a,
7
7
  excludePlugins: o,
8
8
  excludeBuiltInPlugins: e,
9
- children: f
9
+ silent: l,
10
+ children: c
10
11
  }) => {
11
- const [c, d] = C(() => i.pluginStore);
12
- return P(() => {
13
- const t = new AbortController(), l = async (r) => {
12
+ const [d, u] = P(() => i.pluginStore);
13
+ return v(() => {
14
+ const t = new AbortController(), s = async (r) => {
14
15
  try {
15
16
  const n = await r.loadPlugin();
16
17
  if (t.signal.aborted) return;
17
- const g = new n.default();
18
- i.install(g);
18
+ const b = new n.default();
19
+ i.install(b, l);
19
20
  } catch (n) {
20
21
  if (t.signal.aborted) return;
21
22
  console.error(`[ClueUIPluginProvider] Failed to load plugin: ${r.name ?? r.id}`, n);
22
23
  }
23
- }, u = async () => {
24
+ }, g = async () => {
24
25
  if (a && Array.isArray(a))
25
26
  for (const r of a) {
26
27
  if (t.signal.aborted) return;
27
- o != null && o.includes(r.id) || await l(r);
28
+ o != null && o.includes(r.id) || await s(r);
28
29
  }
29
30
  if (!e) {
30
- const r = new b().getPlugins();
31
+ const r = new m().getPlugins();
31
32
  for (const n of r) {
32
33
  if (t.signal.aborted) return;
33
- o != null && o.includes(n.id) || await l(n);
34
+ o != null && o.includes(n.id) || await s(n);
34
35
  }
35
36
  }
36
37
  };
37
- return i.reset(), d(i.pluginStore), u().catch((r) => {
38
+ return i.reset(), u(i.pluginStore), g().catch((r) => {
38
39
  t.signal.aborted || console.error("[ClueUIPluginProvider] Failed to load plugins", r);
39
40
  }), () => t.abort();
40
- }, [e, o, a]), /* @__PURE__ */ s(v.Provider, { value: { clueUIPluginStore: i }, children: /* @__PURE__ */ s(m, { pluginStore: c, children: f }) });
41
+ }, [e, o, a, l]), /* @__PURE__ */ f(w.Provider, { value: { clueUIPluginStore: i }, children: /* @__PURE__ */ f(p, { pluginStore: d, children: c }) });
41
42
  };
42
43
  export {
43
- v as ClueUIPluginContext,
44
- U as ClueUIPluginProvider
44
+ w as ClueUIPluginContext,
45
+ h as ClueUIPluginProvider
45
46
  };
package/package.json CHANGED
@@ -67,7 +67,7 @@
67
67
  },
68
68
  "type": "module",
69
69
  "types": "main.d.ts",
70
- "version": "1.4.0",
70
+ "version": "1.4.1",
71
71
  "exports": {
72
72
  ".": "./main.js",
73
73
  "./index.css": "./index.css",
@@ -15,7 +15,7 @@ export declare class ClueUIPluginStore {
15
15
  actionPlugins: string[];
16
16
  fetcherPlugins: string[];
17
17
  reset(): void;
18
- install(plugin: ClueUIPlugin): void;
18
+ install(plugin: ClueUIPlugin, silent?: boolean): void;
19
19
  /**
20
20
  * Get plugins based on the given criteria.
21
21
  *
package/plugins/store.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as t, c as a } from "../store-DClHBq7r.js";
1
+ import { C as t, c as a } from "../store-D4aFUWxi.js";
2
2
  import "../uniq-B4UZ671_.js";
3
3
  export {
4
4
  t as ClueUIPluginStore,
@@ -1113,11 +1113,11 @@ class Ct {
1113
1113
  reset() {
1114
1114
  this._pluginStore = Br(), this.plugins = [], this.pluginsByFormat = {}, this.pluginsByActionId = {}, this.pluginsByFetcherId = {}, this.actionPlugins = [], this.fetcherPlugins = [];
1115
1115
  }
1116
- install(s) {
1117
- this.plugins.includes(s.name) || (console.log(`Installing plugin ${s.getPluginName()} by ${s.author}`), this.pluginStore.install(s), this.plugins.push(s.name), s.format && (this.pluginsByFormat[s.format] = [...this.pluginsByFormat[s.format] ?? [], s.name]), s.actionIds && s.actionResult && s.actionIds.forEach((t) => {
1118
- this.pluginsByActionId[t] = [...this.pluginsByActionId[t] ?? [], s.name];
1119
- }), s.fetcherIds && s.fetcherResult && s.fetcherIds.forEach((t) => {
1120
- this.pluginsByFetcherId[t] = [...this.pluginsByFetcherId[t] ?? [], s.name];
1116
+ install(s, t = !1) {
1117
+ this.plugins.includes(s.name) || (t || console.log(`Installing plugin ${s.getPluginName()} by ${s.author}`), this.pluginStore.install(s), this.plugins.push(s.name), s.format && (this.pluginsByFormat[s.format] = [...this.pluginsByFormat[s.format] ?? [], s.name]), s.actionIds && s.actionResult && s.actionIds.forEach((r) => {
1118
+ this.pluginsByActionId[r] = [...this.pluginsByActionId[r] ?? [], s.name];
1119
+ }), s.fetcherIds && s.fetcherResult && s.fetcherIds.forEach((r) => {
1120
+ this.pluginsByFetcherId[r] = [...this.pluginsByFetcherId[r] ?? [], s.name];
1121
1121
  }), s.actionResult && this.actionPlugins.push(s.name), s.fetcherResult && this.fetcherPlugins.push(s.name));
1122
1122
  }
1123
1123
  /**