@open-resource-discovery/metadata-renderer 1.0.0 → 1.1.0
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.
- package/README.md +1 -0
- package/dist/a2a/index.d.ts +1 -1
- package/dist/a2a.js +1 -1
- package/dist/asyncApi/asyncapi-browser.d.ts +10 -0
- package/dist/asyncApi/customAttributes/attributeLink.d.ts +1 -1
- package/dist/asyncApi/index.d.ts +2 -2
- package/dist/asyncapi.js +1 -1
- package/dist/chunks/{a2a-B5lkgqLU.js → a2a-BfdUdobQ.js} +1 -1
- package/dist/chunks/{asyncApi-K0uQpQwz.js → asyncApi-B7WZqXRI.js} +16 -153
- package/dist/chunks/{csn-D4GBs8tC.js → csn-CIBA2ds5.js} +58 -189
- package/dist/chunks/{mcp-qA5sYRAN.js → mcp-Yb3SHisP.js} +1 -1
- package/dist/chunks/{openApi-Ccp9Pa_k.js → openApi-sDysRKUP.js} +15 -323
- package/dist/chunks/overlay-CO0o6FYy.js +41 -0
- package/dist/chunks/{utils-BC3WF3-9.js → utils-BLQCpHkJ.js} +2 -0
- package/dist/core/ShadowRoot.d.ts +1 -1
- package/dist/core/dispatch.d.ts +3 -0
- package/dist/core/dispatch.test.d.ts +1 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/utils.d.ts +1 -1
- package/dist/csn/customAttributes/postProcess.d.ts +1 -0
- package/dist/csn/customAttributes/postProcess.test.d.ts +1 -0
- package/dist/csn/index.d.ts +1 -2
- package/dist/csn.js +1 -1
- package/dist/entries/overlay.d.ts +2 -0
- package/dist/index.css +6815 -2141
- package/dist/index.d.ts +2 -0
- package/dist/index.js +650 -28
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp.js +1 -1
- package/dist/openApi/customAttributes/attributeLink.d.ts +1 -1
- package/dist/openApi/index.d.ts +1 -2
- package/dist/openapi.js +1 -1
- package/dist/overlay/index.d.ts +7 -0
- package/dist/overlay.js +2 -0
- package/dist/styles.d.ts +1 -0
- package/dist/styles.js +1 -0
- package/dist/types.d.ts +1 -3
- package/dist/vendor.d.ts +1 -0
- package/package.json +30 -20
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { i as loadObject } from "./utils-
|
|
1
|
+
import { i as loadObject } from "./utils-BLQCpHkJ.js";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import { createElement, useEffect, useId, useMemo, useRef
|
|
3
|
+
import { createElement, useEffect, useId, useMemo, useRef } from "react";
|
|
4
4
|
import { ApiReferenceReact } from "@scalar/api-reference-react";
|
|
5
5
|
import Markdown from "react-markdown";
|
|
6
|
-
import {
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { ReactRenderer } from "@scalar/react-renderer";
|
|
8
8
|
//#region src/lib/openApi/utils/context.ts
|
|
9
9
|
var openApiContext = {
|
|
@@ -522,316 +522,6 @@ function buildScalarThemeStyles(id, theme) {
|
|
|
522
522
|
})()].filter(Boolean).join("\n\n");
|
|
523
523
|
}
|
|
524
524
|
//#endregion
|
|
525
|
-
//#region src/lib/openApi/customAttributes/sapAttributes/root/typeCheckXxtOverview.ts
|
|
526
|
-
function typeCheckExSapExtOverviewExSapExtOverview(obj) {
|
|
527
|
-
if (typeof obj !== "object" || obj === null) return false;
|
|
528
|
-
if (!("xSapExtOverview" in obj) || !Array.isArray(obj.xSapExtOverview)) return false;
|
|
529
|
-
return obj.xSapExtOverview.every((xSapExtOverview) => {
|
|
530
|
-
if (typeof xSapExtOverview !== "object" || xSapExtOverview === null) return false;
|
|
531
|
-
if (!("name" in xSapExtOverview) || !("values" in xSapExtOverview)) return false;
|
|
532
|
-
if (typeof xSapExtOverview.name !== "string") return false;
|
|
533
|
-
if (typeof xSapExtOverview.values === "string") return true;
|
|
534
|
-
if (!Array.isArray(xSapExtOverview.values)) return false;
|
|
535
|
-
if (xSapExtOverview.values.every((value) => typeof value === "string")) return true;
|
|
536
|
-
return xSapExtOverview.values.every((value) => {
|
|
537
|
-
if (typeof value !== "object" || value === null) return false;
|
|
538
|
-
if (!("text" in value) || typeof value.text !== "string") return false;
|
|
539
|
-
return "format" in value && (value.format === "plain" || value.format === "markdown");
|
|
540
|
-
});
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
//#endregion
|
|
544
|
-
//#region src/lib/openApi/customAttributes/sapAttributes/root/extOverview.tsx
|
|
545
|
-
function extOverview(props) {
|
|
546
|
-
if (!typeCheckExSapExtOverviewExSapExtOverview(props)) return null;
|
|
547
|
-
const { xSapExtOverview } = props;
|
|
548
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
549
|
-
className: "sap-api-container",
|
|
550
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
551
|
-
className: "sap-api-label sap-api-label--root",
|
|
552
|
-
children: ["SAP Extensibility Overview ", /* @__PURE__ */ jsx(attributeLink, { attributeName: "x-sap-ext-overview" })]
|
|
553
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
554
|
-
className: "sap-api-value sap-api-value--root",
|
|
555
|
-
children: xSapExtOverview.map((extension) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("strong", { children: extension.name }), /* @__PURE__ */ jsx("ul", {
|
|
556
|
-
className: "sap-api-list",
|
|
557
|
-
children: typeof extension.values === "string" ? /* @__PURE__ */ jsx("li", { children: extension.values }) : extension.values.map((value) => typeof value === "string" ? /* @__PURE__ */ jsx("li", { children: value }, value) : /* @__PURE__ */ jsx("li", { children: value.format === "plain" ? value.text : /* @__PURE__ */ jsx(Markdown, { children: value.text }) }, value.text))
|
|
558
|
-
})] }, extension.name))
|
|
559
|
-
})]
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
//#endregion
|
|
563
|
-
//#region src/lib/openApi/customAttributes/sapAttributes/root/stateInfo.tsx
|
|
564
|
-
var background = {
|
|
565
|
-
ACTIVE: "color-mix(in srgb, var(--scalar-color-green) 15%, transparent)",
|
|
566
|
-
BETA: "color-mix(in srgb, var(--scalar-color-blue) 15%, transparent)",
|
|
567
|
-
DEPRECATED: "color-mix(in srgb, var(--scalar-color-orange) 15%, transparent)",
|
|
568
|
-
DECOMMISSIONED: "color-mix(in srgb, var(--scalar-color-red) 15%, transparent)"
|
|
569
|
-
};
|
|
570
|
-
var color = {
|
|
571
|
-
ACTIVE: "var(--scalar-color-green)",
|
|
572
|
-
BETA: "var(--scalar-color-blue)",
|
|
573
|
-
DEPRECATED: "var(--scalar-color-orange)",
|
|
574
|
-
DECOMMISSIONED: "var(--scalar-color-red)"
|
|
575
|
-
};
|
|
576
|
-
function StateInfo({ xSapStateInfo }) {
|
|
577
|
-
if (!xSapStateInfo) return null;
|
|
578
|
-
const status = xSapStateInfo.state?.toUpperCase();
|
|
579
|
-
const badge = /* @__PURE__ */ jsx("span", {
|
|
580
|
-
style: {
|
|
581
|
-
display: "inline-block",
|
|
582
|
-
borderRadius: "10px",
|
|
583
|
-
padding: "0 6px",
|
|
584
|
-
background: background[status] || "",
|
|
585
|
-
color: color[status] || ""
|
|
586
|
-
},
|
|
587
|
-
children: status
|
|
588
|
-
});
|
|
589
|
-
const dateFormatter = new Intl.DateTimeFormat("en-GB", { dateStyle: "long" });
|
|
590
|
-
const formatDate = (d) => {
|
|
591
|
-
const parsed = new Date(d);
|
|
592
|
-
return isNaN(parsed.getTime()) ? d : dateFormatter.format(parsed);
|
|
593
|
-
};
|
|
594
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
595
|
-
className: "sap-api-container",
|
|
596
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
597
|
-
className: "sap-api-label",
|
|
598
|
-
children: ["API State ", /* @__PURE__ */ jsx(attributeLink, { attributeName: "x-sap-stateInfo" })]
|
|
599
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
600
|
-
className: "sap-api-value",
|
|
601
|
-
children: [
|
|
602
|
-
badge,
|
|
603
|
-
xSapStateInfo.deprecationDate && /* @__PURE__ */ jsxs("div", { children: ["Deprecated on ", formatDate(xSapStateInfo.deprecationDate)] }),
|
|
604
|
-
xSapStateInfo.decommissionedDate && /* @__PURE__ */ jsxs("div", { children: ["Decommissioned on ", formatDate(xSapStateInfo.decommissionedDate)] }),
|
|
605
|
-
xSapStateInfo.successorApi && /* @__PURE__ */ jsxs("div", { children: ["Successor API: ", /* @__PURE__ */ jsx("a", {
|
|
606
|
-
href: xSapStateInfo.successorApi,
|
|
607
|
-
target: "_blank",
|
|
608
|
-
rel: "noreferrer",
|
|
609
|
-
className: "sap-api-link",
|
|
610
|
-
children: xSapStateInfo.successorApi
|
|
611
|
-
})] })
|
|
612
|
-
]
|
|
613
|
-
})]
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
//#endregion
|
|
617
|
-
//#region src/lib/openApi/customAttributes/sapAttributes/root/ordId.tsx
|
|
618
|
-
function CopyIcon() {
|
|
619
|
-
return /* @__PURE__ */ jsxs("svg", {
|
|
620
|
-
viewBox: "0 0 24 24",
|
|
621
|
-
width: "1em",
|
|
622
|
-
height: "1em",
|
|
623
|
-
fill: "none",
|
|
624
|
-
stroke: "currentColor",
|
|
625
|
-
strokeWidth: "2",
|
|
626
|
-
"aria-hidden": "true",
|
|
627
|
-
children: [/* @__PURE__ */ jsx("rect", {
|
|
628
|
-
x: "9",
|
|
629
|
-
y: "9",
|
|
630
|
-
width: "13",
|
|
631
|
-
height: "13",
|
|
632
|
-
rx: "2"
|
|
633
|
-
}), /* @__PURE__ */ jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })]
|
|
634
|
-
});
|
|
635
|
-
}
|
|
636
|
-
function CheckIcon() {
|
|
637
|
-
return /* @__PURE__ */ jsx("svg", {
|
|
638
|
-
viewBox: "0 0 24 24",
|
|
639
|
-
width: "1em",
|
|
640
|
-
height: "1em",
|
|
641
|
-
fill: "none",
|
|
642
|
-
stroke: "currentColor",
|
|
643
|
-
strokeWidth: "2",
|
|
644
|
-
"aria-hidden": "true",
|
|
645
|
-
children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" })
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
function ordId({ xSapOrdId }) {
|
|
649
|
-
const [copied, setCopied] = useState(false);
|
|
650
|
-
if (!xSapOrdId) return null;
|
|
651
|
-
const copy = () => {
|
|
652
|
-
navigator.clipboard?.writeText(xSapOrdId).then(() => {
|
|
653
|
-
setCopied(true);
|
|
654
|
-
setTimeout(() => setCopied(false), 1500);
|
|
655
|
-
});
|
|
656
|
-
};
|
|
657
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
658
|
-
className: "sap-api-container",
|
|
659
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
660
|
-
className: "sap-api-label",
|
|
661
|
-
children: ["ORD ID ", /* @__PURE__ */ jsx(attributeLink, { attributeName: "x-sap-ord-id" })]
|
|
662
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
663
|
-
className: "sap-api-value sap-api-ord-id",
|
|
664
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
665
|
-
className: "sap-api-ord-id-text",
|
|
666
|
-
children: xSapOrdId
|
|
667
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
668
|
-
type: "button",
|
|
669
|
-
className: "sap-api-copy-btn",
|
|
670
|
-
onClick: copy,
|
|
671
|
-
"aria-label": "Copy ORD ID",
|
|
672
|
-
title: copied ? "Copied" : "Copy",
|
|
673
|
-
children: copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {})
|
|
674
|
-
})]
|
|
675
|
-
})]
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
//#endregion
|
|
679
|
-
//#region src/lib/openApi/customAttributes/sapAttributes/operation/deprecatedOperation.tsx
|
|
680
|
-
function deprecatedOperation({ xSapDeprecatedOperation }) {
|
|
681
|
-
const deprecationDate = new Intl.DateTimeFormat("en-GB", { dateStyle: "long" }).format(new Date(xSapDeprecatedOperation.deprecationDate));
|
|
682
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
683
|
-
className: "sap-api-container",
|
|
684
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
685
|
-
className: "sap-api-label",
|
|
686
|
-
children: ["SAP Deprecated Operation ", /* @__PURE__ */ jsx(attributeLink, { attributeName: "x-sap-deprecated-operation" })]
|
|
687
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
688
|
-
className: "sap-api-value",
|
|
689
|
-
children: [
|
|
690
|
-
"Deprecated on ",
|
|
691
|
-
deprecationDate,
|
|
692
|
-
" ",
|
|
693
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
694
|
-
!xSapDeprecatedOperation.successorOperationRef && !xSapDeprecatedOperation.successorOperationId ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
695
|
-
" Successor ",
|
|
696
|
-
xSapDeprecatedOperation.successorOperationRef ? /* @__PURE__ */ jsx("a", {
|
|
697
|
-
href: xSapDeprecatedOperation.successorOperationRef,
|
|
698
|
-
rel: "noreferrer, noopener",
|
|
699
|
-
children: xSapDeprecatedOperation.successorOperationRef
|
|
700
|
-
}) : null,
|
|
701
|
-
xSapDeprecatedOperation.successorOperationId ? /* @__PURE__ */ jsx("span", { children: xSapDeprecatedOperation.successorOperationId }) : null
|
|
702
|
-
] })
|
|
703
|
-
]
|
|
704
|
-
})]
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
//#endregion
|
|
708
|
-
//#region src/lib/openApi/customAttributes/sapAttributes/schema/odmEntityName.tsx
|
|
709
|
-
function odmEntityName({ xSapOdmEntityName }) {
|
|
710
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
711
|
-
className: "sap-api-container",
|
|
712
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
713
|
-
className: "sap-api-label",
|
|
714
|
-
children: ["ODM entity name ", /* @__PURE__ */ jsx(attributeLink, { attributeName: "x-sap-odm-entity-name" })]
|
|
715
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
716
|
-
className: "sap-api-value",
|
|
717
|
-
children: xSapOdmEntityName
|
|
718
|
-
})]
|
|
719
|
-
});
|
|
720
|
-
}
|
|
721
|
-
//#endregion
|
|
722
|
-
//#region src/lib/openApi/customAttributes/sapAttributes/schema/odmSemanticKey.tsx
|
|
723
|
-
function odmSemanticKey({ xSapOdmSemanticKey }) {
|
|
724
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
725
|
-
className: "sap-api-container",
|
|
726
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
727
|
-
className: "sap-api-label",
|
|
728
|
-
children: ["ODM Semantic Key ", /* @__PURE__ */ jsx(attributeLink, { attributeName: "x-sap-odm-semantic-key" })]
|
|
729
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
730
|
-
className: "sap-api-value",
|
|
731
|
-
children: xSapOdmSemanticKey.map((entry) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("strong", { children: entry.name }), /* @__PURE__ */ jsx("ul", {
|
|
732
|
-
className: "sap-api-list",
|
|
733
|
-
children: entry.values.map((v) => /* @__PURE__ */ jsx("li", { children: v }, v))
|
|
734
|
-
})] }, entry.name))
|
|
735
|
-
})]
|
|
736
|
-
});
|
|
737
|
-
}
|
|
738
|
-
//#endregion
|
|
739
|
-
//#region src/lib/openApi/customAttributes/sapAttributes/sapPreset.ts
|
|
740
|
-
function component(fn) {
|
|
741
|
-
return { component: fn };
|
|
742
|
-
}
|
|
743
|
-
var sapOpenApiAttributesConfig = {
|
|
744
|
-
prefixStartsWith: "x-sap-",
|
|
745
|
-
documentationUrl: (name, { version }) => `https://github.com/SAP/openapi-specification/tree/main/sap-schemas/v${version}#${name}`,
|
|
746
|
-
extensions: {
|
|
747
|
-
"x-sap-compliance-level": {
|
|
748
|
-
type: "link",
|
|
749
|
-
label: "SAP Compliance Level",
|
|
750
|
-
callback: (v) => {
|
|
751
|
-
return {
|
|
752
|
-
"sap:base:v1": "https://github.com/open-resource-discovery/specification/blob/main/docs/spec-extensions/policy-levels/sap-base-v1.md",
|
|
753
|
-
"sap:core:v1": "https://github.com/open-resource-discovery/specification/blob/main/docs/spec-extensions/policy-levels/sap-core-v1.md",
|
|
754
|
-
"sap:core:v2": "https://github.com/open-resource-discovery/specification/blob/main/docs/spec-extensions/policy-levels/sap-core-v1.md"
|
|
755
|
-
}[String(v)];
|
|
756
|
-
}
|
|
757
|
-
},
|
|
758
|
-
"x-sap-shortText": {
|
|
759
|
-
type: "string",
|
|
760
|
-
label: "SAP Short Text"
|
|
761
|
-
},
|
|
762
|
-
"x-sap-software-min-version": {
|
|
763
|
-
type: "string",
|
|
764
|
-
label: "SAP Software Version"
|
|
765
|
-
},
|
|
766
|
-
"x-sap-api-type": {
|
|
767
|
-
type: "string",
|
|
768
|
-
label: "SAP API Type"
|
|
769
|
-
},
|
|
770
|
-
"x-sap-direction": {
|
|
771
|
-
type: "string",
|
|
772
|
-
label: "SAP Direction"
|
|
773
|
-
},
|
|
774
|
-
"x-sap-ord-id": component(ordId),
|
|
775
|
-
"x-sap-operation-intent": {
|
|
776
|
-
type: "string",
|
|
777
|
-
label: "SAP Operation Intent"
|
|
778
|
-
},
|
|
779
|
-
"x-sap-odm-oid": {
|
|
780
|
-
type: "string",
|
|
781
|
-
label: "ODM OID"
|
|
782
|
-
},
|
|
783
|
-
"x-sap-odm-oid-reference-entity-name": {
|
|
784
|
-
type: "string",
|
|
785
|
-
label: "ODM OID Reference Entity Name"
|
|
786
|
-
},
|
|
787
|
-
"x-sap-precision": {
|
|
788
|
-
type: "number",
|
|
789
|
-
label: "SAP Precision"
|
|
790
|
-
},
|
|
791
|
-
"x-sap-scale": {
|
|
792
|
-
type: "number",
|
|
793
|
-
label: "SAP Scale"
|
|
794
|
-
},
|
|
795
|
-
"x-sap-root-entity": {
|
|
796
|
-
type: "boolean",
|
|
797
|
-
label: "SAP Root Entity"
|
|
798
|
-
},
|
|
799
|
-
"x-sap-dpp-entity-semantics": {
|
|
800
|
-
type: "string",
|
|
801
|
-
label: "SAP DPP: Entity Semantics"
|
|
802
|
-
},
|
|
803
|
-
"x-sap-dpp-data-subject-role": {
|
|
804
|
-
type: "string",
|
|
805
|
-
label: "SAP DPP: Data Subject Role"
|
|
806
|
-
},
|
|
807
|
-
"x-sap-dpp-data-subject-role-description": {
|
|
808
|
-
type: "string",
|
|
809
|
-
label: "SAP DPP: Data Subject Role Description"
|
|
810
|
-
},
|
|
811
|
-
"x-sap-dpp-field-semantics": {
|
|
812
|
-
type: "string",
|
|
813
|
-
label: "SAP DPP: Field Semantics"
|
|
814
|
-
},
|
|
815
|
-
"x-sap-dpp-is-potentially-personal": {
|
|
816
|
-
type: "boolean",
|
|
817
|
-
label: "SAP DPP: Potentially Personal"
|
|
818
|
-
},
|
|
819
|
-
"x-sap-dpp-is-potentially-sensitive": {
|
|
820
|
-
type: "boolean",
|
|
821
|
-
label: "SAP DPP: Potentially Sensitive"
|
|
822
|
-
},
|
|
823
|
-
"x-sap-ext-overview": component(extOverview),
|
|
824
|
-
"x-sap-stateInfo": component(StateInfo),
|
|
825
|
-
"x-sap-extensible": {
|
|
826
|
-
type: "object",
|
|
827
|
-
label: "SAP Extensible"
|
|
828
|
-
},
|
|
829
|
-
"x-sap-deprecated-operation": component(deprecatedOperation),
|
|
830
|
-
"x-sap-odm-entity-name": component(odmEntityName),
|
|
831
|
-
"x-sap-odm-semantic-key": component(odmSemanticKey)
|
|
832
|
-
}
|
|
833
|
-
};
|
|
834
|
-
//#endregion
|
|
835
525
|
//#region src/lib/openApi/styles.ts
|
|
836
526
|
var styles_default = `
|
|
837
527
|
.sap-api-container {
|
|
@@ -1028,11 +718,12 @@ a:hover {
|
|
|
1028
718
|
`;
|
|
1029
719
|
//#endregion
|
|
1030
720
|
//#region src/lib/openApi/index.tsx
|
|
1031
|
-
function OpenApiRenderer({ content,
|
|
721
|
+
function OpenApiRenderer({ content, customAttributes, className, theme }) {
|
|
1032
722
|
const id = useId();
|
|
1033
723
|
const containerRef = useRef(null);
|
|
1034
724
|
const isDark = className?.split(/\s+/).includes("dark") ?? false;
|
|
1035
|
-
const activeConfigs = customAttributes ?? [
|
|
725
|
+
const activeConfigs = useMemo(() => customAttributes ?? [], [customAttributes]);
|
|
726
|
+
const isEnabled = customAttributes !== void 0;
|
|
1036
727
|
useEffect(() => {
|
|
1037
728
|
const el = containerRef.current;
|
|
1038
729
|
if (!el) return;
|
|
@@ -1043,26 +734,27 @@ function OpenApiRenderer({ content, showCustomAttributes = true, customAttribute
|
|
|
1043
734
|
return () => {
|
|
1044
735
|
ro.disconnect();
|
|
1045
736
|
if (window.location.hash) history.replaceState(null, "", window.location.pathname + window.location.search);
|
|
737
|
+
document.body.classList.remove("light-mode", "dark-mode");
|
|
1046
738
|
};
|
|
1047
739
|
}, []);
|
|
1048
740
|
const customAttributesKey = useMemo(() => {
|
|
1049
|
-
if (!
|
|
741
|
+
if (!isEnabled) return "";
|
|
1050
742
|
const parsed = loadObject(content);
|
|
1051
743
|
if (!parsed) return "";
|
|
1052
744
|
return activeConfigs.flatMap((config) => extractCustomAttributeValues(parsed, config.prefixStartsWith ?? "").map(([k, v]) => `${k}=${JSON.stringify(v)}`)).join("|");
|
|
1053
745
|
}, [
|
|
1054
746
|
content,
|
|
1055
|
-
|
|
747
|
+
isEnabled,
|
|
1056
748
|
activeConfigs
|
|
1057
749
|
]);
|
|
1058
750
|
const configuration = useMemo(() => {
|
|
1059
751
|
openApiContext.version = getVersion(content);
|
|
1060
|
-
openApiContext.configs =
|
|
752
|
+
openApiContext.configs = isEnabled ? activeConfigs : [];
|
|
1061
753
|
const parsed = loadObject(content);
|
|
1062
754
|
const prefixes = activeConfigs.map((c) => c.prefixStartsWith).filter(Boolean);
|
|
1063
755
|
return {
|
|
1064
|
-
content:
|
|
1065
|
-
plugins:
|
|
756
|
+
content: isEnabled && parsed && prefixes.length ? injectSchemaExtensions(parsed, prefixes) : parsed ?? content,
|
|
757
|
+
plugins: isEnabled ? [buildCustomAttributesPlugin(parsed, activeConfigs)] : [],
|
|
1066
758
|
forceDarkModeState: isDark ? "dark" : "light",
|
|
1067
759
|
hideDarkModeToggle: true,
|
|
1068
760
|
hideClientButton: true,
|
|
@@ -1071,7 +763,7 @@ function OpenApiRenderer({ content, showCustomAttributes = true, customAttribute
|
|
|
1071
763
|
}, [
|
|
1072
764
|
content,
|
|
1073
765
|
isDark,
|
|
1074
|
-
|
|
766
|
+
isEnabled,
|
|
1075
767
|
activeConfigs
|
|
1076
768
|
]);
|
|
1077
769
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -1084,9 +776,9 @@ function OpenApiRenderer({ content, showCustomAttributes = true, customAttribute
|
|
|
1084
776
|
children: [
|
|
1085
777
|
/* @__PURE__ */ jsx("style", { children: styles_default }),
|
|
1086
778
|
theme && /* @__PURE__ */ jsx("style", { children: buildScalarThemeStyles(id, theme) }),
|
|
1087
|
-
/* @__PURE__ */ jsx(ApiReferenceReact, { configuration }, `${isDark ? "dark" : "light"}-${
|
|
779
|
+
/* @__PURE__ */ jsx(ApiReferenceReact, { configuration }, `${isDark ? "dark" : "light"}-${isEnabled}-${customAttributesKey}`)
|
|
1088
780
|
]
|
|
1089
781
|
});
|
|
1090
782
|
}
|
|
1091
783
|
//#endregion
|
|
1092
|
-
export {
|
|
784
|
+
export { attributeLink as n, OpenApiRenderer as t };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { t as buildShadcnThemeStyle } from "./utils-BLQCpHkJ.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { useEffect, useId } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { OverlayCardView, useOverlayStore, useTheme } from "@open-resource-discovery/overlay-editor/card-view";
|
|
6
|
+
//#region src/lib/overlay/index.tsx
|
|
7
|
+
function OverlayRenderer({ content, className, theme }) {
|
|
8
|
+
const id = useId();
|
|
9
|
+
const { setTheme } = useTheme();
|
|
10
|
+
const isDark = className?.split(/\s+/).includes("dark") ?? false;
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
useOverlayStore.getState().setRawJson(content);
|
|
13
|
+
}, [content]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setTheme(isDark ? "dark" : "light");
|
|
16
|
+
}, [isDark, setTheme]);
|
|
17
|
+
const themeStyle = theme ? buildShadcnThemeStyle("overlay-root", id, theme) : null;
|
|
18
|
+
const footerThemeStyle = theme ? buildShadcnThemeStyle("overlay-sidebar-footer-mobile", id, theme) : null;
|
|
19
|
+
const scopedStyles = `
|
|
20
|
+
${`[data-renderer-id="${id}"] .overlay-root`} code {
|
|
21
|
+
color: var(--ord-code-fg, var(--ord-foreground, #24292f));
|
|
22
|
+
background-color: var(--ord-code-bg, var(--ord-muted, #f6f8fa));
|
|
23
|
+
}
|
|
24
|
+
[data-renderer-id="${id}"] .overlay-sidebar-footer-mobile {
|
|
25
|
+
background: var(--ord-background);
|
|
26
|
+
color: var(--ord-muted-foreground);
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
30
|
+
"data-renderer-id": id,
|
|
31
|
+
className: "h-full",
|
|
32
|
+
children: [
|
|
33
|
+
/* @__PURE__ */ jsx("style", { children: scopedStyles }),
|
|
34
|
+
themeStyle && /* @__PURE__ */ jsx("style", { children: themeStyle }),
|
|
35
|
+
footerThemeStyle && /* @__PURE__ */ jsx("style", { children: footerThemeStyle }),
|
|
36
|
+
/* @__PURE__ */ jsx(OverlayCardView, {})
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { OverlayRenderer as t };
|
|
@@ -25,6 +25,7 @@ function detectMetaType(content) {
|
|
|
25
25
|
if (typeof o.csnInteropEffective === "string") return "csn";
|
|
26
26
|
if (typeof o.openapi === "string" || typeof o.swagger === "string") return "openapi";
|
|
27
27
|
if (typeof o.asyncapi === "string") return "asyncapi";
|
|
28
|
+
if (typeof o.ordOverlay === "string" && Array.isArray(o.patches)) return "overlay";
|
|
28
29
|
if (Array.isArray(o.supportedProtocolVersions)) return "mcp";
|
|
29
30
|
if (typeof o.capabilities === "object" && o.capabilities !== null && Array.isArray(o.skills)) return "a2a";
|
|
30
31
|
return "unknown";
|
|
@@ -38,6 +39,7 @@ function extractVersion(type, content) {
|
|
|
38
39
|
if (typeof o.swagger === "string") return "2.0";
|
|
39
40
|
return "";
|
|
40
41
|
case "asyncapi": return typeof o.asyncapi === "string" ? o.asyncapi : "";
|
|
42
|
+
case "overlay": return typeof o.ordOverlay === "string" ? o.ordOverlay : "";
|
|
41
43
|
case "a2a":
|
|
42
44
|
if (typeof o.protocolVersion === "string") return o.protocolVersion;
|
|
43
45
|
if (Array.isArray(o.supportedInterfaces) && o.supportedInterfaces.length > 0) {
|
|
@@ -3,4 +3,4 @@ export type ShadowRootProps = {
|
|
|
3
3
|
styles?: string;
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
};
|
|
6
|
-
export declare function ShadowRoot({ styles, children }: ShadowRootProps): import(
|
|
6
|
+
export declare function ShadowRoot({ styles, children }: ShadowRootProps): import('react').JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/core/index.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export type MetadataRendererProps = {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
theme?: RendererTheme;
|
|
10
10
|
};
|
|
11
|
-
export declare function MetadataRenderer({ content, renderers, options, type, className, theme }: MetadataRendererProps): import(
|
|
11
|
+
export declare function MetadataRenderer({ content, renderers, options, type, className, theme }: MetadataRendererProps): import('react').JSX.Element;
|
package/dist/core/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RendererTheme } from '../types';
|
|
2
|
-
export type MetaType = 'csn' | 'openapi' | 'asyncapi' | 'a2a' | 'mcp' | 'unknown';
|
|
2
|
+
export type MetaType = 'csn' | 'openapi' | 'asyncapi' | 'overlay' | 'a2a' | 'mcp' | 'unknown';
|
|
3
3
|
export declare function loadObject(content: string): undefined | object;
|
|
4
4
|
export declare function detectMetaType(content: string): MetaType;
|
|
5
5
|
export declare function extractVersion(type: MetaType, content: string): string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CsnCustomAttributesConfig } from './types';
|
|
2
2
|
type Rec = Record<string, unknown>;
|
|
3
3
|
export declare function discoverAnnotationKeys(doc: Rec, prefix: string): string[];
|
|
4
|
+
export declare function stripAllAnnotations(html: string): string;
|
|
4
5
|
export declare function applyAnnotationRenderers(html: string, configs: CsnCustomAttributesConfig[], doc: Rec | null): string;
|
|
5
6
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/csn/index.d.ts
CHANGED
|
@@ -4,9 +4,8 @@ import { CsnCustomAttributesConfig } from './customAttributes/types';
|
|
|
4
4
|
export type CsnRendererProps = {
|
|
5
5
|
content: string;
|
|
6
6
|
config?: CsnRendererConfig;
|
|
7
|
-
showCustomAttributes?: boolean;
|
|
8
7
|
customAttributes?: CsnCustomAttributesConfig[];
|
|
9
8
|
className?: string;
|
|
10
9
|
theme?: RendererTheme;
|
|
11
10
|
};
|
|
12
|
-
export declare function CsnRenderer({ content, config,
|
|
11
|
+
export declare function CsnRenderer({ content, config, customAttributes, className, theme }: CsnRendererProps): import('react').JSX.Element;
|
package/dist/csn.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as CsnRenderer } from "./chunks/csn-
|
|
1
|
+
import { t as CsnRenderer } from "./chunks/csn-CIBA2ds5.js";
|
|
2
2
|
export { CsnRenderer };
|