|
| 1 | +# CLAUDE.md — SplashScreen |
| 2 | + |
| 3 | +This is the splash screen web application for Autodesk Dynamo, published as the npm package `@dynamods/splash-screen`. It renders inside a WebView2 host (Dynamo) and displays loading progress before handing off to the main application UI. |
| 4 | + |
| 5 | +## Essential Commands |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install --force # Install dependencies (--force required due to peer dep conflicts) |
| 9 | +npm run start # Dev server on localhost:8080 |
| 10 | +npm run build # Dev build → /dist/build/ |
| 11 | +npm run bundle # Production build (minified) → /dist/ |
| 12 | +npm run production # Full release build: bundle + copy files + licenses |
| 13 | + |
| 14 | +npm run lint:check # Check ESLint issues |
| 15 | +npm run lint:fix # Auto-fix ESLint issues |
| 16 | + |
| 17 | +npm run test:unit # Jest unit tests (App, Toast) |
| 18 | +npm run test:e2e # Playwright e2e tests (Chromium) |
| 19 | + |
| 20 | +npm run version:patch # Bump patch version (triggers license generation via postversion hook) |
| 21 | +npm run generate_license # Regenerate third-party license files manually |
| 22 | +``` |
| 23 | + |
| 24 | +## Architecture |
| 25 | + |
| 26 | +### Two-phase UI |
| 27 | +- **Dynamic phase** — loading screen with progress bar and version display (`Dynamic.js`) |
| 28 | +- **Static phase** — post-load UI with Launch, Sign In, and Import Settings buttons (`Static.js`) |
| 29 | +- `App.js` orchestrates both phases; `Toast.js` handles notifications |
| 30 | + |
| 31 | +### WebView2 host communication |
| 32 | +The app runs embedded in Dynamo via Chrome WebView2. It communicates with the host via: |
| 33 | +```js |
| 34 | +chrome.webview.hostObjects.scriptObject.MethodName(args) |
| 35 | +``` |
| 36 | +Host methods: `SignIn`, `SignOut`, `LaunchDynamo`, `ImportSettings`, `ResetSettings`. |
| 37 | + |
| 38 | +When running outside WebView2 (plain browser), the app enters **debug mode** (append `?debug` to URL). Debug mode skips the loading phase and mocks all host callbacks. |
| 39 | + |
| 40 | +### Window API |
| 41 | +`App.js` exposes methods on `window` so the Dynamo host can drive the React component: |
| 42 | +- `window.setLoadingText(text)` — update loading message |
| 43 | +- `window.setProgress(value)` — update progress bar (0–100) |
| 44 | +- `window.loadStaticPage()` — transition from Dynamic → Static phase |
| 45 | + |
| 46 | +### State management |
| 47 | +Class-based components with `setState()`. No Redux or Context. Parent (`App`) passes state down to children via props. |
| 48 | + |
| 49 | +## Key Conventions |
| 50 | + |
| 51 | +- **Class-based components** — this codebase uses `class Foo extends React.Component`, not function components or hooks |
| 52 | +- **2-space indentation**, **single quotes**, **semicolons required** (enforced by ESLint) |
| 53 | +- CSS files co-located with their component (e.g. `App.js` + `App.css`) |
| 54 | +- All images are base64-encoded and centralized in `encodedImages.js` |
| 55 | +- PropTypes and defaultProps used in `Static.js` for i18n label support |
| 56 | + |
| 57 | +## Project Structure |
| 58 | + |
| 59 | +``` |
| 60 | +src/ |
| 61 | + index.js Entry point (ReactDOM.createRoot) |
| 62 | + App.js / App.css Root component, orchestrates phases, exposes window API |
| 63 | + Dynamic.js/.css Loading phase UI |
| 64 | + Static.js/.css Post-load phase UI |
| 65 | + Toast.js/.css Toast notification system |
| 66 | + encodedImages.js All images as base64 strings |
| 67 | +
|
| 68 | +tests/ |
| 69 | + App.test.js Jest unit tests for App |
| 70 | + Toast.test.js Jest unit tests for Toast |
| 71 | + e2e.test.js Playwright e2e tests |
| 72 | + __mocks__/ Mocks for CSS/file imports in Jest |
| 73 | +
|
| 74 | +public/ |
| 75 | + index.html HTML template for webpack |
| 76 | +
|
| 77 | +dist/ Build output (gitignored) |
| 78 | +license_output/ Generated third-party license files |
| 79 | +.github/workflows/ CI: build.yml (PRs), npm-publish.yml (releases) |
| 80 | +``` |
| 81 | + |
| 82 | +## Testing Notes |
| 83 | + |
| 84 | +- Unit tests use `@testing-library/react` with Jest; CSS and file imports are mocked via `__mocks__/` |
| 85 | +- E2E tests use Playwright (Chromium only); run `npx playwright install chromium` if missing |
| 86 | +- Coverage is reported in LCOV format; CI posts a summary to PRs via `zgosalvez/github-actions-report-lcov` |
| 87 | + |
| 88 | +## CI/CD |
| 89 | + |
| 90 | +- **build.yml**: Runs on every push/PR to `master` — installs, builds, unit tests, e2e tests, coverage report |
| 91 | +- **npm-publish.yml**: Runs on GitHub Release creation — builds production bundle, publishes `/dist` to npm as `@dynamods/splash-screen` (public) |
| 92 | + |
| 93 | +## Release Workflow |
| 94 | + |
| 95 | +1. `npm run version:patch` (or `minor`/`major`) — bumps version, regenerates licenses |
| 96 | +2. Push the version commit + tag |
| 97 | +3. Create a GitHub Release → triggers npm publish automatically |
0 commit comments