@industry-theme/principal-view-panels 0.1.8 → 0.1.9

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":"PrincipalViewGraphPanel.d.ts","sourceRoot":"","sources":["../../src/panels/PrincipalViewGraphPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAyC/E;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAyuBjE,CAAC"}
1
+ {"version":3,"file":"PrincipalViewGraphPanel.d.ts","sourceRoot":"","sources":["../../src/panels/PrincipalViewGraphPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAyC/E;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA+xBjE,CAAC"}
@@ -53450,6 +53450,7 @@ const PrincipalViewGraphPanel = ({
53450
53450
  eventsRef.current = events;
53451
53451
  const selectedConfigIdRef = useRef(null);
53452
53452
  selectedConfigIdRef.current = state.selectedConfigId;
53453
+ const skipNextFileChangeRef = useRef(false);
53453
53454
  const loadConfiguration = useCallback(async (configId) => {
53454
53455
  var _a2;
53455
53456
  setState((prev) => ({ ...prev, loading: true, error: null }));
@@ -53569,7 +53570,7 @@ const PrincipalViewGraphPanel = ({
53569
53570
  setState((prev) => ({ ...prev, hasUnsavedChanges: false }));
53570
53571
  }, [loadConfiguration]);
53571
53572
  const saveAllChanges = useCallback(async () => {
53572
- var _a2;
53573
+ var _a2, _b2;
53573
53574
  if (!state.canvas) return;
53574
53575
  const pendingChanges = (_a2 = graphRef.current) == null ? void 0 : _a2.getPendingChanges();
53575
53576
  const hasGraphChanges = (pendingChanges == null ? void 0 : pendingChanges.hasChanges) ?? false;
@@ -53594,8 +53595,14 @@ const PrincipalViewGraphPanel = ({
53594
53595
  const jsonContent = JSON.stringify(updatedCanvas, null, 2);
53595
53596
  const fullPath = `${repositoryPath}/${selectedConfig.path}`;
53596
53597
  await writeFile(fullPath, jsonContent);
53597
- await loadConfiguration(selectedConfigIdRef.current || void 0);
53598
- setState((prev) => ({ ...prev, isSaving: false, hasUnsavedChanges: false }));
53598
+ skipNextFileChangeRef.current = true;
53599
+ setState((prev) => ({
53600
+ ...prev,
53601
+ canvas: updatedCanvas,
53602
+ isSaving: false,
53603
+ hasUnsavedChanges: false
53604
+ }));
53605
+ (_b2 = graphRef.current) == null ? void 0 : _b2.resetEditState();
53599
53606
  } catch (error) {
53600
53607
  console.error("[PrincipalView] Error saving changes:", error);
53601
53608
  setState((prev) => ({
@@ -53604,7 +53611,7 @@ const PrincipalViewGraphPanel = ({
53604
53611
  error: `Failed to save: ${error.message}`
53605
53612
  }));
53606
53613
  }
53607
- }, [state.canvas, state.availableConfigs, loadConfiguration]);
53614
+ }, [state.canvas, state.availableConfigs]);
53608
53615
  const toggleLayoutConfig = useCallback(() => {
53609
53616
  setState((prev) => ({ ...prev, showLayoutConfig: !prev.showLayoutConfig }));
53610
53617
  }, []);
@@ -53650,11 +53657,39 @@ const PrincipalViewGraphPanel = ({
53650
53657
  if (prevData === null || fileTreeLoading) {
53651
53658
  return;
53652
53659
  }
53660
+ if (skipNextFileChangeRef.current) {
53661
+ skipNextFileChangeRef.current = false;
53662
+ return;
53663
+ }
53653
53664
  if (prevData !== fileTreeData && fileTreeData !== null) {
53654
- console.log("[PrincipalViewGraph] File tree data changed, reloading...");
53655
- loadConfiguration();
53665
+ const selectedConfig = state.availableConfigs.find((c2) => c2.id === selectedConfigIdRef.current);
53666
+ if (!selectedConfig) {
53667
+ const newConfigs = ConfigLoader.findConfigs(fileTreeData.allFiles || []);
53668
+ if (newConfigs.length > 0) {
53669
+ console.log("[PrincipalViewGraph] New configs available, reloading...");
53670
+ loadConfiguration();
53671
+ }
53672
+ return;
53673
+ }
53674
+ const prevFiles = prevData.allFiles || [];
53675
+ const newFiles = fileTreeData.allFiles || [];
53676
+ const prevConfigFile = prevFiles.find((f) => (f.path || f.relativePath) === selectedConfig.path);
53677
+ const newConfigFile = newFiles.find((f) => (f.path || f.relativePath) === selectedConfig.path);
53678
+ const libraryPath = ConfigLoader.findLibraryPath(newFiles);
53679
+ const prevLibraryFile = libraryPath ? prevFiles.find((f) => (f.path || f.relativePath) === libraryPath) : null;
53680
+ const newLibraryFile = libraryPath ? newFiles.find((f) => (f.path || f.relativePath) === libraryPath) : null;
53681
+ const configChanged = prevConfigFile !== newConfigFile;
53682
+ const libraryChanged = prevLibraryFile !== newLibraryFile;
53683
+ if (configChanged || libraryChanged) {
53684
+ console.log("[PrincipalViewGraph] Current config or library changed, reloading...", {
53685
+ configChanged,
53686
+ libraryChanged,
53687
+ configPath: selectedConfig.path
53688
+ });
53689
+ loadConfiguration();
53690
+ }
53656
53691
  }
53657
- }, [fileTreeData, fileTreeLoading, loadConfiguration]);
53692
+ }, [fileTreeData, fileTreeLoading, loadConfiguration, state.availableConfigs]);
53658
53693
  useEffect(() => {
53659
53694
  const unsubscribe = eventsRef.current.on("data:refresh", () => {
53660
53695
  loadConfiguration();