@eventcatalog/core 3.4.0 → 3.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.
@@ -571,164 +571,47 @@ nodeGraphs.push({
571
571
  </script>
572
572
 
573
573
  <script>
574
- // Listen for Astro transititions
574
+ import { destroyZoomInstances, renderMermaidWithZoom } from '@utils/mermaid-zoom';
575
+
576
+ // Listen for Astro transitions
575
577
  document.addEventListener('astro:page-load', () => {
578
+ destroyZoomInstances();
576
579
  const graphs = document.getElementsByClassName('mermaid');
577
- if (document.getElementsByClassName('mermaid').length > 0) {
578
- renderDiagrams(graphs);
580
+ if (graphs.length > 0) {
581
+ renderMermaidWithZoom(graphs, window.eventcatalog?.mermaid);
579
582
  }
580
583
  });
581
584
 
582
- /**
583
- * Renders mermaid diagrams in the page
584
- * @param {HTMLCollectionOf<HTMLElement>} graphs - The collection of mermaid graph elements
585
- */
586
- async function renderDiagrams(graphs: any) {
587
- const { default: mermaid } = await import('mermaid');
588
-
589
- // @ts-ignore
590
- if (window.eventcatalog.mermaid) {
591
- const { icons } = await import('@iconify-json/logos');
592
- // @ts-ignore
593
- const { iconPacks = [], enableSupportForElkLayout = false } = window.eventcatalog.mermaid ?? {};
594
-
595
- if (iconPacks.length > 0) {
596
- const iconPacksToRegister = iconPacks.map((name: any) => {
597
- return {
598
- name,
599
- icons,
600
- };
601
- });
602
-
603
- mermaid.registerIconPacks(iconPacksToRegister);
604
- }
605
-
606
- if (enableSupportForElkLayout) {
607
- // @ts-ignore
608
- const { default: elkLayouts } = await import('@mermaid-js/layout-elk/dist/mermaid-layout-elk.core.mjs');
609
- mermaid.registerLayoutLoaders(elkLayouts);
610
- }
611
- }
612
-
613
- // Detect current theme from data-theme attribute
614
- const isDarkMode = document.documentElement.getAttribute('data-theme') === 'dark';
615
- const currentTheme = isDarkMode ? 'dark' : 'default';
616
-
617
- // Custom theme variables for better readability in dark mode
618
- const darkThemeVariables = {
619
- // Sequence diagram - improve text contrast
620
- signalColor: '#f0f6fc',
621
- signalTextColor: '#f0f6fc',
622
- actorTextColor: '#0d1117',
623
- actorBkg: '#f0f6fc',
624
- actorBorder: '#484f58',
625
- actorLineColor: '#6b7280',
626
- // General text colors
627
- primaryTextColor: '#f0f6fc',
628
- secondaryTextColor: '#c9d1d9',
629
- tertiaryTextColor: '#f0f6fc',
630
- // Line colors
631
- lineColor: '#6b7280',
632
- };
633
-
634
- mermaid.initialize({
635
- // fontSize: 2,
636
- flowchart: {
637
- curve: 'linear',
638
- rankSpacing: 0,
639
- nodeSpacing: 0,
640
- },
641
- startOnLoad: false,
642
- fontFamily: 'var(--sans-font)',
643
- // @ts-ignore This works, but TS expects a enum for some reason
644
- theme: currentTheme,
645
- themeVariables: isDarkMode ? darkThemeVariables : undefined,
646
- architecture: {
647
- useMaxWidth: true,
648
- },
649
- });
650
-
651
- for (const graph of graphs) {
652
- const content = graph.getAttribute('data-content');
653
- if (!content) continue;
654
- let svg = document.createElement('svg');
655
- const id = (svg.id = 'mermaid-' + Math.round(Math.random() * 100000));
656
- graph.appendChild(svg);
657
- mermaid.render(id, content).then((result) => {
658
- graph.innerHTML = result.svg;
659
- });
660
- }
661
- }
662
-
585
+ // Initial render
663
586
  const graphs = document.getElementsByClassName('mermaid');
664
- if (document.getElementsByClassName('mermaid').length > 0) {
665
- renderDiagrams(graphs);
587
+ if (graphs.length > 0) {
588
+ renderMermaidWithZoom(graphs, window.eventcatalog?.mermaid);
666
589
  }
667
590
 
668
- // Make renderDiagrams available globally for accordion component
669
- window.renderDiagrams = renderDiagrams;
591
+ // Make available globally for accordion component
592
+ window.renderDiagrams = (graphs: HTMLCollectionOf<Element>) => {
593
+ renderMermaidWithZoom(graphs, window.eventcatalog?.mermaid);
594
+ };
670
595
  </script>
671
596
 
672
597
  <script>
673
- import('pako').then(({ deflate }: any) => {
674
- document.addEventListener('astro:page-load', () => {
675
- const blocks = document.getElementsByClassName('plantuml');
676
- if (blocks.length > 0) {
677
- renderPlantUML(blocks, deflate);
678
- }
679
- });
680
-
681
- function renderPlantUML(blocks: any, deflate: any) {
682
- for (const block of blocks) {
683
- const content = block.getAttribute('data-content');
684
- if (!content) continue;
685
-
686
- const encoded = encodePlantUML(content, deflate);
687
- const img = document.createElement('img');
688
- img.src = `https://www.plantuml.com/plantuml/svg/~1${encoded}`;
689
- img.alt = 'PlantUML diagram';
690
- img.loading = 'lazy';
691
- block.innerHTML = '';
692
- // Add class to the img
693
- img.classList.add('mx-auto');
694
- block.appendChild(img);
695
- }
696
- }
598
+ import { renderPlantUMLWithZoom } from '@utils/mermaid-zoom';
697
599
 
698
- function encodePlantUML(text: any, deflate: any) {
699
- const utf8encoded = new TextEncoder().encode(text);
700
- const compressed = deflate(utf8encoded, { level: 9 });
701
- return encode64(compressed);
600
+ function initPlantUML() {
601
+ const blocks = document.getElementsByClassName('plantuml');
602
+ if (blocks.length > 0) {
603
+ renderPlantUMLWithZoom(blocks);
702
604
  }
605
+ }
703
606
 
704
- const encode64 = (data: any) => {
705
- const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_';
706
- let str = '';
707
- let i = 0;
708
- while (i < data.length) {
709
- let b1 = data[i++];
710
- let b2 = i < data.length ? data[i++] : 0;
711
- let b3 = i < data.length ? data[i++] : 0;
712
-
713
- let c1 = b1 >> 2;
714
- let c2 = ((b1 & 0x3) << 4) | (b2 >> 4);
715
- let c3 = ((b2 & 0xf) << 2) | (b3 >> 6);
716
- let c4 = b3 & 0x3f;
717
-
718
- str += chars[c1] + chars[c2] + chars[c3] + chars[c4];
719
- }
720
- return str;
721
- };
607
+ // Run on initial load and page transitions
608
+ initPlantUML();
609
+ document.addEventListener('astro:page-load', initPlantUML);
722
610
 
723
- const graphs = document.getElementsByClassName('plantuml');
724
- if (document.getElementsByClassName('plantuml').length > 0) {
725
- renderPlantUML(graphs, deflate);
726
- }
727
-
728
- window.renderPlantUML = (graphs: any) => {
729
- renderPlantUML(graphs, deflate);
730
- };
731
- });
611
+ // Make available globally for accordion component
612
+ window.renderPlantUML = (blocks: HTMLCollectionOf<Element>) => {
613
+ renderPlantUMLWithZoom(blocks);
614
+ };
732
615
  </script>
733
616
  <script>
734
617
  // @ts-nocheck
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Type declarations for MCP server dependencies
3
+ * These are used by the enterprise MCP server feature
4
+ */
5
+
6
+ declare module 'hono' {
7
+ export interface Context {
8
+ req: {
9
+ raw: Request;
10
+ };
11
+ json: (data: unknown, status?: number) => Response;
12
+ }
13
+
14
+ export class Hono {
15
+ constructor();
16
+ basePath(path: string): Hono;
17
+ get(path: string, handler: (c: Context) => Response | Promise<Response>): void;
18
+ post(path: string, handler: (c: Context) => Response | Promise<Response>): void;
19
+ fetch(request: Request): Promise<Response>;
20
+ }
21
+ }
22
+
23
+ declare module '@modelcontextprotocol/sdk/server/mcp.js' {
24
+ import { z } from 'zod';
25
+
26
+ export interface ToolConfig {
27
+ description: string;
28
+ inputSchema: z.ZodType<any>;
29
+ }
30
+
31
+ export interface ToolResult {
32
+ content: Array<{ type: 'text'; text: string }>;
33
+ isError?: boolean;
34
+ }
35
+
36
+ export interface ResourceConfig {
37
+ description: string;
38
+ mimeType: string;
39
+ }
40
+
41
+ export interface ResourceResult {
42
+ contents: Array<{
43
+ uri: string;
44
+ text: string;
45
+ mimeType: string;
46
+ }>;
47
+ }
48
+
49
+ export class McpServer {
50
+ constructor(config: { name: string; version: string });
51
+ registerTool(name: string, config: ToolConfig, handler: (params: any) => Promise<ToolResult>): void;
52
+ registerResource(name: string, uri: string, config: ResourceConfig, handler: (uri: URL) => Promise<ResourceResult>): void;
53
+ connect(transport: any): Promise<void>;
54
+ }
55
+ }
56
+
57
+ declare module '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js' {
58
+ export interface WebStandardStreamableHTTPServerTransportConfig {
59
+ sessionIdGenerator: undefined;
60
+ }
61
+
62
+ export class WebStandardStreamableHTTPServerTransport {
63
+ constructor(config: WebStandardStreamableHTTPServerTransportConfig);
64
+ handleRequest(request: Request): Promise<Response>;
65
+ }
66
+ }