Skip to content

feat: Add new simulator embed build configurations and files, remove#993

Open
harikrishna-au wants to merge 5 commits intoCircuitVerse:mainfrom
harikrishna-au:main
Open

feat: Add new simulator embed build configurations and files, remove#993
harikrishna-au wants to merge 5 commits intoCircuitVerse:mainfrom
harikrishna-au:main

Conversation

@harikrishna-au
Copy link
Contributor

@harikrishna-au harikrishna-au commented Mar 3, 2026

feat: separate simulator-embed-{version}.js as a distinct Vite build output

Fixes #990


Describe the changes you have made in this PR

Right now every embed user downloads the full simulator bundle including all the editor tools they can never use. This PR fixes that by adding a separate embed entry point.

What I did:

  • Added v0/embed.html and v1/embed.html as dedicated embed entry points
  • Added v0/src/embedMain.ts and v1/src/embedMain.ts — same as main.ts but without bootstrap, tutorials styles, and font preloading since embed view doesn't need them
  • Updated vite.config.ts to build two outputs per version using Rollup's multi-entry input:
    simulator-v0.js        ← full editor (unchanged)
    simulator-embed-v0.js  ← new embed-only bundle
    
  • Deleted src/simulator/src/embed.js — it was 132 lines, fully commented out, dead code left over from the jQuery migration

Screenshots of the UI changes (If any)

No visual changes. The embed view looks and works the same, just loaded from a leaner bundle.


Code Understanding and AI Usage

Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?

  • No, I wrote all the code myself
  • Yes, I used AI assistance (continue below)

If you used AI assistance:

  • I have reviewed every single line of the AI-generated code
  • I can explain the purpose and logic of each function/component I added
  • I have tested edge cases and understand how the code handles them
  • I have modified the AI output to follow this project's coding standards and conventions

Explain your implementation approach:

The idea is straightforward — Rollup supports multiple entry points in a single build. By naming the inputs simulator and simulator-embed and using [name]-${version}.js as the output template, both files get the right names without touching multi-build.js.

embedMain.ts is just a trimmed down main.ts. I removed bootstrap, tutorials styles, and font preloading since none of them are used in embed.vue. The router only has the embed route because embed.vue calls useRoute() to read the project ID and query params like theme, clock_time, and fullscreen.

The deleted embed.js was safe to remove — every single line was commented out. embedListeners.js handles all the actual embed interaction logic and is untouched.


Checklist before requesting a review

  • I have added proper PR title and linked to the issue
  • I have performed a self-review of my code
  • I can explain the purpose of every function, class, and logic block I added
  • I understand why my changes work and have tested them thoroughly
  • I have considered potential edge cases and how my code handles them
  • If it is a core feature, I have added thorough tests
  • My code follows the project's style guidelines and conventions

Summary by CodeRabbit

  • New Features

    • Added a standalone embed page for the simulator with routing, localization, and UI shell to mount embedded projects.
  • Bug Fixes

    • Improved session handling: sign-out on 401 responses and re-check on tab visibility.
    • Safer redo operation: aborts and restores state if redo data fails to load.
  • Chores

    • Build updated to include the new embed entry point.
    • Auth store now clears stored token on init/sign-out.

…an old embed script, and document GSoC issues for debug panel, session desync, and embed build.
@netlify
Copy link

netlify bot commented Mar 3, 2026

Deploy Preview for circuitverse ready!

Name Link
🔨 Latest commit f962966
🔍 Latest deploy log https://app.netlify.com/projects/circuitverse/deploys/69a6c42bb60d1c000834f4d0
😎 Deploy Preview https://deploy-preview-993--circuitverse.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 53 (🟢 up 7 from production)
Accessibility: 68 (🟢 up 2 from production)
Best Practices: 92 (no change from production)
SEO: 77 (🔴 down 5 from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 3, 2026

Walkthrough

Adds dedicated embed entry points and HTML pages for the simulator (new src/embedMain.ts and versioned embed.html files), removes the legacy src/simulator/src/embed.js, and updates Vite config to emit separate build entries (simulator and simulator-embed) with template-based output names. Also includes smaller changes: visibility handling in src/pages/simulatorHandler.vue, redo error handling in src/simulator/src/data/redo.ts, and auth token clearing/removal in src/store/authStore.ts.

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title is incomplete and truncated, ending mid-sentence. It mentions 'Add new simulator embed build configurations and files, remove' but doesn't specify what is being removed, making it unclear and unfinished. Complete the title to clearly describe what is being removed. Example: 'feat: Add simulator embed build configuration and remove dead embed.js code'
Out of Scope Changes check ⚠️ Warning Several changes appear out-of-scope: visibility change listener in simulatorHandler.vue, auth token localStorage cleanup in authStore.ts, and redo error handling in redo.ts are unrelated to the embed build configuration objective. Move visibility change, auth token cleanup, and redo error handling changes to separate PRs focused on those specific features. Keep this PR focused on embed build separation.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR successfully implements the key objective from #990: produces separate simulator-embed-{version}.js bundles alongside simulator-{version}.js via Vite config changes, new dedicated embed entry points, and removes dead embed.js code.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
v1/src/embedMain.ts (1)

14-16: Router history may need to respect the configured base path.

The createWebHistory() is called without a base path argument, but vite.config.ts sets base: /simulatorvue/${version}/. In production, the router may not correctly resolve routes relative to this base.

♻️ Consider passing the base path to createWebHistory
 const embedRouter = createRouter({
-  history: createWebHistory(),
+  history: createWebHistory(import.meta.env.BASE_URL),
   routes: [
src/embedMain.ts (2)

14-16: Router history may need to respect the configured base path.

Same issue as the v1 version - createWebHistory() should receive the base URL for correct route resolution in production.

♻️ Consider passing the base path to createWebHistory
 const embedRouter = createRouter({
-  history: createWebHistory(),
+  history: createWebHistory(import.meta.env.BASE_URL),
   routes: [

1-37: Consider extracting shared embed bootstrap logic.

The src/embedMain.ts and v1/src/embedMain.ts files are identical. While maintaining both v0 and v1 folders is intentional per project conventions, consider whether a shared utility could reduce duplication for the router configuration and app setup.


ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b2e81a and cc561d4.

📒 Files selected for processing (6)
  • src/embedMain.ts
  • src/simulator/src/embed.js
  • v0/embed.html
  • v1/embed.html
  • v1/src/embedMain.ts
  • vite.config.ts
💤 Files with no reviewable changes (1)
  • src/simulator/src/embed.js

…e documentation for embed build, session desync, and debug panel.
…SoC issue documentation for embed build, session desync, and debug panel."

This reverts commit b305491.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc561d4 and b305491.

📒 Files selected for processing (3)
  • src/pages/simulatorHandler.vue
  • src/simulator/src/data/redo.ts
  • src/store/authStore.ts

@harikrishna-au
Copy link
Contributor Author

harikrishna-au commented Mar 3, 2026

@Nihal4777 review PR

@naman79820
Copy link
Contributor

Hey @harikrishna-au if i am not wrong then you are trying to implement Gsoc project 4 "Separate simulator-.js and simulator-embed-.js as separate output files." part right?

@naman79820
Copy link
Contributor

naman79820 commented Mar 3, 2026

If you are trying to create an MVP so that mentors can review it and provide guidance, then please add MVP at the top of the title and feel free to mention them on specific slack channel. Thanks :))

@naman79820 naman79820 added invalid This doesn't seem right hold labels Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: produce simulator-embed-{version}.js as a separate Vite build output

2 participants