@xapps-platform/marketplace-ui 0.1.4 → 0.1.5

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 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,aAAa,EAAW,MAAM,+BAA+B,CAAC;AAC1F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAuiBvC,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAMtF;AAED,wBAAgB,kBAAkB;;;;;;;EAEjC;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAe3F"}
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,aAAa,EAAW,MAAM,+BAA+B,CAAC;AAC1F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAuiBvC,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAMtF;AAED,wBAAgB,kBAAkB;;;;;;;EAEjC;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAmC3F"}
package/dist/index.js CHANGED
@@ -625,17 +625,37 @@ function useMarketplaceI18n() {
625
625
  return useI18n();
626
626
  }
627
627
  function resolveMarketplaceText(value, locale) {
628
- if (typeof value === "string") return value;
629
- if (!value || typeof value !== "object" || Array.isArray(value)) return "";
628
+ let candidateValue = value;
629
+ if (typeof candidateValue === "string") {
630
+ const trimmed = candidateValue.trim();
631
+ if (!trimmed) return "";
632
+ if (trimmed.startsWith("{")) {
633
+ try {
634
+ const parsed = JSON.parse(trimmed);
635
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
636
+ candidateValue = parsed;
637
+ } else {
638
+ return trimmed;
639
+ }
640
+ } catch {
641
+ return trimmed;
642
+ }
643
+ } else {
644
+ return trimmed;
645
+ }
646
+ }
647
+ if (!candidateValue || typeof candidateValue !== "object" || Array.isArray(candidateValue)) {
648
+ return "";
649
+ }
630
650
  const currentLocale = String(locale || "en").trim() || "en";
631
- const direct = value[currentLocale];
651
+ const direct = candidateValue[currentLocale];
632
652
  if (typeof direct === "string" && direct.trim()) return direct;
633
653
  const base = currentLocale.split("-")[0];
634
- const baseValue = value[base];
654
+ const baseValue = candidateValue[base];
635
655
  if (typeof baseValue === "string" && baseValue.trim()) return baseValue;
636
- const english = value.en;
656
+ const english = candidateValue.en;
637
657
  if (typeof english === "string" && english.trim()) return english;
638
- for (const localized of Object.values(value)) {
658
+ for (const localized of Object.values(candidateValue)) {
639
659
  if (typeof localized === "string" && localized.trim()) return localized;
640
660
  }
641
661
  return "";
@@ -981,10 +1001,22 @@ function CatalogPage() {
981
1001
  if (!Array.isArray(tags) || !tags.includes(selectedTag)) return false;
982
1002
  }
983
1003
  if (!qq) return true;
984
- const hay = `${x.manifest?.title ?? x.name} ${x.manifest?.description ?? x.description ?? ""} ${x.slug}`.toLowerCase();
1004
+ const manifest = asRecord(x.manifest);
1005
+ const title = resolveMarketplaceText(manifest.title, locale) || readFirstString(x.name);
1006
+ const description = resolveMarketplaceText(manifest.description, locale) || readFirstString(x.description);
1007
+ const hay = `${title} ${description} ${x.slug}`.toLowerCase();
985
1008
  return hay.includes(qq);
986
1009
  });
