Skip to content

Commit

Permalink
Merge pull request #1408 from analogjs/beta
Browse files Browse the repository at this point in the history
chore: release 1.9.0
  • Loading branch information
brandonroberts authored Oct 14, 2024
2 parents 4f032b1 + b589b3e commit 6e3786e
Show file tree
Hide file tree
Showing 111 changed files with 1,894 additions and 987 deletions.
19 changes: 19 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,25 @@
"contributions": [
"code"
]
},
{
"login": "redfox-mx",
"name": "Diego Jesús",
"avatar_url": "https://avatars.githubusercontent.com/u/20145660?v=4",
"profile": "https://github.com/redfox-mx",
"contributions": [
"code",
"infra"
]
},
{
"login": "Rockerturner",
"name": "Rockerturner",
"avatar_url": "https://avatars.githubusercontent.com/u/25847930?v=4",
"profile": "https://github.com/Rockerturner",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
4 changes: 2 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ pnpm-lock.yaml
/.nx/cache
.angular
*.analog

/.nx/workspace-data
/.nx/workspace-data
/packages/create-analog/template-*
96 changes: 96 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,99 @@
# [1.9.0-beta.16](https://github.com/analogjs/analog/compare/v1.9.0-beta.15...v1.9.0-beta.16) (2024-10-14)

### Bug Fixes

- **vite-plugin-nitro:** use ssrBuildDir if provided for SSR entry point ([#1407](https://github.com/analogjs/analog/issues/1407)) ([132f70d](https://github.com/analogjs/analog/commit/132f70d600d4925598da3b96440d23a942f91f1d))

# [1.9.0-beta.15](https://github.com/analogjs/analog/compare/v1.9.0-beta.14...v1.9.0-beta.15) (2024-10-13)

### Bug Fixes

- **nx-plugin:** added missing import for 'join' in tailwind template ([#1405](https://github.com/analogjs/analog/issues/1405)) ([02d7898](https://github.com/analogjs/analog/commit/02d7898fba018c0f92016199900f33dd48141e0d))

# [1.9.0-beta.14](https://github.com/analogjs/analog/compare/v1.9.0-beta.13...v1.9.0-beta.14) (2024-10-13)

### Bug Fixes

- **platform:** load content highlighter on first content request ([#1402](https://github.com/analogjs/analog/issues/1402)) ([ead2aba](https://github.com/analogjs/analog/commit/ead2ababbd31c55af5713f584aa9201b146c91e9))

# [1.9.0-beta.13](https://github.com/analogjs/analog/compare/v1.9.0-beta.12...v1.9.0-beta.13) (2024-10-13)

### Bug Fixes

- **vite-plugin-nitro:** inline and apply api prefix to endpoints ([#1401](https://github.com/analogjs/analog/issues/1401)) ([94bfc2e](https://github.com/analogjs/analog/commit/94bfc2e00c3ee1bb9076a9718b2d16496a1ef142))

# [1.9.0-beta.12](https://github.com/analogjs/analog/compare/v1.9.0-beta.11...v1.9.0-beta.12) (2024-10-12)

### Bug Fixes

- **vite-plugin-angular:** use esbuild to postprocess sourcemaps during testing ([#1399](https://github.com/analogjs/analog/issues/1399)) ([bdf8cee](https://github.com/analogjs/analog/commit/bdf8cee28b201871886ead48127600fd00f4af37))

# [1.9.0-beta.11](https://github.com/analogjs/analog/compare/v1.9.0-beta.10...v1.9.0-beta.11) (2024-10-11)

### Bug Fixes

- **router:** expose inject function for page endpoint URL ([#1397](https://github.com/analogjs/analog/issues/1397)) ([42486cc](https://github.com/analogjs/analog/commit/42486ccd5c520bd5258b9d93c372566424001d02))

# [1.9.0-beta.10](https://github.com/analogjs/analog/compare/v1.9.0-beta.9...v1.9.0-beta.10) (2024-10-10)

### Bug Fixes

- **create-analog:** add minimal template to semver during release ([0e030cc](https://github.com/analogjs/analog/commit/0e030cca96f60b42d0c6feaf5c997cc54ce0a5da))

# [1.9.0-beta.9](https://github.com/analogjs/analog/compare/v1.9.0-beta.8...v1.9.0-beta.9) (2024-10-10)

### Bug Fixes

- **router:** retrieve initial server page load from transfer state ([#1396](https://github.com/analogjs/analog/issues/1396)) ([f9f1d9b](https://github.com/analogjs/analog/commit/f9f1d9b28e6b156ff91e657fa916dabe6bdcf4d9))

# [1.9.0-beta.8](https://github.com/analogjs/analog/compare/v1.9.0-beta.7...v1.9.0-beta.8) (2024-10-10)

### Bug Fixes

- **platform:** add better cache invalidation for file changes ([#1394](https://github.com/analogjs/analog/issues/1394)) ([c38900d](https://github.com/analogjs/analog/commit/c38900da1b8ffa89e5e5e826840095755e820791))

# [1.9.0-beta.7](https://github.com/analogjs/analog/compare/v1.9.0-beta.6...v1.9.0-beta.7) (2024-10-08)

### Bug Fixes

- **vite-plugin-angular:** support outputFromObservable ([#1392](https://github.com/analogjs/analog/issues/1392)) ([8c255ec](https://github.com/analogjs/analog/commit/8c255ece5594e1f7a16b8a15cfa4619bf55770e8))

# [1.9.0-beta.6](https://github.com/analogjs/analog/compare/v1.9.0-beta.5...v1.9.0-beta.6) (2024-10-07)

### Features

- **create-analog:** update app generators and templates to use TypeScript for Tailwind config ([#1387](https://github.com/analogjs/analog/issues/1387)) ([586adae](https://github.com/analogjs/analog/commit/586adae9b4ef0770dcb5d14344cd5943645b38a9))

# [1.9.0-beta.5](https://github.com/analogjs/analog/compare/v1.9.0-beta.4...v1.9.0-beta.5) (2024-10-06)

### Bug Fixes

- **create-analog:** add Analog SFCs to Tailwind config ([#1388](https://github.com/analogjs/analog/issues/1388)) ([c051f05](https://github.com/analogjs/analog/commit/c051f056974b2336e209ea6941c42822c808ab81))

# [1.9.0-beta.4](https://github.com/analogjs/analog/compare/v1.9.0-beta.3...v1.9.0-beta.4) (2024-10-03)

### Features

- **router:** introduce server support for form actions ([#1346](https://github.com/analogjs/analog/issues/1346)) ([1d15109](https://github.com/analogjs/analog/commit/1d15109b40935319d7fdf32af751acb1f6effaf7))

# [1.9.0-beta.3](https://github.com/analogjs/analog/compare/v1.9.0-beta.2...v1.9.0-beta.3) (2024-10-02)

### Bug Fixes

- **vite-plugin-nitro:** add option use proxy for API requests instead of custom middleware ([#1378](https://github.com/analogjs/analog/issues/1378)) ([f72087f](https://github.com/analogjs/analog/commit/f72087f43bd09fb51407f3e699d7265d05b96e44))

# [1.9.0-beta.2](https://github.com/analogjs/analog/compare/v1.9.0-beta.1...v1.9.0-beta.2) (2024-10-01)

### Features

- **create-analog:** optionally generate new projects with Analog SFCs ([#1375](https://github.com/analogjs/analog/issues/1375)) ([9b46f08](https://github.com/analogjs/analog/commit/9b46f081d1fd20e2c4e99ca6eee0e09237568704))

# [1.9.0-beta.1](https://github.com/analogjs/analog/compare/v1.8.2...v1.9.0-beta.1) (2024-09-30)

### Features

- **create-analog:** set project title based on project name; sort deps ([#1374](https://github.com/analogjs/analog/issues/1374)) ([775eeab](https://github.com/analogjs/analog/commit/775eeab1ce3812e43070e7b18fa22adfa8e02ff3))

## [1.8.2](https://github.com/analogjs/analog/compare/v1.8.1...v1.8.2) (2024-09-30)

### Bug Fixes
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- prettier-ignore-start -->
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-122-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-124-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
<!-- prettier-ignore-end -->

Expand Down Expand Up @@ -263,6 +263,8 @@ Thanks goes to these wonderful people for contributing to Analog ([emoji key](ht
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ilyassFouih"><img src="https://avatars.githubusercontent.com/u/33469478?v=4?s=100" width="100px;" alt="Ilyass "/><br /><sub><b>Ilyass </b></sub></a><br /><a href="https://github.com/analogjs/analog/commits?author=ilyassFouih" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://bradbodine.dev"><img src="https://avatars.githubusercontent.com/u/2924609?v=4?s=100" width="100px;" alt="Brad Bodine"/><br /><sub><b>Brad Bodine</b></sub></a><br /><a href="https://github.com/analogjs/analog/commits?author=bbodine1" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kilesh-mhzn"><img src="https://avatars.githubusercontent.com/u/78723506?v=4?s=100" width="100px;" alt="Kilesh Maharjan"/><br /><sub><b>Kilesh Maharjan</b></sub></a><br /><a href="https://github.com/analogjs/analog/commits?author=kilesh-mhzn" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/redfox-mx"><img src="https://avatars.githubusercontent.com/u/20145660?v=4?s=100" width="100px;" alt="Diego Jesús"/><br /><sub><b>Diego Jesús</b></sub></a><br /><a href="https://github.com/analogjs/analog/commits?author=redfox-mx" title="Code">💻</a> <a href="#infra-redfox-mx" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Rockerturner"><img src="https://avatars.githubusercontent.com/u/25847930?v=4?s=100" width="100px;" alt="Rockerturner"/><br /><sub><b>Rockerturner</b></sub></a><br /><a href="https://github.com/analogjs/analog/commits?author=Rockerturner" title="Code">💻</a></td>
</tr>
</tbody>
</table>
Expand Down
96 changes: 96 additions & 0 deletions apps/analog-app/src/app/pages/form-action.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { Directive, inject, input, output } from '@angular/core';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { injectRouteEndpointURL } from '@analogjs/router';

@Directive({
selector: 'form[action],form[method]',
host: {
'(submit)': `submitted($event)`,
},
standalone: true,
})
export class FormAction {
action = input<string>('');
onSuccess = output<unknown>();
onError = output<unknown>();
state = output<
'submitting' | 'error' | 'redirect' | 'success' | 'navigate'
>();
private router = inject(Router);
private route = inject(ActivatedRoute);
private path = this._getPath();

submitted($event: { target: HTMLFormElement } & Event) {
$event.preventDefault();

this.state.emit('submitting');
const body = new FormData($event.target);

if ($event.target.method.toUpperCase() === 'GET') {
this._handleGet(body, this.path);
} else {
this._handlePost(body, this.path, $event);
}
}

private _handleGet(body: FormData, path: string) {
const params: Params = {};
body.forEach((formVal, formKey) => (params[formKey] = formVal));

this.state.emit('navigate');
this.router.navigate([path], {
queryParams: params,
onSameUrlNavigation: 'reload',
});
}

private _handlePost(
body: FormData,
path: string,
$event: { target: HTMLFormElement } & Event
) {
fetch(path, {
method: $event.target.method,
body,
})
.then((res) => {
if (res.ok) {
if (res.redirected) {
const redirectUrl = new URL(res.url).pathname;
this.state.emit('redirect');
this.router.navigate([redirectUrl]);
} else if (res.headers.get('Content-type') === 'application/json') {
res.json().then((result) => {
this.onSuccess.emit(result);
this.state.emit('success');
});
} else {
res.text().then((result) => {
this.onSuccess.emit(result);
this.state.emit('success');
});
}
} else {
if (res.headers.get('X-Analog-Errors')) {
res.json().then((errors: unknown) => {
this.onError.emit(errors);
this.state.emit('error');
});
} else {
this.state.emit('error');
}
}
})
.catch((_) => {
this.state.emit('error');
});
}

private _getPath() {
if (this.route) {
return injectRouteEndpointURL(this.route.snapshot).pathname;
}

return `/api/_analog/pages${window.location.pathname}`;
}
}
52 changes: 52 additions & 0 deletions apps/analog-app/src/app/pages/newsletter.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Component, signal } from '@angular/core';

import { FormAction } from './form-action.directive';

type FormErrors =
| {
email?: string;
}
| undefined;

@Component({
selector: 'app-newsletter-page',
standalone: true,
imports: [FormAction],
template: `
<h3>Newsletter Signup</h3>
@if (!signedUp()) {
<form
method="post"
(onSuccess)="onSuccess()"
(onError)="onError($any($event))"
(onStateChange)="errors.set(undefined)"
>
<div>
<label for="email"> Email </label>
<input type="email" name="email" />
</div>
<button class="button" type="submit">Submit</button>
</form>
@if( errors()?.email ) {
<p>{{ errors()?.email }}</p>
} } @else {
<div>Thanks for signing up!</div>
}
`,
})
export default class NewsletterComponent {
signedUp = signal(false);
errors = signal<FormErrors>(undefined);

onSuccess() {
this.signedUp.set(true);
}

onError(result?: FormErrors) {
this.errors.set(result);
console.log({ result });
}
}
30 changes: 30 additions & 0 deletions apps/analog-app/src/app/pages/newsletter.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
type PageServerAction,
redirect,
json,
fail,
} from '@analogjs/router/server/actions';
import { readFormData } from 'h3';

export function load() {
return {
loaded: true,
};
}

export async function action({ event }: PageServerAction) {
const body = await readFormData(event);
const email = body.get('email') as string;

if (!email) {
return fail(422, { email: 'Email is required' });
}

if (email.length < 10) {
return redirect('/');
}

console.log({ email: body.get('email') });

return json({ type: 'success' });
}
32 changes: 32 additions & 0 deletions apps/analog-app/src/app/pages/search.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Component, computed } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { injectLoad } from '@analogjs/router';

import { FormAction } from './form-action.directive';
import type { load } from './search.server';

@Component({
selector: 'app-search-page',
standalone: true,
imports: [FormAction],
template: `
<h3>Search</h3>
<form method="get">
<div>
<label for="search"> Search </label>
<input type="text" name="search" [value]="searchTerm()" />
</div>
<button class="button" type="submit">Submit</button>
</form>
@if(searchTerm()) {
<p>Search Term: {{ searchTerm() }}</p>
}
`,
})
export default class NewsletterComponent {
loader = toSignal(injectLoad<typeof load>(), { requireSync: true });
searchTerm = computed(() => this.loader().searchTerm);
}
12 changes: 12 additions & 0 deletions apps/analog-app/src/app/pages/search.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { PageServerLoad } from '@analogjs/router';
import { getQuery } from 'h3';

export async function load({ event }: PageServerLoad) {
const query = getQuery(event);
console.log('loaded search', query['search']);

return {
loaded: true,
searchTerm: `${query['search']}`,
};
}
2 changes: 2 additions & 0 deletions apps/docs-app/docs/contributors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ Andres is a software engineer for HeroDevs, Angular and Firebase GDE.
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ilyassFouih"><img src="https://avatars.githubusercontent.com/u/33469478?v=4?s=100" width="100px;" alt="Ilyass "/><br /><sub><b>Ilyass </b></sub></a><br /><a href="https://github.com/analogjs/analog/commits?author=ilyassFouih" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://bradbodine.dev"><img src="https://avatars.githubusercontent.com/u/2924609?v=4?s=100" width="100px;" alt="Brad Bodine"/><br /><sub><b>Brad Bodine</b></sub></a><br /><a href="https://github.com/analogjs/analog/commits?author=bbodine1" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kilesh-mhzn"><img src="https://avatars.githubusercontent.com/u/78723506?v=4?s=100" width="100px;" alt="Kilesh Maharjan"/><br /><sub><b>Kilesh Maharjan</b></sub></a><br /><a href="https://github.com/analogjs/analog/commits?author=kilesh-mhzn" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/redfox-mx"><img src="https://avatars.githubusercontent.com/u/20145660?v=4?s=100" width="100px;" alt="Diego Jesús"/><br /><sub><b>Diego Jesús</b></sub></a><br /><a href="https://github.com/analogjs/analog/commits?author=redfox-mx" title="Code">💻</a> <a href="#infra-redfox-mx" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Rockerturner"><img src="https://avatars.githubusercontent.com/u/25847930?v=4?s=100" width="100px;" alt="Rockerturner"/><br /><sub><b>Rockerturner</b></sub></a><br /><a href="https://github.com/analogjs/analog/commits?author=Rockerturner" title="Code">💻</a></td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const load = async ({
## Injecting the Data

Accessing the data fetched on the server can be done using the `injectLoad` function provided by `@analogjs/router`.
The `load` function is resolved using Angular route resolvers, so setting `requireSync: false` and `initialValue: {}`
offers no advantage, as load is fetched before the component is instantiated.

```ts
// src/app/pages/index.page.ts
Expand Down
Loading

0 comments on commit 6e3786e

Please sign in to comment.