Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor : typescript integration : src/simulator/src/data.ts #435

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 0 additions & 58 deletions src/simulator/src/data.js

This file was deleted.

87 changes: 87 additions & 0 deletions src/simulator/src/data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import Vue from 'vue';
import { fullView } from './ux';
import { createSubCircuitPrompt } from './subcircuit';
import save from './data/save';
import load from './data/load';
import createSaveAsImgPrompt from './data/saveImage';
import {
clearProject,
newProject,
saveOffline,
openOffline,
recoverProject,
} from './data/project';
import { createNewCircuitScope } from './circuit';
import { createCombinationalAnalysisPrompt } from './combinationalAnalysis';
import { colorThemes } from './themer/themer';
import { showTourGuide } from './tutorials';
import { createVerilogCircuit } from './Verilog2CV';
import { generateVerilog } from './verilog';
import { bitConverterDialog } from './utils';
import keyBinder from '#/components/DialogBox/CustomShortcut.vue';
import ExportProject from '#/components/DialogBox/ExportProject.vue';
import ImportProject from '#/components/DialogBox/ImportProject.vue';

interface LogixFunction {
save: typeof save;
load: typeof load;
createSaveAsImgPrompt: typeof createSaveAsImgPrompt;
clearProject: typeof clearProject;
newProject: typeof newProject;
saveOffline: typeof saveOffline;
createOpenLocalPrompt: typeof openOffline;
recoverProject: typeof recoverProject;
createSubCircuitPrompt: typeof createSubCircuitPrompt;
createCombinationalAnalysisPrompt: typeof createCombinationalAnalysisPrompt;
fullViewOption: typeof fullView;
colorThemes: typeof colorThemes;
showTourGuide: typeof showTourGuideHelper;
newVerilogModule: typeof createVerilogCircuit;
generateVerilog: typeof generateVerilog;
bitconverter: typeof bitConverterDialog;
createNewCircuitScope: typeof createNewCircuitScope;
customShortcut: typeof keyBinder;
ExportProject: typeof ExportProject;
ImportProject: typeof ImportProject;
}

const logixFunction: LogixFunction = {
save,
load,
createSaveAsImgPrompt,
clearProject,
newProject,
saveOffline,
createOpenLocalPrompt: openOffline,
recoverProject,
createSubCircuitPrompt,
createCombinationalAnalysisPrompt,
fullViewOption: fullView,
colorThemes,
showTourGuide: showTourGuideHelper,
newVerilogModule: createVerilogCircuit,
generateVerilog,
bitconverter: bitConverterDialog,
createNewCircuitScope,
customShortcut: keyBinder,
ExportProject,
ImportProject,
};

export default logixFunction;

/**
* Initializes the tour guide with a slight delay to ensure DOM is ready.
* @todo Refactor to use proper lifecycle hooks or event-based initialization
*/
function showTourGuideHelper(): void {
// Consider using Vue's nextTick or proper event listeners
Vue.nextTick(() => {
showTourGuide();
});
}

// Hack to call createNewCircuitScope with keyboard shortcut
function createNewCircuit(): void {
createNewCircuitScope();
}
Comment on lines +84 to +87
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove unnecessary wrapper function.

The createNewCircuit function is a simple wrapper that adds no value and is explicitly marked as a hack. Consider:

  1. Using createNewCircuitScope directly for keyboard shortcuts
  2. If the wrapper is necessary, document why it's needed