-
Notifications
You must be signed in to change notification settings - Fork 69
Add opal-frontend package #8170
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "parser": "@typescript-eslint/parser", | ||
| "parserOptions": { | ||
| "projectService": true | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| dist/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| .env | ||
| tsconfig.tsbuildinfo |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <!doctype html> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width" /> | ||
| <title>Opal Frontend</title> | ||
| </head> | ||
| <body> | ||
| <script type="module" src="/src/index.ts"></script> | ||
| <opal-main></opal-main> | ||
| </body> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| { | ||
| "name": "@breadboard-ai/opal-frontend", | ||
| "private": true, | ||
| "version": "0.1.0", | ||
| "description": "The Opal Frontend", | ||
| "main": "./dist/src/index.js", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/src/index.d.ts", | ||
| "default": "./dist/src/index.js" | ||
| }, | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "types": "dist/src/index.d.ts", | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "wireit", | ||
| "build:vite": "wireit", | ||
| "build:tsc": "wireit", | ||
| "dev": "vite", | ||
| "lint": "wireit" | ||
| }, | ||
| "wireit": { | ||
| "build": { | ||
| "dependencies": [ | ||
| "build:vite" | ||
| ] | ||
| }, | ||
| "typescript-files-and-deps": { | ||
| "files": [ | ||
| "src/**/*.ts", | ||
| "tsconfig.json", | ||
| "vite.config.ts", | ||
| "../../core/tsconfig/base.json", | ||
| "package.json" | ||
| ] | ||
| }, | ||
| "check:tsc": { | ||
| "command": "tsc -b --pretty --noEmit", | ||
| "env": { | ||
| "FORCE_COLOR": "1" | ||
| }, | ||
| "dependencies": [ | ||
| "typescript-files-and-deps" | ||
| ], | ||
| "files": [], | ||
| "output": [] | ||
| }, | ||
| "build:tsc": { | ||
| "command": "tsc -b --pretty", | ||
| "env": { | ||
| "FORCE_COLOR": "1" | ||
| }, | ||
| "dependencies": [ | ||
| "typescript-files-and-deps" | ||
| ], | ||
| "files": [ | ||
| "dist/tsc/" | ||
| ] | ||
| }, | ||
| "build:vite": { | ||
| "command": "vite build", | ||
| "env": { | ||
| "FORCE_COLOR": "1" | ||
| }, | ||
| "dependencies": [ | ||
| "check:tsc" | ||
| ], | ||
| "files": [ | ||
| "vite.config.ts", | ||
| "*.html" | ||
| ], | ||
| "output": [ | ||
| "dist/" | ||
| ] | ||
| }, | ||
| "lint": { | ||
| "command": "eslint --max-warnings=0 'src/**/*.ts'", | ||
| "files": [ | ||
| "src/**/*.ts", | ||
| "../../eslint.config.js" | ||
| ], | ||
| "output": [] | ||
| } | ||
| }, | ||
| "repository": { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: more idiomatic to have the package metadata the the top |
||
| "directory": "packages/opal-frontend", | ||
| "type": "git", | ||
| "url": "git+https://github.com/breadboard-ai/breadboard.git" | ||
| }, | ||
| "files": [ | ||
| "dist/", | ||
| "index.html" | ||
| ], | ||
| "keywords": [], | ||
| "author": "Google Labs Team", | ||
| "license": "Apache-2.0", | ||
| "bugs": { | ||
| "url": "https://github.com/breadboard-ai/breadboard/issues" | ||
| }, | ||
| "homepage": "https://github.com/breadboard-ai/breadboard/tree/main/packages/opal-frontend#readme", | ||
| "devDependencies": { | ||
| "@google-labs/tsconfig": "^0.0.2", | ||
| "@types/node": "^22.0.0", | ||
| "typescript": "^5.8.3", | ||
| "vite": "^7.2.6", | ||
| "wireit": "^0.15.0-pre.2" | ||
| }, | ||
| "dependencies": { | ||
| "@lit-labs/signals": "^0.1.3", | ||
| "lit": "^3.3.2", | ||
| "signal-polyfill": "^0.2.2", | ||
| "signal-utils": "^0.21.1" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2026 |
||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { signal } from "signal-utils"; | ||
| import { SignalWatcher } from "@lit-labs/signals"; | ||
| import { LitElement, html, css } from "lit"; | ||
| import { customElement } from "lit/decorators.js"; | ||
|
|
||
| /** | ||
| * @constructor | ||
| * @extends {LitElement} | ||
| */ | ||
| const SignalWatcherBase = SignalWatcher(LitElement); | ||
|
|
||
| @customElement("opal-main") | ||
| /** @extends {LitElement} */ | ||
| class OpalMain extends SignalWatcherBase { | ||
| static override styles = css` | ||
| :host { | ||
| display: block; | ||
| font-family: system-ui, sans-serif; | ||
| padding: 2rem; | ||
| } | ||
| `; | ||
|
|
||
| @signal accessor time = new Date().toLocaleTimeString(); | ||
|
|
||
| override connectedCallback() { | ||
| super.connectedCallback(); | ||
| setInterval(() => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is just a test, but the timer needs to get closed on disconnectedCallback |
||
| this.time = new Date().toLocaleTimeString(); | ||
| }, 1000); | ||
| } | ||
|
|
||
| override render() { | ||
| return html`<h1>Hello, Signals! The time is ${this.time}</h1>`; | ||
| } | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| "opal-main": OpalMain; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2022", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's bump to 2024 for target and lib? |
||
| "module": "nodenext", | ||
| "lib": ["ES2023", "DOM", "DOM.Iterable"], | ||
| "skipLibCheck": true, | ||
| "useDefineForClassFields": false, | ||
| "outDir": "dist/tsc", | ||
| "moduleResolution": "nodenext", | ||
| "resolveJsonModule": true, | ||
| "isolatedModules": true, | ||
| "strict": true, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may want to make sure we have all the same strictness checks enabled externally as internal. |
||
| "noUnusedLocals": true, | ||
| "noUnusedParameters": true, | ||
| "noFallthroughCasesInSwitch": true, | ||
| "types": ["vite/client", "node"] | ||
| }, | ||
| "include": ["src/**/*.ts"], | ||
| "extends": "@google-labs/tsconfig/base.json" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Google LLC | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2026 |
||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { defineConfig, type UserConfig } from "vite"; | ||
|
|
||
| export default defineConfig((): UserConfig => { | ||
| return { | ||
| optimizeDeps: { esbuildOptions: { target: "esnext" } }, | ||
| build: { | ||
| target: "esnext", | ||
| outDir: "dist/client", | ||
| }, | ||
| resolve: { | ||
| dedupe: ["lit"], | ||
| }, | ||
| server: { | ||
| port: 3333, | ||
| watch: { | ||
| ignored: ["**/.wireit/**"], | ||
| }, | ||
| }, | ||
| }; | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has no "output", so it can never get cached by wireit