Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions examples/ts-angular-chat/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single
ij_typescript_use_double_quotes = false

[*.md]
max_line_length = off
trim_trailing_whitespace = false
43 changes: 43 additions & 0 deletions examples/ts-angular-chat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings
__screenshots__/

# System files
.DS_Store
Thumbs.db
5 changes: 5 additions & 0 deletions examples/ts-angular-chat/.postcssrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": {
"@tailwindcss/postcss": {}
}
}
4 changes: 4 additions & 0 deletions examples/ts-angular-chat/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
"recommendations": ["angular.ng-template"]
}
20 changes: 20 additions & 0 deletions examples/ts-angular-chat/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: start",
"url": "http://localhost:4200/"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: test",
"url": "http://localhost:9876/debug.html"
}
]
}
42 changes: 42 additions & 0 deletions examples/ts-angular-chat/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "Changes detected"
},
"endsPattern": {
"regexp": "bundle generation (complete|failed)"
}
}
}
},
{
"type": "npm",
"script": "test",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "Changes detected"
},
"endsPattern": {
"regexp": "bundle generation (complete|failed)"
}
}
}
}
]
}
59 changes: 59 additions & 0 deletions examples/ts-angular-chat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# TsAngularChat

This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 21.0.5.

## Development server

To start a local development server, run:

```bash
ng serve
```

Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.

## Code scaffolding

Angular CLI includes powerful code scaffolding tools. To generate a new component, run:

```bash
ng generate component component-name
```

For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:

```bash
ng generate --help
```

## Building

To build the project run:

```bash
ng build
```

This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.

## Running unit tests

To execute unit tests with the [Vitest](https://vitest.dev/) test runner, use the following command:

```bash
ng test
```

## Running end-to-end tests

For end-to-end (e2e) testing, run:

```bash
ng e2e
```

Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.

## Additional Resources

For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
73 changes: 73 additions & 0 deletions examples/ts-angular-chat/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"cli": {
"packageManager": "npm"
},
"newProjectRoot": "projects",
"projects": {
"ts-angular-chat": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular/build:application",
"options": {
"browser": "src/main.ts",
"tsConfig": "tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"src/styles.css"
]
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kB",
"maximumError": "8kB"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular/build:dev-server",
"configurations": {
"production": {
"buildTarget": "ts-angular-chat:build:production"
},
"development": {
"buildTarget": "ts-angular-chat:build:development"
}
},
"defaultConfiguration": "development"
},
"test": {
"builder": "@angular/build:unit-test"
}
}
}
}
}
48 changes: 48 additions & 0 deletions examples/ts-angular-chat/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "ts-angular-chat",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"prettier": {
"printWidth": 100,
"singleQuote": true,
"overrides": [
{
"files": "*.html",
"options": {
"parser": "angular"
}
}
]
},
"private": true,
"packageManager": "npm@11.3.0",
"dependencies": {
"@angular/common": "^21.0.0",
"@angular/compiler": "^21.0.0",
"@angular/core": "^21.0.0",
"@angular/forms": "^21.0.0",
"@angular/platform-browser": "^21.0.0",
"@angular/router": "^21.0.0",
"@tanstack/ai": "workspace:^",
"@tanstack/ai-angular": "workspace:^",
"rxjs": "~7.8.0",
"tslib": "^2.3.0"
},
"devDependencies": {
"@angular/build": "^21.0.5",
"@angular/cli": "^21.0.5",
"@angular/compiler-cli": "^21.0.0",
"@tailwindcss/postcss": "^4.1.12",
"jsdom": "^27.1.0",
"postcss": "^8.5.3",
"tailwindcss": "^4.1.12",
"typescript": "~5.9.2",
"vitest": "^4.0.8"
}
}
Binary file added examples/ts-angular-chat/public/favicon.ico
Binary file not shown.
11 changes: 11 additions & 0 deletions examples/ts-angular-chat/src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ApplicationConfig, provideBrowserGlobalErrorListeners } from '@angular/core';
import { provideRouter } from '@angular/router';

import { routes } from './app.routes';

export const appConfig: ApplicationConfig = {
providers: [
provideBrowserGlobalErrorListeners(),
provideRouter(routes)
]
};
66 changes: 66 additions & 0 deletions examples/ts-angular-chat/src/app/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<div class="min-h-screen bg-slate-950 text-slate-100">
<div class="mx-auto flex min-h-screen max-w-3xl flex-col px-4 py-10">
<header class="mb-6">
<h1 class="text-xl font-semibold tracking-tight">TanStack AI + Angular</h1>
<p class="mt-1 text-sm text-slate-400">Simple demo using @tanstack/ai-angular</p>
</header>

<main class="flex-1 space-y-4">
@if (chat.messages().length === 0) {
<div class="rounded-xl border border-slate-800 bg-slate-900/40 p-4 text-sm text-slate-300">
Type a message to start.
</div>
} @for (m of chat.messages(); track m.id) {
<div class="space-y-2">
<div class="text-xs uppercase tracking-wide text-slate-500">{{ m.role }}</div>

<div
class="max-w-2xl rounded-xl border border-slate-800 bg-slate-900/40 p-3"
[class.ml-auto]="m.role === 'user'"
>
@for (p of textParts(m); track $index) {
<div class="whitespace-pre-wrap text-sm">{{ p.content }}</div>
}
</div>
</div>
}
</main>

<footer class="mt-6">
<form
class="flex items-center gap-2 rounded-2xl border border-slate-800 bg-slate-900/60 p-2"
(submit)="$event.preventDefault(); send()"
>
<input
class="h-11 w-full rounded-xl bg-slate-950/40 px-3 text-sm text-slate-100 outline-none placeholder:text-slate-500"
placeholder="Ask something..."
[value]="prompt()"
(input)="prompt.set($event.target.value)"
[disabled]="chat.isLoading()"
/>
<button
type="submit"
class="h-11 shrink-0 rounded-xl bg-emerald-500 px-4 text-sm font-medium text-slate-950 disabled:opacity-50"
[disabled]="chat.isLoading()"
>
Send
</button>
</form>

<div class="mt-3 flex items-center justify-between text-xs text-slate-400">
<div>
@if (chat.isLoading()) {
<span>Streaming...</span>
} @if (chat.error()) {
<span>Error: {{ chat.error()?.message }}</span>
}
</div>

<div class="flex items-center gap-3">
<button type="button" class="hover:text-slate-200" (click)="chat.stop()">Stop</button>
<button type="button" class="hover:text-slate-200" (click)="chat.clear()">Clear</button>
</div>
</div>
</footer>
</div>
</div>
Loading