Skip to content

Commit a6f04f9

Browse files
Fix: Resolve CI build failures for Crane Visualizer panel
This commit addresses several issues that caused the CI build to fail: 1. **Corrected Module Import Paths:** * I changed import paths in `src/crane_visualizer_panel.tsx` for `settings_utils.ts` and `constants.ts` from `../` to `./` to correctly resolve modules within the `src` directory. 2. **Addressed React UMD Global Errors:** * I added `import React from 'react';` to `src/crane_visualizer_panel.tsx` (merging with existing named React imports). This ensures `React` is in scope for JSX compilation, as required by the `"jsx": "react"` setting in `tsconfig.json`. 3. **Fixed `unsubscribe` TypeError and Logic:** * I corrected the argument passed to `context.unsubscribe` in the topic subscription `useEffect` hook in `src/crane_visualizer_panel.tsx`. It now correctly passes an array of topic strings (`[topic]`) instead of an array of objects (`[{ topic }]`), aligning with the expected signature for unsubscribing by subscription ID. This also fixes a potential memory leak where previous topics were not being unsubscribed upon topic change. These changes should resolve the CI build errors and ensure the panel builds successfully.
1 parent 597f129 commit a6f04f9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/crane_visualizer_panel.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback, useLayoutEffect, useState, useEffect, FC, memo } from "react";
1+
import React, { useCallback, useLayoutEffect, useState, useEffect, FC, memo } from "react";
22
import {
33
PanelExtensionContext,
44
SettingsTree,
@@ -13,9 +13,9 @@ import ReactDOM from "react-dom";
1313
import { StrictMode } from "react";
1414
import { usePanZoom } from "./hooks/usePanZoom";
1515
import { usePanelConfig } from "./hooks/usePanelConfig"; // Hook import
16-
import { PanelConfig, NamespaceConfig } from "../settings_utils"; // Type imports
17-
import { createNamespaceFields, handleSettingsAction } from "../settings_utils"; // Import utils
18-
import { DEFAULT_TOPIC, DEFAULT_VIEWBOX_ASPECT_RATIO } from "../constants"; // Import constants
16+
import { PanelConfig, NamespaceConfig } from "./settings_utils"; // Type imports
17+
import { createNamespaceFields, handleSettingsAction } from "./settings_utils"; // Import utils
18+
import { DEFAULT_TOPIC, DEFAULT_VIEWBOX_ASPECT_RATIO } from "./constants"; // Import constants
1919

2020
interface SvgPrimitiveArray {
2121
layer: string; // "parent/child1/child2"のような階層パス
@@ -81,7 +81,8 @@ const CraneVisualizer: React.FC<{ context: PanelExtensionContext }> = ({ context
8181
context.subscribe([{ topic }]);
8282
return () => {
8383
// Unsubscribe when the topic changes or the panel is unmounted
84-
context.unsubscribe([{ topic }]);
84+
// context.unsubscribe expects an array of subscriptionIds (topic strings)
85+
context.unsubscribe([topic]);
8586
};
8687
}, [topic, context]); // Added context as a dependency, as context.subscribe/unsubscribe are used.
8788

0 commit comments

Comments
 (0)