@analogjs/astro-angular 0.2.0-beta.2 → 0.2.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -14
- package/migrations/migration.json +4 -0
- package/package.json +24 -12
- package/src/client.d.ts +5 -2
- package/src/client.d.ts.map +1 -0
- package/src/client.js +4 -2
- package/src/client.js.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +19 -2
- package/src/index.js.map +1 -0
- package/src/server.d.ts +5 -2
- package/src/server.d.ts.map +1 -0
- package/src/server.js +4 -2
- package/src/server.js.map +1 -0
- package/src/test-setup.d.ts +0 -1
- package/src/test-setup.js +0 -2
package/README.md
CHANGED
|
@@ -9,14 +9,19 @@ An [Angular](https://angular.io) integration for rendering components in [Astro]
|
|
|
9
9
|
Use the `astro add` command to install the integration
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
|
|
12
|
+
# Using NPM
|
|
13
|
+
npx astro add @analogjs/astro-angular
|
|
14
|
+
# Using Yarn
|
|
15
|
+
yarn astro add @analogjs/astro-angular
|
|
16
|
+
# Using PNPM
|
|
17
|
+
pnpm astro add @analogjs/astro-angular
|
|
13
18
|
```
|
|
14
19
|
|
|
15
20
|
This command:
|
|
16
21
|
|
|
17
22
|
- Installs the `@analogjs/astro-angular` package.
|
|
18
23
|
- Adds the `@analogjs/astro-angular` integration to the `astro.config.mjs` file.
|
|
19
|
-
- Installs the necessary dependencies to render Angular components on the server and client, and common Angular dependencies, such as `@angular/common
|
|
24
|
+
- Installs the necessary dependencies to render Angular components on the server and client, and common Angular dependencies, such as `@angular/common`.
|
|
20
25
|
|
|
21
26
|
### Setting up the TypeScript config
|
|
22
27
|
|
|
@@ -53,7 +58,8 @@ Create a `tsconfig.app.json` in the root of the project.
|
|
|
53
58
|
"enableI18nLegacyMessageIdFormat": false,
|
|
54
59
|
"strictInjectionParameters": true,
|
|
55
60
|
"strictInputAccessModifiers": true,
|
|
56
|
-
"strictTemplates": true
|
|
61
|
+
"strictTemplates": true,
|
|
62
|
+
"allowJs": false
|
|
57
63
|
},
|
|
58
64
|
"files": [],
|
|
59
65
|
"include": ["src/**/*.ts", "src/**/*.tsx"]
|
|
@@ -108,9 +114,7 @@ export default defineConfig({
|
|
|
108
114
|
integrations: [
|
|
109
115
|
angular({
|
|
110
116
|
vite: {
|
|
111
|
-
|
|
112
|
-
workspaceRoot: 'rootDir',
|
|
113
|
-
inlineStylesExtension: 'scss|sass|less'
|
|
117
|
+
inlineStylesExtension: 'scss|sass|less',
|
|
114
118
|
},
|
|
115
119
|
}),
|
|
116
120
|
],
|
|
@@ -174,6 +178,52 @@ import { HelloComponent } from '../components/hello.component';
|
|
|
174
178
|
|
|
175
179
|
Find more information about [Client Directives](https://docs.astro.build/en/reference/directives-reference/#client-directives) in the Astro documentation.
|
|
176
180
|
|
|
181
|
+
## Adding Component Providers
|
|
182
|
+
|
|
183
|
+
Additional providers can be added to a component for static rendering and client hydration.
|
|
184
|
+
|
|
185
|
+
These are `renderProviders` and `clientProviders` respectively. These providers are defined as static arrays on the Component class, and are registered when the component is rendered, and hydrated on the client.
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
import { Component, OnInit, inject } from '@angular/core';
|
|
189
|
+
import { NgFor } from '@angular/common';
|
|
190
|
+
import { provideHttpClient, HttpClient } from '@angular/common/http';
|
|
191
|
+
|
|
192
|
+
interface Todo {
|
|
193
|
+
id: number;
|
|
194
|
+
title: string;
|
|
195
|
+
completed: boolean;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
@Component({
|
|
199
|
+
selector: 'app-todos',
|
|
200
|
+
standalone: true,
|
|
201
|
+
imports: [NgFor],
|
|
202
|
+
template: `
|
|
203
|
+
<h2>Todos</h2>
|
|
204
|
+
|
|
205
|
+
<ul>
|
|
206
|
+
<li *ngFor="let todo of todos">
|
|
207
|
+
{{ todo.title }}
|
|
208
|
+
</li>
|
|
209
|
+
</ul>
|
|
210
|
+
`,
|
|
211
|
+
})
|
|
212
|
+
export class TodosComponent implements OnInit {
|
|
213
|
+
static clientProviders = [provideHttpClient()];
|
|
214
|
+
static renderProviders = [];
|
|
215
|
+
|
|
216
|
+
http = inject(HttpClient);
|
|
217
|
+
todos: Todo[] = [];
|
|
218
|
+
|
|
219
|
+
ngOnInit() {
|
|
220
|
+
this.http
|
|
221
|
+
.get<Todo[]>('https://jsonplaceholder.typicode.com/todos')
|
|
222
|
+
.subscribe((todos) => (this.todos = todos));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
177
227
|
## Using Components in MDX pages
|
|
178
228
|
|
|
179
229
|
To use components with MDX pages, you must install and configure MDX support by following the Astro integration of [@astrojs/mdx](https://docs.astro.build/en/guides/integrations-guide/mdx/). Your `astro.config.mjs` should now include the `@astrojs/mdx` integration.
|
|
@@ -192,10 +242,10 @@ Create an `.mdx` file inside the `src/pages` directory and add the Angular compo
|
|
|
192
242
|
|
|
193
243
|
```md
|
|
194
244
|
---
|
|
195
|
-
layout:
|
|
196
|
-
title:
|
|
197
|
-
description:
|
|
198
|
-
pubDate:
|
|
245
|
+
layout: '../../layouts/BlogPost.astro'
|
|
246
|
+
title: 'Using Angular in MDX'
|
|
247
|
+
description: 'Lorem ipsum dolor sit amet'
|
|
248
|
+
pubDate: 'Sep 22 2022'
|
|
199
249
|
---
|
|
200
250
|
|
|
201
251
|
import { HelloComponent } from "../../components/hello.component.ts";
|
|
@@ -208,10 +258,10 @@ To hydrate the component on the client, use one of the Astro [client directives]
|
|
|
208
258
|
|
|
209
259
|
```md
|
|
210
260
|
---
|
|
211
|
-
layout:
|
|
212
|
-
title:
|
|
213
|
-
description:
|
|
214
|
-
pubDate:
|
|
261
|
+
layout: '../../layouts/BlogPost.astro'
|
|
262
|
+
title: 'Using Angular in MDX'
|
|
263
|
+
description: 'Lorem ipsum dolor sit amet'
|
|
264
|
+
pubDate: 'Sep 22 2022'
|
|
215
265
|
---
|
|
216
266
|
|
|
217
267
|
import { HelloComponent } from "../../components/hello.component.ts";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@analogjs/astro-angular",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.20",
|
|
4
4
|
"description": "Use Angular components within Astro",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Brandon Roberts <robertsbt@gmail.com>",
|
|
@@ -27,23 +27,35 @@
|
|
|
27
27
|
"url": "https://github.com/analogjs/analog.git"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@analogjs/vite-plugin-angular": "^0.2.0-beta.
|
|
30
|
+
"@analogjs/vite-plugin-angular": "^0.2.0-beta.20"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@angular-devkit/build-angular": "^16.0.0
|
|
34
|
-
"@angular/animations": "^16.0.0
|
|
35
|
-
"@angular/common": "^16.0.0
|
|
36
|
-
"@angular/compiler-cli": "^16.0.0
|
|
37
|
-
"@angular/compiler": "^16.0.0
|
|
38
|
-
"@angular/core": "^16.0.0
|
|
39
|
-
"@angular/language-service": "^16.0.0
|
|
40
|
-
"@angular/platform-browser": "^16.0.0
|
|
41
|
-
"@angular/platform-browser-dynamic": "^16.0.0
|
|
42
|
-
"@angular/platform-server": "^16.0.0
|
|
33
|
+
"@angular-devkit/build-angular": "^16.0.0",
|
|
34
|
+
"@angular/animations": "^16.0.0",
|
|
35
|
+
"@angular/common": "^16.0.0",
|
|
36
|
+
"@angular/compiler-cli": "^16.0.0",
|
|
37
|
+
"@angular/compiler": "^16.0.0",
|
|
38
|
+
"@angular/core": "^16.0.0",
|
|
39
|
+
"@angular/language-service": "^16.0.0",
|
|
40
|
+
"@angular/platform-browser": "^16.0.0",
|
|
41
|
+
"@angular/platform-browser-dynamic": "^16.0.0",
|
|
42
|
+
"@angular/platform-server": "^16.0.0",
|
|
43
43
|
"rxjs": "^7.5.6",
|
|
44
44
|
"zone.js": "^0.13.0",
|
|
45
45
|
"tslib": "^2.4.0"
|
|
46
46
|
},
|
|
47
|
+
"ng-update": {
|
|
48
|
+
"packageGroup": [
|
|
49
|
+
"@analogjs/astro-angular",
|
|
50
|
+
"@analogjs/platform",
|
|
51
|
+
"@analogjs/content",
|
|
52
|
+
"@analogjs/router",
|
|
53
|
+
"@analogjs/trpc",
|
|
54
|
+
"@analogjs/vite-plugin-angular",
|
|
55
|
+
"@analogjs/vite-plugin-nitro"
|
|
56
|
+
],
|
|
57
|
+
"migrations": "./migrations/migration.json"
|
|
58
|
+
},
|
|
47
59
|
"main": "./src/index.js",
|
|
48
60
|
"types": "./src/index.d.ts"
|
|
49
61
|
}
|
package/src/client.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import 'zone.js/dist/zone.js';
|
|
2
|
-
import { ɵComponentType as ComponentType } from '@angular/core';
|
|
3
|
-
declare const _default: (element: HTMLElement) => (Component: ComponentType<unknown
|
|
2
|
+
import { EnvironmentProviders, Provider, ɵComponentType as ComponentType } from '@angular/core';
|
|
3
|
+
declare const _default: (element: HTMLElement) => (Component: ComponentType<unknown> & {
|
|
4
|
+
clientProviders?: (Provider | EnvironmentProviders)[];
|
|
5
|
+
}, props?: Record<string, unknown>, _childHTML?: unknown) => void;
|
|
4
6
|
export default _default;
|
|
7
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../packages/astro-angular/src/client.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EACL,oBAAoB,EACpB,QAAQ,EAER,cAAc,IAAI,aAAa,EAChC,MAAM,eAAe,CAAC;kCAIE,WAAW,iBAErB,cAAc,OAAO,CAAC,GAAG;IAClC,eAAe,CAAC,EAAE,CAAC,QAAQ,GAAG,oBAAoB,CAAC,EAAE,CAAC;CACvD,UACO,OAAO,MAAM,EAAE,OAAO,CAAC,eAClB,OAAO;AANxB,wBAoCE"}
|
package/src/client.js
CHANGED
|
@@ -4,7 +4,9 @@ import { NgZone, createComponent } from '@angular/core';
|
|
|
4
4
|
import { createApplication } from '@angular/platform-browser';
|
|
5
5
|
export default (element) => {
|
|
6
6
|
return (Component, props, _childHTML) => {
|
|
7
|
-
createApplication(
|
|
7
|
+
createApplication({
|
|
8
|
+
providers: [...(Component.clientProviders || [])],
|
|
9
|
+
}).then((appRef) => {
|
|
8
10
|
const zone = appRef.injector.get(NgZone);
|
|
9
11
|
zone.run(() => {
|
|
10
12
|
const componentRef = createComponent(Component, {
|
|
@@ -24,4 +26,4 @@ export default (element) => {
|
|
|
24
26
|
});
|
|
25
27
|
};
|
|
26
28
|
};
|
|
27
|
-
//# sourceMappingURL=
|
|
29
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../packages/astro-angular/src/client.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAGL,oBAAoB,GAErB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAkB,MAAM,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,eAAe,CAAC,OAAoB,EAAE,EAAE;IACtC,OAAO,CACL,SAEC,EACD,KAA+B,EAC/B,UAAoB,EACpB,EAAE;QACF,iBAAiB,CAAC;YAChB,SAAS,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC;SAClD,CAAC,CAAC,IAAI,CAAC,CAAC,MAAsB,EAAE,EAAE;YACjC,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACzC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE;gBACZ,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,EAAE;oBAC9C,mBAAmB,EAAE,MAAM,CAAC,QAAQ;oBACpC,WAAW,EAAE,OAAO;iBACrB,CAAC,CAAC;gBAEH,MAAM,MAAM,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC;gBAC/C,IAAI,KAAK,IAAI,MAAM,EAAE;oBACnB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;wBAChD,IACE,MAAM,CAAC,MAAM,CAAC,IAAI,CAChB,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,CAC7B,YAAY,KAAK,GAAG,IAAI,QAAQ,KAAK,GAAG,CAC3C,EACD;4BACA,YAAY,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;yBACnC;qBACF;iBACF;gBAED,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YAC3C,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import 'zone.js/dist/zone.js';\nimport {\n EnvironmentProviders,\n Provider,\n reflectComponentType,\n ɵComponentType as ComponentType,\n} from '@angular/core';\nimport { ApplicationRef, NgZone, createComponent } from '@angular/core';\nimport { createApplication } from '@angular/platform-browser';\n\nexport default (element: HTMLElement) => {\n return (\n Component: ComponentType<unknown> & {\n clientProviders?: (Provider | EnvironmentProviders)[];\n },\n props?: Record<string, unknown>,\n _childHTML?: unknown\n ) => {\n createApplication({\n providers: [...(Component.clientProviders || [])],\n }).then((appRef: ApplicationRef) => {\n const zone = appRef.injector.get(NgZone);\n zone.run(() => {\n const componentRef = createComponent(Component, {\n environmentInjector: appRef.injector,\n hostElement: element,\n });\n\n const mirror = reflectComponentType(Component);\n if (props && mirror) {\n for (const [key, value] of Object.entries(props)) {\n if (\n mirror.inputs.some(\n ({ templateName, propName }) =>\n templateName === key || propName === key\n )\n ) {\n componentRef.setInput(key, value);\n }\n }\n }\n\n appRef.attachView(componentRef.hostView);\n });\n });\n };\n};\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/astro-angular/src/index.ts"],"names":[],"mappings":"AAAA,OAAoB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAE,gBAAgB,EAAiB,MAAM,OAAO,CAAC;AAExD,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AA4DD,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAanE"}
|
package/src/index.js
CHANGED
|
@@ -31,7 +31,24 @@ function getViteConfiguration(vite) {
|
|
|
31
31
|
* this workaround for now.
|
|
32
32
|
*
|
|
33
33
|
*/
|
|
34
|
-
plugins: [
|
|
34
|
+
plugins: [
|
|
35
|
+
viteAngular.default(vite),
|
|
36
|
+
{
|
|
37
|
+
name: '@analogjs/astro-angular-platform-server',
|
|
38
|
+
transform(code, id) {
|
|
39
|
+
if (id.includes('platform-server')) {
|
|
40
|
+
code = code.replace(/global\./g, 'globalThis.');
|
|
41
|
+
return {
|
|
42
|
+
code: code.replace('new xhr2.XMLHttpRequest', 'new (xhr2.default.XMLHttpRequest || xhr2.default)'),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
ssr: {
|
|
50
|
+
noExternal: ['@angular/**', '@analogjs/**'],
|
|
51
|
+
},
|
|
35
52
|
};
|
|
36
53
|
}
|
|
37
54
|
export default function (options) {
|
|
@@ -48,4 +65,4 @@ export default function (options) {
|
|
|
48
65
|
},
|
|
49
66
|
};
|
|
50
67
|
}
|
|
51
|
-
//# sourceMappingURL=
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/astro-angular/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAA8B,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAO/C,SAAS,WAAW;IAClB,OAAO;QACL,IAAI,EAAE,yBAAyB;QAC/B,gBAAgB,EAAE,mCAAmC;QACrD,gBAAgB,EAAE,mCAAmC;KACtD,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAoB;IAChD,OAAO;QACL,YAAY,EAAE;YACZ,OAAO,EAAE;gBACP,2BAA2B;gBAC3B,eAAe;gBACf,mCAAmC;aACpC;YACD,OAAO,EAAE;gBACP,0BAA0B;gBAC1B,mCAAmC;aACpC;SACF;QACD;;;;;;;;;;WAUG;QACH,OAAO,EAAE;YACN,WAAmB,CAAC,OAAO,CAAC,IAAI,CAAC;YAClC;gBACE,IAAI,EAAE,yCAAyC;gBAC/C,SAAS,CAAC,IAAY,EAAE,EAAU;oBAChC,IAAI,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE;wBAClC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;wBAEhD,OAAO;4BACL,IAAI,EAAE,IAAI,CAAC,OAAO,CAChB,yBAAyB,EACzB,mDAAmD,CACpD;yBACF,CAAC;qBACH;oBAED,OAAO;gBACT,CAAC;aACF;SACF;QACD,GAAG,EAAE;YACH,UAAU,EAAE,CAAC,aAAa,EAAE,cAAc,CAAC;SAC5C;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,WAAW,OAAwB;IAC/C,OAAO;QACL,IAAI,EAAE,yBAAyB;QAC/B,KAAK,EAAE;YACL,oBAAoB,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,EAAE;gBACtD,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC;gBAC3B,YAAY,CAAC,EAAE,IAAI,EAAE,oBAAoB,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC,EAAE,CAAC,CAAC;YAC9D,CAAC;YACD,mBAAmB,EAAE,GAAG,EAAE;gBACxB,cAAc,EAAE,CAAC;YACnB,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import viteAngular, { PluginOptions } from '@analogjs/vite-plugin-angular';\nimport { enableProdMode } from '@angular/core';\nimport { AstroIntegration, AstroRenderer } from 'astro';\n\ninterface AngularOptions {\n vite?: PluginOptions;\n}\n\nfunction getRenderer(): AstroRenderer {\n return {\n name: '@analogjs/astro-angular',\n clientEntrypoint: '@analogjs/astro-angular/client.js',\n serverEntrypoint: '@analogjs/astro-angular/server.js',\n };\n}\n\nfunction getViteConfiguration(vite?: PluginOptions) {\n return {\n optimizeDeps: {\n include: [\n '@angular/platform-browser',\n '@angular/core',\n '@analogjs/astro-angular/client.js',\n ],\n exclude: [\n '@angular/platform-server',\n '@analogjs/astro-angular/server.js',\n ],\n },\n /**\n *\n * Why I am casting viteAngular as any\n *\n * The vite angular plugins is shipped as commonjs, while this astro\n * integration is shipped using ESM and if you call the default\n * function, you get the following error: viteAngular is not a function.\n * Attempt to use ESM for the angular vite plugin broke something, hence\n * this workaround for now.\n *\n */\n plugins: [\n (viteAngular as any).default(vite),\n {\n name: '@analogjs/astro-angular-platform-server',\n transform(code: string, id: string) {\n if (id.includes('platform-server')) {\n code = code.replace(/global\\./g, 'globalThis.');\n\n return {\n code: code.replace(\n 'new xhr2.XMLHttpRequest',\n 'new (xhr2.default.XMLHttpRequest || xhr2.default)'\n ),\n };\n }\n\n return;\n },\n },\n ],\n ssr: {\n noExternal: ['@angular/**', '@analogjs/**'],\n },\n };\n}\n\nexport default function (options?: AngularOptions): AstroIntegration {\n return {\n name: '@analogjs/astro-angular',\n hooks: {\n 'astro:config:setup': ({ addRenderer, updateConfig }) => {\n addRenderer(getRenderer());\n updateConfig({ vite: getViteConfiguration(options?.vite) });\n },\n 'astro:build:setup': () => {\n enableProdMode();\n },\n },\n };\n}\n"]}
|
package/src/server.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import 'zone.js/bundles/zone-node.umd.js';
|
|
2
|
-
import type { ɵComponentType as ComponentType } from '@angular/core';
|
|
2
|
+
import type { EnvironmentProviders, Provider, ɵComponentType as ComponentType } from '@angular/core';
|
|
3
3
|
declare function check(Component: ComponentType<unknown>, _props: Record<string, unknown>, _children: unknown): boolean;
|
|
4
|
-
declare function renderToStaticMarkup(Component: ComponentType<unknown
|
|
4
|
+
declare function renderToStaticMarkup(Component: ComponentType<unknown> & {
|
|
5
|
+
renderProviders: (Provider | EnvironmentProviders)[];
|
|
6
|
+
}, props: Record<string, unknown>, _children: unknown): Promise<{
|
|
5
7
|
html: string;
|
|
6
8
|
}>;
|
|
7
9
|
declare const _default: {
|
|
@@ -9,3 +11,4 @@ declare const _default: {
|
|
|
9
11
|
renderToStaticMarkup: typeof renderToStaticMarkup;
|
|
10
12
|
};
|
|
11
13
|
export default _default;
|
|
14
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../packages/astro-angular/src/server.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAEV,oBAAoB,EACpB,QAAQ,EACR,cAAc,IAAI,aAAa,EAChC,MAAM,eAAe,CAAC;AAuBvB,iBAAS,KAAK,CACZ,SAAS,EAAE,aAAa,CAAC,OAAO,CAAC,EACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,SAAS,EAAE,OAAO,WAGnB;AAwCD,iBAAe,oBAAoB,CACjC,SAAS,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG;IAClC,eAAe,EAAE,CAAC,QAAQ,GAAG,oBAAoB,CAAC,EAAE,CAAC;CACtD,EACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,SAAS,EAAE,OAAO;;GAwBnB;;;;;AAED,wBAGE"}
|
package/src/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import 'zone.js/bundles/zone-node.umd.js';
|
|
3
3
|
import { ApplicationRef, InjectionToken, reflectComponentType, } from '@angular/core';
|
|
4
|
-
import { BEFORE_APP_SERIALIZED, provideServerRendering, renderApplication, } from '@angular/platform-server';
|
|
4
|
+
import { BEFORE_APP_SERIALIZED, provideServerRendering, renderApplication, ɵSERVER_CONTEXT, } from '@angular/platform-server';
|
|
5
5
|
import { bootstrapApplication } from '@angular/platform-browser';
|
|
6
6
|
const ANALOG_ASTRO_STATIC_PROPS = new InjectionToken('@analogjs/astro-angular: Static Props w/ Mirror Provider', {
|
|
7
7
|
factory() {
|
|
@@ -48,6 +48,8 @@ function renderToStaticMarkup(Component, props, _children) {
|
|
|
48
48
|
},
|
|
49
49
|
STATIC_PROPS_HOOK_PROVIDER,
|
|
50
50
|
provideServerRendering(),
|
|
51
|
+
{ provide: ɵSERVER_CONTEXT, useValue: 'analog' },
|
|
52
|
+
...(Component.renderProviders || []),
|
|
51
53
|
],
|
|
52
54
|
});
|
|
53
55
|
const html = yield renderApplication(bootstrap, {
|
|
@@ -60,4 +62,4 @@ export default {
|
|
|
60
62
|
check,
|
|
61
63
|
renderToStaticMarkup,
|
|
62
64
|
};
|
|
63
|
-
//# sourceMappingURL=
|
|
65
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../packages/astro-angular/src/server.ts"],"names":[],"mappings":";AAAA,OAAO,kCAAkC,CAAC;AAO1C,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,yBAAyB,GAAG,IAAI,cAAc,CAGjD,0DAA0D,EAAE;IAC7D,OAAO;QACL,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAA8B,EAAE,CAAC;IAC/D,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,KAAK,CACZ,SAAiC,EACjC,MAA+B,EAC/B,SAAkB;IAElB,OAAO,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;AAC3C,CAAC;AAED,iEAAiE;AACjE,wCAAwC;AACxC,MAAM,0BAA0B,GAAa;IAC3C,OAAO,EAAE,qBAAqB;IAC9B,UAAU,EAAE,CACV,MAAsB,EACtB,EACE,KAAK,EACL,MAAM,GAIP,EACD,EAAE;QACF,OAAO,GAAG,EAAE;YACV,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACrC,IAAI,OAAO,IAAI,KAAK,IAAI,MAAM,EAAE;gBAC9B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;oBAChD;oBACE,4CAA4C;oBAC5C,2CAA2C;oBAC3C,sDAAsD;oBACtD,MAAM,CAAC,MAAM,CAAC,IAAI,CAChB,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,CAC7B,YAAY,KAAK,GAAG,IAAI,QAAQ,KAAK,GAAG,CAC3C,EACD;wBACA,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;qBAC9B;iBACF;gBACD,OAAO,CAAC,iBAAiB,CAAC,aAAa,EAAE,CAAC;aAC3C;QACH,CAAC,CAAC;IACJ,CAAC;IACD,IAAI,EAAE,CAAC,cAAc,EAAE,yBAAyB,CAAC;IACjD,KAAK,EAAE,IAAI;CACZ,CAAC;AAEF,SAAe,oBAAoB,CACjC,SAEC,EACD,KAA8B,EAC9B,SAAkB;;QAElB,MAAM,MAAM,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,KAAK,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,KAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,CAAC;QAC1E,MAAM,QAAQ,GAAG,IAAI,KAAK,MAAM,KAAK,GAAG,CAAC;QACzC,MAAM,SAAS,GAAG,GAAG,EAAE,CACrB,oBAAoB,CAAC,SAAS,EAAE;YAC9B,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,yBAAyB;oBAClC,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;iBAC5B;gBACD,0BAA0B;gBAC1B,sBAAsB,EAAE;gBACxB,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE;gBAChD,GAAG,CAAC,SAAS,CAAC,eAAe,IAAI,EAAE,CAAC;aACrC;SACF,CAAC,CAAC;QAEL,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC,SAAS,EAAE;YAC9C,QAAQ;SACT,CAAC,CAAC;QAEH,OAAO,EAAE,IAAI,EAAE,CAAC;IAClB,CAAC;CAAA;AAED,eAAe;IACb,KAAK;IACL,oBAAoB;CACrB,CAAC","sourcesContent":["import 'zone.js/bundles/zone-node.umd.js';\nimport type {\n ComponentMirror,\n EnvironmentProviders,\n Provider,\n ɵComponentType as ComponentType,\n} from '@angular/core';\nimport {\n ApplicationRef,\n InjectionToken,\n reflectComponentType,\n} from '@angular/core';\nimport {\n BEFORE_APP_SERIALIZED,\n provideServerRendering,\n renderApplication,\n ɵSERVER_CONTEXT,\n} from '@angular/platform-server';\nimport { bootstrapApplication } from '@angular/platform-browser';\n\nconst ANALOG_ASTRO_STATIC_PROPS = new InjectionToken<{\n props: Record<string, unknown>;\n mirror: ComponentMirror<unknown>;\n}>('@analogjs/astro-angular: Static Props w/ Mirror Provider', {\n factory() {\n return { props: {}, mirror: {} as ComponentMirror<unknown> };\n },\n});\n\nfunction check(\n Component: ComponentType<unknown>,\n _props: Record<string, unknown>,\n _children: unknown\n) {\n return !!reflectComponentType(Component);\n}\n\n// Run beforeAppInitialized hook to set Input on the ComponentRef\n// before the platform renders to string\nconst STATIC_PROPS_HOOK_PROVIDER: Provider = {\n provide: BEFORE_APP_SERIALIZED,\n useFactory: (\n appRef: ApplicationRef,\n {\n props,\n mirror,\n }: {\n props: Record<string, unknown>;\n mirror: ComponentMirror<unknown>;\n }\n ) => {\n return () => {\n const compRef = appRef.components[0];\n if (compRef && props && mirror) {\n for (const [key, value] of Object.entries(props)) {\n if (\n // we double-check inputs on ComponentMirror\n // because Astro might add additional props\n // that aren't actually Input defined on the Component\n mirror.inputs.some(\n ({ templateName, propName }) =>\n templateName === key || propName === key\n )\n ) {\n compRef.setInput(key, value);\n }\n }\n compRef.changeDetectorRef.detectChanges();\n }\n };\n },\n deps: [ApplicationRef, ANALOG_ASTRO_STATIC_PROPS],\n multi: true,\n};\n\nasync function renderToStaticMarkup(\n Component: ComponentType<unknown> & {\n renderProviders: (Provider | EnvironmentProviders)[];\n },\n props: Record<string, unknown>,\n _children: unknown\n) {\n const mirror = reflectComponentType(Component);\n const appId = mirror?.selector || Component.name.toString().toLowerCase();\n const document = `<${appId}></${appId}>`;\n const bootstrap = () =>\n bootstrapApplication(Component, {\n providers: [\n {\n provide: ANALOG_ASTRO_STATIC_PROPS,\n useValue: { props, mirror },\n },\n STATIC_PROPS_HOOK_PROVIDER,\n provideServerRendering(),\n { provide: ɵSERVER_CONTEXT, useValue: 'analog' },\n ...(Component.renderProviders || []),\n ],\n });\n\n const html = await renderApplication(bootstrap, {\n document,\n });\n\n return { html };\n}\n\nexport default {\n check,\n renderToStaticMarkup,\n};\n"]}
|
package/src/test-setup.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@analogjs/vite-plugin-angular/setup-vitest';
|
package/src/test-setup.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import '@analogjs/vite-plugin-angular/setup-vitest';
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC1zZXR1cC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3BhY2thZ2VzL2FzdHJvLWFuZ3VsYXIvc3JjL3Rlc3Qtc2V0dXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyw0Q0FBNEMsQ0FBQyJ9
|