Skip to content

[chore] refactor typescript directory #2087

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

Merged
merged 3 commits into from
Jul 14, 2025
Merged

Conversation

sxlijin
Copy link
Collaborator

@sxlijin sxlijin commented Jun 30, 2025

Major TypeScript Directory Refactor

Overview

This PR introduces a major refactor of the TypeScript codebase. The primary goal is to modernize, modularize, and clarify the structure of our TypeScript projects, making it easier to maintain, extend, and onboard new contributors. This is a breaking, high-impact change that affects nearly every TypeScript-related file and package.


What Changed

1. Monorepo Structure: All TypeScript Packages Moved to /packages

  • Before: Many packages and apps (e.g., fiddle-frontend, vscode-ext, playground-common, common, etc.) were scattered directly under typescript/ or in ad-hoc subfolders.
  • After: All reusable packages and libraries now live under typescript/packages/. This includes:
    • baml-schema-wasm-node
    • baml-schema-wasm-web
    • codemirror-lang-baml
    • common
    • fiddle-proxy
    • language-server
    • nextjs-plugin
    • playground-common
    • ui (new, see below)

2. Apps Consolidated Under /apps

  • Before: Apps like the playground and VSCode extension were in their own folders (fiddle-frontend, vscode-ext/packages/vscode, etc.).
  • After: All TypeScript-based apps now live under typescript/apps/:
    • fiddle-web-app (formerly fiddle-frontend)
    • vscode-ext (formerly vscode-ext/packages/vscode and web-panel)

3. New ui Package

  • All shared UI components (buttons, dialogs, forms, etc.) are now in typescript/packages/ui/.
  • This package is intended to be the single source of truth for UI primitives across all apps.

4. Shared Code and Utilities

  • The common and playground-common packages have been moved and refactored for clarity.
  • Shared logic, types, and utilities are now easier to find and import.

5. Configuration and Tooling

  • All build, lint, and workspace configuration files have been updated to reflect the new structure.
  • New workspace tools and base configs are in typescript/workspace-tools/.

6. Removed/Deleted Files

  • Legacy, duplicate, or now-unnecessary files and configs have been deleted.
  • Old package.jsons, tsconfigs, and other configs from the previous structure are gone.

Why This Matters

  • Consistency: All TypeScript code now follows a clear, industry-standard monorepo structure.
  • Maintainability: Easier to update dependencies, share code, and onboard new contributors.
  • Scalability: Adding new packages or apps is now straightforward.
  • Clarity: No more confusion about where a package, component, or utility lives.

Impact for Contributors

  • Imports: You may need to update import paths in your branches or local changes.
  • Docs: Please refer to the new folder structure when writing documentation or onboarding guides.
  • Build/Test: All scripts and CI should now reference the new locations. If you have custom scripts, update their paths.
  • VSCode/IDE: You may need to reload your workspace or update your project settings.

Migration Guide

  • Apps: Look in typescript/apps/ for all runnable applications.
  • Packages: Look in typescript/packages/ for all libraries, shared code, and utilities.
  • UI Components: Use @boundaryml/ui for all shared UI needs.
  • Workspace Tools: See typescript/workspace-tools/ for base configs and scripts.

Summary Table

Old Location New Location
typescript/fiddle-frontend/ typescript/apps/fiddle-web-app/
typescript/vscode-ext/packages/vscode/ typescript/apps/vscode-ext/
typescript/vscode-ext/packages/web-panel/ typescript/apps/vscode-ext/src/web-panel/
typescript/playground-common/ typescript/packages/playground-common/
typescript/common/ typescript/packages/common/
typescript/fiddle-proxy/ typescript/packages/fiddle-proxy/
typescript/nextjs-plugin/ typescript/packages/nextjs-plugin/
typescript/codemirror-lang-baml/ typescript/packages/codemirror-lang-baml/
typescript/baml-schema-wasm-node/ typescript/packages/baml-schema-wasm-node/
typescript/baml-schema-wasm-web/ typescript/packages/baml-schema-wasm-web/
typescript/language-server/ typescript/packages/language-server/

Final Notes

  • This is a breaking change for anyone with open PRs or local branches. Please rebase and update paths as needed.
  • If you find any missing or misplaced files, please open a follow-up PR or issue.

Copy link

vercel bot commented Jun 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
baml ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 14, 2025 11:20am

useEffect(() => {
console.log('adding event listener');
const fn = (
event: MessageEvent<

Check warning

Code scanning / CodeQL

Missing origin verification in `postMessage` handler Medium

Postmessage handler has no origin check.

Copilot Autofix

AI 22 days ago

To fix the issue, we need to verify the origin of the incoming MessageEvent before processing the message. This involves:

  1. Defining a list of trusted origins (e.g., https://www.example.com) that are allowed to send messages.
  2. Adding a conditional check to ensure the event.origin matches one of the trusted origins.
  3. If the origin is not trusted, the handler should ignore the message or log a warning.

The fix will be applied to the fn function defined on line 189. The trusted origins can be defined as a constant array or a configuration variable.


Suggested changeset 1
typescript/packages/playground-common/src/baml_wasm_web/EventListener.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/typescript/packages/playground-common/src/baml_wasm_web/EventListener.tsx b/typescript/packages/playground-common/src/baml_wasm_web/EventListener.tsx
--- a/typescript/packages/playground-common/src/baml_wasm_web/EventListener.tsx
+++ b/typescript/packages/playground-common/src/baml_wasm_web/EventListener.tsx
@@ -188,2 +188,3 @@
     console.log('adding event listener');
+    const trustedOrigins = ['https://www.example.com', 'https://trusted-origin.com'];
     const fn = (
@@ -253,2 +254,6 @@
     ) => {
+      if (!trustedOrigins.includes(event.origin)) {
+        console.warn(`Untrusted origin: ${event.origin}`);
+        return;
+      }
       const { command, content } = event.data;
EOF
@@ -188,2 +188,3 @@
console.log('adding event listener');
const trustedOrigins = ['https://www.example.com', 'https://trusted-origin.com'];
const fn = (
@@ -253,2 +254,6 @@
) => {
if (!trustedOrigins.includes(event.origin)) {
console.warn(`Untrusted origin: ${event.origin}`);
return;
}
const { command, content } = event.data;
Copilot is powered by AI and may make mistakes. Always verify output.
@seawatts seawatts force-pushed the seawatts/update-playground2 branch from e372c19 to 58a06e7 Compare June 30, 2025 23:22
@seawatts seawatts marked this pull request as ready for review July 1, 2025 05:03
@seawatts seawatts changed the title squash everything [chore] refactor typescript directory Jul 1, 2025
@seawatts seawatts self-assigned this Jul 1, 2025
Copy link
Contributor

ellipsis-dev bot commented Jul 1, 2025

⚠️ This PR is too big for Ellipsis, but support for larger PRs is coming soon. If you want us to prioritize this feature, let us know at [email protected]


Generated with ❤️ by ellipsis.dev

fix: issue with manturin

codegen

fix: release

fix: wasm build

fix genreate

fix python

final
@seawatts seawatts enabled auto-merge July 14, 2025 11:09
@seawatts seawatts added this pull request to the merge queue Jul 14, 2025
Merged via the queue into canary with commit 6b7c178 Jul 14, 2025
19 checks passed
@seawatts seawatts deleted the seawatts/update-playground2 branch July 14, 2025 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants