How infi-pc/locatorjs works
Main Components
• Browser Extension: Under apps/extension, this part includes multiple pages (Background, Content script, Popup UI, etc.), configuration files (manifest.v2.json, manifest.v3.json), and tooling (Webpack, Babel, ESLint, Tailwind). It is the entry point into the system from the user’s browser.
• Demo/Example Applications: There are several apps built with different technologies (e.g., apps/next-react-server-components, various apps/vite-* projects, and apps/web). These serve both as integrations and test beds for LocatorJS in different environments.
• Testing Infrastructure: The apps/playwright folder indicates end-to-end testing setups using Playwright. This component simulates user interactions and ensures the extension and libraries work as expected.
• Core and Supporting Libraries: The packages directory includes several modules:
• packages/runtime: Contains the core runtime logic, adapters for different frameworks (React, Svelte, Vue), components (UI elements for outlines, banner, tooltips, etc.), and helper functions.
• packages/babel-jsx: Provides Babel integrations for JSX transformations.
• packages/locatorjs: Likely holds integration logic (though it might be embedded in other modules) for actually locating components.
• Other packages such as packages/react-devtools-hook, packages/dev-config, packages/shared, and packages/ui contribute to configuration, shared logic, and UI widget components.
• Development and Workspace Configuration: Tools like turbo.json, lerna.json, pnpm-workspace.yaml, and various .vscode, .github configurations indicate CI/CD pipelines, workspace management, and contribution guidelines.
Relationships and Interactions
• The Browser Extension communicates with the webpage via injected content/hook scripts – for example, the “Hook” files and runtime adapters.
• The extension’s Popup and Background pages interact with the core LocatorJS libraries from packages/runtime and others. This is facilitated by scripted data flows (use of Webpack, Babel configurations, etc.).
• The demo applications (Vite, Next.js, etc.) serve as examples and testing grounds; they integrate LocatorJS as a library. Their UI components, when inspected, invoke LocatorJS’s runtime which then communicates back to the extension.
• Testing with Playwright orchestrates scenarios across these apps and the extension to simulate user actions.
• The “babel-jsx” package likely transforms or compiles JSX code during build time, working together with “react-devtools-hook” and “runtime” adapters to capture UI component information.
Important Architectural Patterns and Design Principles
• Modular / Repository Pattern: The monorepo is organized into discrete “apps” and “packages,” delineating consumer examples from core library functionality.
• Adapter Pattern: The runtime package’s adapters (for React, Svelte, Vue, etc.) abstract the specifics of each framework, allowing LocatorJS to remain framework-agnostic.
• Separation of Concerns: There’s a clear split between front-end/demo applications, the browser extension (UI and background processes), and the underlying libraries which handle business logic and component inspection.
• Testing & Development Workflow: With dedicated directories for Playwright tests and CI/CD workflows (under .github/workflows), the project emphasizes automated testing and continuous integration.
Relevant Technologies, Frameworks, and Tools
• Frameworks/Libraries: React, SolidJS, Preact, Svelte, Vue.
• Build Tools: Webpack (for the extension), Vite (for various sample projects), Babel (with specific JSX transformations).
• Testing: Playwright for end-to-end tests.
• Linting and Formatting: ESLint, Prettier, and other configuration presets housed in packages/dev-config.
• CI/CD: GitHub Actions workflows provided under .github/workflows.
• Package Management: pnpm, lerna, and turbo (turbo.json).
Elements
• Annotations: Include notes about technologies or protocols used (for example, “Webpack build-time bundling” for the extension, “Vite bundler” for demos).