987
- }, [items, installationsByXappId, installedOnly, q, selectedTag, env?.tags, env?.publishers]);
1010
+ }, [
1011
+ env?.publishers,
1012
+ env?.tags,
1013
+ installationsByXappId,
1014
+ installedOnly,
1015
+ items,
1016
+ locale,
1017
+ q,
1018
+ selectedTag
1019
+ ]);
988
1020
  return /* @__PURE__ */ jsxs3("div", { className: `mx-catalog-container ${isEmbedded ? "is-embedded" : ""}`, children: [
989
1021
  /* @__PURE__ */ jsxs3("header", { className: "mx-header", children: [
990
1022
  /* @__PURE__ */ jsx6("h1", { className: "mx-title", children: env?.title ?? t("common.marketplace", void 0, "Marketplace") }),
@@ -2730,7 +2762,7 @@ function useQuery4() {
2730
2762
  }
2731
2763
  function RequestDetailPage() {
2732
2764
  const { client, host, env } = useMarketplace();
2733
- const { t } = useMarketplaceI18n();
2765
+ const { t, locale } = useMarketplaceI18n();
2734
2766
  const { id } = useParams();
2735
2767
  const token = useQueryToken5();
2736
2768
  const query = useQuery4();
@@ -2747,10 +2779,11 @@ function RequestDetailPage() {
2747
2779
  const dataRecord = asRecord(data);
2748
2780
  const requestRecord = asRecord(dataRecord.request);
2749
2781
  const toolRecord = asRecord(dataRecord.tool);
2782
+ const manifestRecord = asRecord(dataRecord.manifest);
2750
2783
  const status = readFirstString(requestRecord.status) || void 0;
2751
2784
  const isTerminal = status === "COMPLETED" || status === "FAILED";
2752
2785
  const effectiveXappId = readFirstString(requestRecord.xapp_id, xappIdFilter);
2753
- const effectiveXappTitle = readFirstString(requestRecord.xapp_name);
2786
+ const effectiveXappTitle = resolveMarketplaceText(manifestRecord.title, locale) || readFirstString(requestRecord.xapp_name);
2754
2787
  const xappCrumbLabel = effectiveXappTitle || effectiveXappId;
2755
2788
  const isEmbedded = typeof window !== "undefined" && window.location.pathname.startsWith("/embed");
2756
2789
  const marketplaceTo = {
@@ -2842,7 +2875,7 @@ function RequestDetailPage() {
2842
2875
  };
2843
2876
  }, [id]);
2844
2877
  const emptyState = error === "Subject required" || error === "Session token required";
2845
- const title = readFirstString(toolRecord.title, requestRecord.tool_name) || t("activity.request_detail_title", void 0, "Request Details");
2878
+ const title = resolveMarketplaceText(toolRecord.title, locale) || readFirstString(requestRecord.tool_name) || t("activity.request_detail_title", void 0, "Request Details");
2846
2879
  const artifacts = Array.isArray(dataRecord.artifacts) ? dataRecord.artifacts : [];
2847
2880
  function attachArtifactLinks(value, arts) {
2848
2881
  if (typeof value === "string") {
@@ -3109,7 +3142,7 @@ function RequestDetailPage() {
3109
3142
  /* @__PURE__ */ jsxs8("div", { children: [
3110
3143
  /* @__PURE__ */ jsx12("h2", { className: "mx-title mx-request-section-title", children: title }),
3111
3144
  /* @__PURE__ */ jsxs8("div", { className: "mx-request-meta-row", children: [
3112
- /* @__PURE__ */ jsx12("span", { children: readString(requestRecord.xapp_name) }),
3145
+ /* @__PURE__ */ jsx12("span", { children: effectiveXappTitle || "\u2014" }),
3113
3146
  readString(requestRecord.xapp_version) && /* @__PURE__ */ jsxs8(Fragment5, { children: [
3114
3147
  /* @__PURE__ */ jsx12("span", { children: "\xB7" }),
3115
3148
  /* @__PURE__ */ jsxs8("span", { children: [
@@ -3128,7 +3161,7 @@ function RequestDetailPage() {
3128
3161
  ] }),
3129
3162
  /* @__PURE__ */ jsxs8("div", { className: "mx-meta-item", children: [
3130
3163
  /* @__PURE__ */ jsx12("span", { className: "mx-meta-label", children: t("common.tool", void 0, "Tool") }),
3131
- /* @__PURE__ */ jsx12("span", { className: "mx-meta-value", children: readFirstString(requestRecord.tool_name) || "\u2014" })
3164
+ /* @__PURE__ */ jsx12("span", { className: "mx-meta-value", children: title || readFirstString(requestRecord.tool_name) || "\u2014" })
3132
3165
  ] }),
3133
3166
  /* @__PURE__ */ jsxs8("div", { className: "mx-meta-item", children: [
3134
3167
  /* @__PURE__ */ jsx12("span", { className: "mx-meta-label", children: t("common.created", void 0, "Created") }),
@@ -3422,7 +3455,7 @@ function RequestDetailPage() {
3422
3455
  onClick: () => {
3423
3456
  const installationId = readFirstString(requestRecord.installation_id);
3424
3457
  const widgetId = readFirstString(widget.id);
3425
- const widgetName = readFirstString(widget.title, widget.widget_name) || t("common.widget", void 0, "Widget");
3458
+ const widgetName = resolveMarketplaceText(widget.title, locale) || readFirstString(widget.widget_name) || t("common.widget", void 0, "Widget");
3426
3459
  if (!installationId || !widgetId) return;
3427
3460
  if (env?.embedMode) {
3428
3461
  navigate({
@@ -3435,7 +3468,7 @@ function RequestDetailPage() {
3435
3468
  installationId,
3436
3469
  widgetId,
3437
3470
  xappId: readString(requestRecord.xapp_id),
3438
- xappTitle: readString(requestRecord.xapp_name),
3471
+ xappTitle: effectiveXappTitle,
3439
3472
  widgetName,
3440
3473
  toolName: readString(requestRecord.tool_name)
3441
3474
  });
@@ -3443,9 +3476,9 @@ function RequestDetailPage() {
3443
3476
  children: t(
3444
3477
  "activity.open_widget",
3445
3478
  {
3446
- widget: readFirstString(widget.title, widget.widget_name) || t("common.widget", void 0, "Widget")
3479
+ widget: resolveMarketplaceText(widget.title, locale) || readFirstString(widget.widget_name) || t("common.widget", void 0, "Widget")
3447
3480
  },
3448
- `Open ${readFirstString(widget.title, widget.widget_name) || t("common.widget", void 0, "Widget")}`
3481
+ `Open ${resolveMarketplaceText(widget.title, locale) || readFirstString(widget.widget_name) || t("common.widget", void 0, "Widget")}`
3449
3482
  )
3450
3483
  },
3451
3484
  readFirstString(widget.id)
@@ -3706,7 +3739,7 @@ function RequestsPage() {
3706
3739
  "..."
3707
3740
  ] }) }),
3708
3741
  /* @__PURE__ */ jsxs9("td", { "data-label": t("common.tool", void 0, "Tool"), children: [
3709
- /* @__PURE__ */ jsx13("div", { className: "mx-cell-bold", children: readFirstString(request.tool_name) || "\u2014" }),
3742
+ /* @__PURE__ */ jsx13("div", { className: "mx-cell-bold", children: resolveMarketplaceText(request.tool_title, locale) || readFirstString(request.tool_name) || "\u2014" }),
3710
3743
  tags.length > 0 && /* @__PURE__ */ jsx13("div", { className: "mx-card-tags mx-card-tags-inline", children: tags.slice(0, 3).map((t2) => /* @__PURE__ */ jsx13("span", { className: "mx-tag mx-tag-compact", children: t2 }, t2)) }),
3711
3744
  hasGuardInfo && /* @__PURE__ */ jsxs9("div", { className: "mx-guard-summary", children: [
3712
3745
  /* @__PURE__ */ jsxs9("div", { children: [
@@ -4127,7 +4160,7 @@ function XappDetailPage() {
4127
4160
  };
4128
4161
  const terms = asRecord4(manifest?.terms);
4129
4162
  const termsTitle = resolveMarketplaceText(terms?.title, locale) || t("xapp.terms_title", void 0, "Terms & Conditions");
4130
- const termsText = readString4(terms?.text);
4163
+ const termsText = resolveMarketplaceText(terms?.text, locale) || readString4(terms?.text);
4131
4164
  const termsUrl = readString4(terms?.url);
4132
4165
  const hasTermsContent = Boolean(termsText || termsUrl);
4133
4166
  const requiresTerms = Boolean(terms || action === "install" || action === "update");
@@ -4164,7 +4197,7 @@ function XappDetailPage() {
4164
4197
  widgetId,
4165
4198
  xappId: String(xappId ?? ""),
4166
4199
  xappTitle: String(title),
4167
- widgetName: readString4(widget?.title) || readString4(widget?.widget_name) || readString4(widget?.name) || t("common.widget", void 0, "Widget"),
4200
+ widgetName: resolveMarketplaceText(widget?.title, locale) || readString4(widget?.widget_name) || readString4(widget?.name) || t("common.widget", void 0, "Widget"),
4168
4201
  toolName: readString4(widget?.bind_tool_name)
4169
4202
  });
4170
4203
  }, [
@@ -4172,6 +4205,7 @@ function XappDetailPage() {
4172
4205
  env?.embedMode,
4173
4206
  host,
4174
4207
  installation,
4208
+ locale,
4175
4209
  queryToolName,
4176
4210
  requestedWidget,
4177
4211
  title,
@@ -4421,7 +4455,7 @@ function XappDetailPage() {
4421
4455
  void 0,
4422
4456
  "No app views are currently available."
4423
4457
  ) }) : /* @__PURE__ */ jsx14("div", { className: "mx-detail-widget-list", children: widgets.map((w, idx) => {
4424
- const name = readString4(w.title) || readString4(w.widget_name) || readString4(w.name) || readString4(w.id) || t("common.widget", void 0, "Widget");
4458
+ const name = resolveMarketplaceText(w.title, locale) || readString4(w.widget_name) || readString4(w.name) || readString4(w.id) || t("common.widget", void 0, "Widget");
4425
4459
  const disabled = !widgetsEnabled;
4426
4460
  const isDefault = readBoolean(w.default, false) || idx === 0 && !widgets.some((ww) => readBoolean(ww.default, false));
4427
4461
  const widgetType = String(w.type || "").toLowerCase();
@@ -4776,7 +4810,7 @@ function XappDetailPage() {
4776
4810
  widgetId: readString4(defaultWidget.id),
4777
4811
  xappId: String(xappId ?? ""),
4778
4812
  xappTitle: String(title),
4779
- widgetName: readString4(defaultWidget?.title) || readString4(defaultWidget?.widget_name) || readString4(defaultWidget?.name) || t("common.widget", void 0, "Widget"),
4813
+ widgetName: resolveMarketplaceText(defaultWidget?.title, locale) || readString4(defaultWidget?.widget_name) || readString4(defaultWidget?.name) || t("common.widget", void 0, "Widget"),
4780
4814
  toolName: readString4(defaultWidget?.bind_tool_name)
4781
4815
  });
4782
4816
  },
@@ -5085,7 +5119,7 @@ function toSessionExpiredUi(input, t) {
5085
5119
  }
5086
5120
  function WidgetView() {
5087
5121
  const { client, host, env } = useMarketplace();
5088
- const { t } = useMarketplaceI18n();
5122
+ const { t, locale } = useMarketplaceI18n();
5089
5123
  const { installationId, widgetId } = useParams3();
5090
5124
  const token = useQueryToken8();
5091
5125
  const iframeRef = useRef2(null);
@@ -5146,7 +5180,7 @@ function WidgetView() {
5146
5180
  setXappDetail(res);
5147
5181
  const detail = asRecord(res);
5148
5182
  setXappTitle(
5149
- readFirstString(asRecord(detail.manifest).title, asRecord(detail.xapp).name) || "App"
5183
+ resolveMarketplaceText(asRecord(detail.manifest).title, locale) || readFirstString(asRecord(detail.xapp).name) || "App"
5150
5184
  );
5151
5185
  }
5152
5186
  } catch {
@@ -5155,7 +5189,7 @@ function WidgetView() {
5155
5189
  return () => {
5156
5190
  alive = false;
5157
5191
  };
5158
- }, [installationId, client, host]);
5192
+ }, [installationId, client, host, locale]);
5159
5193
  useEffect9(() => {
5160
5194
  if (!xappId) {
5161
5195
  setDiscoveredOperationalSurfaces([]);