@analogjs/astro-angular 3.0.0-alpha.5 → 3.0.0-alpha.51
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/_virtual/_rolldown/runtime.js +33 -0
- package/package.json +34 -12
- package/src/client-ngh.d.ts +2 -0
- package/src/client-ngh.js +45 -0
- package/src/client-ngh.js.map +1 -0
- package/src/client.d.ts +2 -3
- package/src/client.js +41 -50
- package/src/client.js.map +1 -1
- package/src/context.d.ts +11 -0
- package/src/context.js +23 -0
- package/src/context.js.map +1 -0
- package/src/create-component.d.ts +5 -0
- package/src/create-component.js +31 -0
- package/src/create-component.js.map +1 -0
- package/src/id.d.ts +4 -0
- package/src/id.js +9 -0
- package/src/id.js.map +1 -0
- package/src/index.d.ts +15 -6
- package/src/index.js +66 -62
- package/src/index.js.map +1 -1
- package/src/middleware.d.ts +2 -0
- package/src/middleware.js +48 -0
- package/src/middleware.js.map +1 -0
- package/src/server-ngh.d.ts +2 -0
- package/src/server-ngh.js +64 -0
- package/src/server-ngh.js.map +1 -0
- package/src/server-providers.d.ts +8 -0
- package/src/server-providers.js +23 -0
- package/src/server-providers.js.map +1 -0
- package/src/server.d.ts +5 -6
- package/src/server.js +61 -56
- package/src/server.js.map +1 -1
- package/src/ssr-integrity.d.ts +1 -0
- package/src/ssr-integrity.js +10 -0
- package/src/ssr-integrity.js.map +1 -0
- package/src/test-setup.d.ts +3 -0
- package/src/utils.d.ts +0 -1
- package/src/utils.js +17 -10
- package/src/utils.js.map +1 -1
- package/src/vite-env.d.ts +1 -0
- package/README.md +0 -359
- package/src/client.d.ts.map +0 -1
- package/src/index.d.ts.map +0 -1
- package/src/server.d.ts.map +0 -1
- package/src/utils.d.ts.map +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __exportAll = (all, no_symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
|
+
key = keys[i];
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
22
|
+
get: ((k) => from[k]).bind(null, key),
|
|
23
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
29
|
+
value: mod,
|
|
30
|
+
enumerable: true
|
|
31
|
+
}) : target, mod));
|
|
32
|
+
//#endregion
|
|
33
|
+
export { __commonJSMin, __exportAll, __toESM };
|
package/package.json
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@analogjs/astro-angular",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.51",
|
|
4
4
|
"description": "Use Angular components within Astro",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Brandon Roberts <robertsbt@gmail.com>",
|
|
7
7
|
"exports": {
|
|
8
|
-
".":
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./src/index.d.ts",
|
|
10
|
+
"default": "./src/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./utils": {
|
|
13
|
+
"types": "./src/utils.d.ts",
|
|
14
|
+
"default": "./src/utils.js"
|
|
15
|
+
},
|
|
16
|
+
"./client-ngh.js": {
|
|
17
|
+
"types": "./src/client-ngh.d.ts",
|
|
18
|
+
"default": "./src/client-ngh.js"
|
|
19
|
+
},
|
|
20
|
+
"./client.js": {
|
|
21
|
+
"types": "./src/client.d.ts",
|
|
22
|
+
"default": "./src/client.js"
|
|
23
|
+
},
|
|
24
|
+
"./server-ngh.js": {
|
|
25
|
+
"types": "./src/server-ngh.d.ts",
|
|
26
|
+
"default": "./src/server-ngh.js"
|
|
27
|
+
},
|
|
28
|
+
"./server.js": {
|
|
29
|
+
"types": "./src/server.d.ts",
|
|
30
|
+
"default": "./src/server.js"
|
|
31
|
+
},
|
|
32
|
+
"./middleware": {
|
|
33
|
+
"types": "./src/middleware.d.ts",
|
|
34
|
+
"default": "./src/middleware.js"
|
|
35
|
+
},
|
|
12
36
|
"./package.json": "./package.json"
|
|
13
37
|
},
|
|
14
38
|
"keywords": [
|
|
@@ -32,7 +56,8 @@
|
|
|
32
56
|
"url": "https://github.com/sponsors/brandonroberts"
|
|
33
57
|
},
|
|
34
58
|
"dependencies": {
|
|
35
|
-
"@analogjs/vite-plugin-angular": "
|
|
59
|
+
"@analogjs/vite-plugin-angular": "3.0.0-alpha.51",
|
|
60
|
+
"rehype": "^13.0.2"
|
|
36
61
|
},
|
|
37
62
|
"peerDependencies": {
|
|
38
63
|
"@angular/build": ">=20.0.0",
|
|
@@ -46,7 +71,7 @@
|
|
|
46
71
|
"@angular/platform-server": ">=20.0.0",
|
|
47
72
|
"rxjs": "^7.8.0",
|
|
48
73
|
"tslib": "^2.4.0",
|
|
49
|
-
"vite": "^
|
|
74
|
+
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
50
75
|
},
|
|
51
76
|
"ng-update": {
|
|
52
77
|
"packageGroup": [
|
|
@@ -63,8 +88,5 @@
|
|
|
63
88
|
"publishConfig": {
|
|
64
89
|
"access": "public",
|
|
65
90
|
"provenance": true
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
"module": "./src/index.js",
|
|
69
|
-
"main": "./src/index.js"
|
|
70
|
-
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ID_PROP_NAME } from "./id.js";
|
|
2
|
+
import { createComponentBindings, getComponentElementTag } from "./create-component.js";
|
|
3
|
+
import { ensureSsrIntegrityMarker } from "./ssr-integrity.js";
|
|
4
|
+
import { APP_BOOTSTRAP_LISTENER, APP_ID, createComponent, provideZonelessChangeDetection, reflectComponentType } from "@angular/core";
|
|
5
|
+
import { createApplication, provideClientHydration } from "@angular/platform-browser";
|
|
6
|
+
//#region packages/astro-angular/src/client-ngh.ts
|
|
7
|
+
var client_ngh_default = (element) => {
|
|
8
|
+
return (Component, props) => {
|
|
9
|
+
const mirror = reflectComponentType(Component);
|
|
10
|
+
if (!mirror) return;
|
|
11
|
+
ensureSsrIntegrityMarker();
|
|
12
|
+
let hostElement = element.querySelector(mirror.selector);
|
|
13
|
+
let reuseDom = true;
|
|
14
|
+
if (!hostElement) {
|
|
15
|
+
hostElement = document.createElement(getComponentElementTag(mirror));
|
|
16
|
+
element.appendChild(hostElement);
|
|
17
|
+
reuseDom = false;
|
|
18
|
+
}
|
|
19
|
+
const ngAppId = hostElement?.getAttribute(ID_PROP_NAME);
|
|
20
|
+
createApplication({ providers: [
|
|
21
|
+
provideZonelessChangeDetection(),
|
|
22
|
+
reuseDom ? provideClientHydration(...Component.hydrationFeatures?.() || []) : [],
|
|
23
|
+
{
|
|
24
|
+
provide: APP_ID,
|
|
25
|
+
useValue: ngAppId || "ng"
|
|
26
|
+
},
|
|
27
|
+
...Component.clientProviders || []
|
|
28
|
+
] }).then((appRef) => {
|
|
29
|
+
const componentRef = createComponent(Component, {
|
|
30
|
+
environmentInjector: appRef.injector,
|
|
31
|
+
hostElement,
|
|
32
|
+
bindings: createComponentBindings(mirror, props, hostElement)
|
|
33
|
+
});
|
|
34
|
+
appRef.attachView(componentRef.hostView);
|
|
35
|
+
appRef.components.push(componentRef);
|
|
36
|
+
appRef.injector.get(APP_BOOTSTRAP_LISTENER, []).forEach((cb) => cb(componentRef));
|
|
37
|
+
}).catch((error) => {
|
|
38
|
+
console.error("Failed to hydrate Angular component:", error);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { client_ngh_default as default };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=client-ngh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-ngh.js","names":[],"sources":["../../src/client-ngh.ts"],"sourcesContent":["import {\n type EnvironmentProviders,\n type Provider,\n reflectComponentType,\n provideZonelessChangeDetection,\n Type,\n APP_ID,\n createComponent,\n APP_BOOTSTRAP_LISTENER,\n} from '@angular/core';\nimport {\n createApplication,\n type HydrationFeature,\n type HydrationFeatureKind,\n provideClientHydration,\n} from '@angular/platform-browser';\nimport {\n createComponentBindings,\n getComponentElementTag,\n} from './create-component.ts';\nimport { ID_PROP_NAME } from './id.ts';\nimport { ensureSsrIntegrityMarker } from './ssr-integrity.ts';\n\nexport default (element: HTMLElement) => {\n return (\n Component: Type<unknown> & {\n clientProviders?: (Provider | EnvironmentProviders)[];\n hydrationFeatures?: () => HydrationFeature<HydrationFeatureKind>[];\n },\n props?: Record<string, unknown>,\n ) => {\n const mirror = reflectComponentType(Component);\n\n if (!mirror) {\n // Not an Angular component\n return;\n }\n\n ensureSsrIntegrityMarker();\n\n let hostElement = element.querySelector(mirror.selector);\n let reuseDom = true;\n\n if (!hostElement) {\n // This is a client-only component\n hostElement = document.createElement(getComponentElementTag(mirror));\n element.appendChild(hostElement);\n reuseDom = false;\n }\n\n const ngAppId = hostElement?.getAttribute(ID_PROP_NAME);\n\n createApplication({\n providers: [\n provideZonelessChangeDetection(),\n reuseDom\n ? provideClientHydration(...(Component.hydrationFeatures?.() || []))\n : [],\n {\n provide: APP_ID,\n useValue: ngAppId || 'ng',\n },\n ...(Component.clientProviders || []),\n ],\n })\n .then((appRef) => {\n const componentRef = createComponent(Component, {\n environmentInjector: appRef.injector,\n hostElement,\n bindings: createComponentBindings(mirror, props, hostElement),\n });\n\n appRef.attachView(componentRef.hostView);\n\n appRef.components.push(componentRef);\n\n appRef.injector\n .get(APP_BOOTSTRAP_LISTENER, [])\n .forEach((cb) => cb(componentRef));\n })\n .catch((error) => {\n console.error('Failed to hydrate Angular component:', error);\n });\n };\n};\n"],"mappings":";;;;;;AAuBA,IAAA,sBAAgB,YAAyB;AACvC,SACE,WAIA,UACG;EACH,MAAM,SAAS,qBAAqB,UAAU;AAE9C,MAAI,CAAC,OAEH;AAGF,4BAA0B;EAE1B,IAAI,cAAc,QAAQ,cAAc,OAAO,SAAS;EACxD,IAAI,WAAW;AAEf,MAAI,CAAC,aAAa;AAEhB,iBAAc,SAAS,cAAc,uBAAuB,OAAO,CAAC;AACpE,WAAQ,YAAY,YAAY;AAChC,cAAW;;EAGb,MAAM,UAAU,aAAa,aAAa,aAAa;AAEvD,oBAAkB,EAChB,WAAW;GACT,gCAAgC;GAChC,WACI,uBAAuB,GAAI,UAAU,qBAAqB,IAAI,EAAE,CAAE,GAClE,EAAE;GACN;IACE,SAAS;IACT,UAAU,WAAW;IACtB;GACD,GAAI,UAAU,mBAAmB,EAAE;GACpC,EACF,CAAC,CACC,MAAM,WAAW;GAChB,MAAM,eAAe,gBAAgB,WAAW;IAC9C,qBAAqB,OAAO;IAC5B;IACA,UAAU,wBAAwB,QAAQ,OAAO,YAAY;IAC9D,CAAC;AAEF,UAAO,WAAW,aAAa,SAAS;AAExC,UAAO,WAAW,KAAK,aAAa;AAEpC,UAAO,SACJ,IAAI,wBAAwB,EAAE,CAAC,CAC/B,SAAS,OAAO,GAAG,aAAa,CAAC;IACpC,CACD,OAAO,UAAU;AAChB,WAAQ,MAAM,wCAAwC,MAAM;IAC5D"}
|
package/src/client.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { EnvironmentProviders, Provider, ɵComponentType as ComponentType } from
|
|
1
|
+
import { EnvironmentProviders, Provider, ɵComponentType as ComponentType } from "@angular/core";
|
|
2
2
|
declare const _default: (element: HTMLElement) => ((Component: ComponentType<unknown> & {
|
|
3
|
-
|
|
3
|
+
clientProviders?: (Provider | EnvironmentProviders)[];
|
|
4
4
|
}, props?: Record<string, unknown>, _childHTML?: unknown) => void);
|
|
5
5
|
export default _default;
|
|
6
|
-
//# sourceMappingURL=client.d.ts.map
|
package/src/client.js
CHANGED
|
@@ -1,52 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
element.dispatchEvent(event);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
appRef.onDestroy(() => {
|
|
44
|
-
destroySubject.next();
|
|
45
|
-
destroySubject.complete();
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
appRef.attachView(componentRef.hostView);
|
|
49
|
-
});
|
|
50
|
-
};
|
|
1
|
+
import { createComponent, provideZonelessChangeDetection, reflectComponentType } from "@angular/core";
|
|
2
|
+
import { createApplication } from "@angular/platform-browser";
|
|
3
|
+
import { Subject, takeUntil } from "rxjs";
|
|
4
|
+
//#region packages/astro-angular/src/client.ts
|
|
5
|
+
var client_default = (element) => {
|
|
6
|
+
return (Component, props, _childHTML) => {
|
|
7
|
+
createApplication({ providers: [provideZonelessChangeDetection(), ...Component.clientProviders || []] }).then((appRef) => {
|
|
8
|
+
const componentRef = createComponent(Component, {
|
|
9
|
+
environmentInjector: appRef.injector,
|
|
10
|
+
hostElement: element
|
|
11
|
+
});
|
|
12
|
+
const mirror = reflectComponentType(Component);
|
|
13
|
+
if (props && mirror) {
|
|
14
|
+
for (const [key, value] of Object.entries(props)) if (mirror.inputs.some(({ templateName, propName }) => templateName === key || propName === key)) componentRef.setInput(key, value);
|
|
15
|
+
}
|
|
16
|
+
if (mirror?.outputs.length && props?.["data-analog-id"]) {
|
|
17
|
+
const destroySubject = new Subject();
|
|
18
|
+
element.setAttribute("data-analog-id", props["data-analog-id"]);
|
|
19
|
+
mirror.outputs.forEach(({ templateName, propName }) => {
|
|
20
|
+
const outputName = templateName || propName;
|
|
21
|
+
componentRef.instance[outputName].pipe(takeUntil(destroySubject)).subscribe((detail) => {
|
|
22
|
+
const event = new CustomEvent(outputName, {
|
|
23
|
+
bubbles: true,
|
|
24
|
+
cancelable: true,
|
|
25
|
+
composed: true,
|
|
26
|
+
detail
|
|
27
|
+
});
|
|
28
|
+
element.dispatchEvent(event);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
appRef.onDestroy(() => {
|
|
32
|
+
destroySubject.next();
|
|
33
|
+
destroySubject.complete();
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
appRef.attachView(componentRef.hostView);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
51
39
|
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { client_default as default };
|
|
42
|
+
|
|
52
43
|
//# sourceMappingURL=client.js.map
|
package/src/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../../src/client.ts"],"sourcesContent":["import {\n EnvironmentProviders,\n Provider,\n reflectComponentType,\n ɵComponentType as ComponentType,\n provideZonelessChangeDetection,\n} from '@angular/core';\nimport { ApplicationRef, createComponent } from '@angular/core';\nimport { createApplication } from '@angular/platform-browser';\nimport { Observable, Subject, takeUntil } from 'rxjs';\n\nexport default (\n element: HTMLElement,\n): ((\n Component: ComponentType<unknown> & {\n clientProviders?: (Provider | EnvironmentProviders)[];\n },\n props?: Record<string, unknown>,\n _childHTML?: unknown,\n) => void) => {\n return (\n Component: ComponentType<unknown> & {\n clientProviders?: (Provider | EnvironmentProviders)[];\n },\n props?: Record<string, unknown>,\n _childHTML?: unknown,\n ): void => {\n createApplication({\n providers: [\n provideZonelessChangeDetection(),\n ...(Component.clientProviders || []),\n ],\n }).then((appRef: ApplicationRef) => {\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 if (mirror?.outputs.length && props?.['data-analog-id']) {\n const destroySubject = new Subject<void>();\n element.setAttribute(\n 'data-analog-id',\n props['data-analog-id'] as string,\n );\n\n mirror.outputs.forEach(({ templateName, propName }) => {\n const outputName = templateName || propName;\n const component = componentRef.instance as Record<\n string,\n Observable<unknown>\n >;\n component[outputName]\n .pipe(takeUntil(destroySubject))\n .subscribe((detail) => {\n const event = new CustomEvent(outputName, {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail,\n });\n element.dispatchEvent(event);\n });\n });\n\n appRef.onDestroy(() => {\n destroySubject.next();\n destroySubject.complete();\n });\n }\n\n appRef.attachView(componentRef.hostView);\n });\n };\n};\n"],"mappings":";;;;AAWA,IAAA,kBACE,YAOY;AACZ,SACE,WAGA,OACA,eACS;AACT,oBAAkB,EAChB,WAAW,CACT,gCAAgC,EAChC,GAAI,UAAU,mBAAmB,EAAE,CACpC,EACF,CAAC,CAAC,MAAM,WAA2B;GAClC,MAAM,eAAe,gBAAgB,WAAW;IAC9C,qBAAqB,OAAO;IAC5B,aAAa;IACd,CAAC;GAEF,MAAM,SAAS,qBAAqB,UAAU;AAC9C,OAAI,SAAS;SACN,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,KACE,OAAO,OAAO,MACX,EAAE,cAAc,eACf,iBAAiB,OAAO,aAAa,IACxC,CAED,cAAa,SAAS,KAAK,MAAM;;AAKvC,OAAI,QAAQ,QAAQ,UAAU,QAAQ,mBAAmB;IACvD,MAAM,iBAAiB,IAAI,SAAe;AAC1C,YAAQ,aACN,kBACA,MAAM,kBACP;AAED,WAAO,QAAQ,SAAS,EAAE,cAAc,eAAe;KACrD,MAAM,aAAa,gBAAgB;AACjB,kBAAa,SAIrB,YACP,KAAK,UAAU,eAAe,CAAC,CAC/B,WAAW,WAAW;MACrB,MAAM,QAAQ,IAAI,YAAY,YAAY;OACxC,SAAS;OACT,YAAY;OACZ,UAAU;OACV;OACD,CAAC;AACF,cAAQ,cAAc,MAAM;OAC5B;MACJ;AAEF,WAAO,gBAAgB;AACrB,oBAAe,MAAM;AACrB,oBAAe,UAAU;MACzB;;AAGJ,UAAO,WAAW,aAAa,SAAS;IACxC"}
|
package/src/context.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SSRResult } from "astro";
|
|
2
|
+
export type RendererContext = {
|
|
3
|
+
result: SSRResult;
|
|
4
|
+
};
|
|
5
|
+
type Context = {
|
|
6
|
+
c: number;
|
|
7
|
+
getId(): string;
|
|
8
|
+
};
|
|
9
|
+
export declare function getContext(result: SSRResult): Context;
|
|
10
|
+
export declare function incrementId(ctx: Context): string;
|
|
11
|
+
export {};
|
package/src/context.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region packages/astro-angular/src/context.ts
|
|
2
|
+
var contexts = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
function getContext(result) {
|
|
4
|
+
let ctx = contexts.get(result);
|
|
5
|
+
if (ctx) return ctx;
|
|
6
|
+
ctx = {
|
|
7
|
+
c: 0,
|
|
8
|
+
getId() {
|
|
9
|
+
return "analog-" + this.c.toString();
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
contexts.set(result, ctx);
|
|
13
|
+
return ctx;
|
|
14
|
+
}
|
|
15
|
+
function incrementId(ctx) {
|
|
16
|
+
const id = ctx.getId();
|
|
17
|
+
ctx.c++;
|
|
18
|
+
return id;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { getContext, incrementId };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../../src/context.ts"],"sourcesContent":["import type { SSRResult } from 'astro';\n\nexport type RendererContext = {\n result: SSRResult;\n};\n\ntype Context = {\n c: number;\n getId(): string;\n};\n\nconst contexts = new WeakMap<SSRResult, Context>();\n\nexport function getContext(result: SSRResult): Context {\n let ctx = contexts.get(result);\n if (ctx) {\n return ctx;\n }\n ctx = {\n c: 0,\n getId() {\n return 'analog-' + this.c.toString();\n },\n };\n contexts.set(result, ctx);\n return ctx;\n}\n\nexport function incrementId(ctx: Context): string {\n const id = ctx.getId();\n ctx.c++;\n return id;\n}\n"],"mappings":";AAWA,IAAM,2BAAW,IAAI,SAA6B;AAElD,SAAgB,WAAW,QAA4B;CACrD,IAAI,MAAM,SAAS,IAAI,OAAO;AAC9B,KAAI,IACF,QAAO;AAET,OAAM;EACJ,GAAG;EACH,QAAQ;AACN,UAAO,YAAY,KAAK,EAAE,UAAU;;EAEvC;AACD,UAAS,IAAI,QAAQ,IAAI;AACzB,QAAO;;AAGT,SAAgB,YAAY,KAAsB;CAChD,MAAM,KAAK,IAAI,OAAO;AACtB,KAAI;AACJ,QAAO"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Binding, type ComponentMirror } from "@angular/core";
|
|
2
|
+
export declare function getComponentElementTag(mirror: ComponentMirror<unknown>): string;
|
|
3
|
+
export declare function createInputBindings(mirror: ComponentMirror<unknown>, props?: Record<string, unknown>): Binding[];
|
|
4
|
+
export declare function createOutputBindings(hostElement: Element, mirror: ComponentMirror<unknown>): Binding[];
|
|
5
|
+
export declare function createComponentBindings(mirror: ComponentMirror<unknown>, props?: Record<string, unknown>, hostElement?: Element): Binding[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "./id.js";
|
|
2
|
+
import { inputBinding, outputBinding } from "@angular/core";
|
|
3
|
+
//#region packages/astro-angular/src/create-component.ts
|
|
4
|
+
function getComponentElementTag(mirror) {
|
|
5
|
+
return mirror.selector.split(",")[0] || "ng-component";
|
|
6
|
+
}
|
|
7
|
+
function createInputBindings(mirror, props) {
|
|
8
|
+
if (!props) return [];
|
|
9
|
+
return Object.entries(props).filter(([key]) => mirror.inputs.some(({ templateName }) => templateName === key)).map(([key, value]) => inputBinding(key, () => value));
|
|
10
|
+
}
|
|
11
|
+
function createOutputBindings(hostElement, mirror) {
|
|
12
|
+
return mirror.outputs.map(({ templateName }) => outputBinding(templateName, (detail) => {
|
|
13
|
+
const event = new CustomEvent(templateName, {
|
|
14
|
+
bubbles: true,
|
|
15
|
+
cancelable: true,
|
|
16
|
+
composed: true,
|
|
17
|
+
detail
|
|
18
|
+
});
|
|
19
|
+
hostElement.dispatchEvent(event);
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
function createComponentBindings(mirror, props, hostElement) {
|
|
23
|
+
const inputBindings = createInputBindings(mirror, props);
|
|
24
|
+
if (!mirror.outputs.length || !props?.["data-analog-id"] || !hostElement) return inputBindings;
|
|
25
|
+
const outputBindings = createOutputBindings(hostElement, mirror);
|
|
26
|
+
return [...inputBindings, ...outputBindings];
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { createComponentBindings, getComponentElementTag };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=create-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-component.js","names":[],"sources":["../../src/create-component.ts"],"sourcesContent":["import {\n type Binding,\n type ComponentMirror,\n inputBinding,\n outputBinding,\n} from '@angular/core';\nimport { ID_PROP_NAME } from './id.ts';\n\nexport function getComponentElementTag(\n mirror: ComponentMirror<unknown>,\n): string {\n return mirror.selector.split(',')[0] || 'ng-component';\n}\n\nexport function createInputBindings(\n mirror: ComponentMirror<unknown>,\n props?: Record<string, unknown>,\n): Binding[] {\n if (!props) {\n return [];\n }\n\n const inputBindings = Object.entries(props)\n .filter(([key]) =>\n mirror.inputs.some(({ templateName }) => templateName === key),\n )\n .map(([key, value]) => inputBinding(key, () => value));\n\n return inputBindings;\n}\n\nexport function createOutputBindings(\n hostElement: Element,\n mirror: ComponentMirror<unknown>,\n): Binding[] {\n const outputBindings = mirror.outputs.map(({ templateName }) =>\n outputBinding(templateName, (detail) => {\n const event = new CustomEvent(templateName, {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail,\n });\n hostElement.dispatchEvent(event);\n }),\n );\n\n return outputBindings;\n}\n\nexport function createComponentBindings(\n mirror: ComponentMirror<unknown>,\n props?: Record<string, unknown>,\n hostElement?: Element,\n): Binding[] {\n const inputBindings = createInputBindings(mirror, props);\n\n if (!mirror.outputs.length || !props?.[ID_PROP_NAME] || !hostElement) {\n return inputBindings;\n }\n\n const outputBindings = createOutputBindings(hostElement, mirror);\n\n return [...inputBindings, ...outputBindings];\n}\n"],"mappings":";;;AAQA,SAAgB,uBACd,QACQ;AACR,QAAO,OAAO,SAAS,MAAM,IAAI,CAAC,MAAM;;AAG1C,SAAgB,oBACd,QACA,OACW;AACX,KAAI,CAAC,MACH,QAAO,EAAE;AASX,QANsB,OAAO,QAAQ,MAAM,CACxC,QAAQ,CAAC,SACR,OAAO,OAAO,MAAM,EAAE,mBAAmB,iBAAiB,IAAI,CAC/D,CACA,KAAK,CAAC,KAAK,WAAW,aAAa,WAAW,MAAM,CAAC;;AAK1D,SAAgB,qBACd,aACA,QACW;AAaX,QAZuB,OAAO,QAAQ,KAAK,EAAE,mBAC3C,cAAc,eAAe,WAAW;EACtC,MAAM,QAAQ,IAAI,YAAY,cAAc;GAC1C,SAAS;GACT,YAAY;GACZ,UAAU;GACV;GACD,CAAC;AACF,cAAY,cAAc,MAAM;GAChC,CACH;;AAKH,SAAgB,wBACd,QACA,OACA,aACW;CACX,MAAM,gBAAgB,oBAAoB,QAAQ,MAAM;AAExD,KAAI,CAAC,OAAO,QAAQ,UAAU,CAAC,QAAA,qBAAyB,CAAC,YACvD,QAAO;CAGT,MAAM,iBAAiB,qBAAqB,aAAa,OAAO;AAEhE,QAAO,CAAC,GAAG,eAAe,GAAG,eAAe"}
|
package/src/id.d.ts
ADDED
package/src/id.js
ADDED
package/src/id.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.js","names":[],"sources":["../../src/id.ts"],"sourcesContent":["/**\n * Property name used to serialize the APP_ID of each component.\n */\nexport const ID_PROP_NAME = 'data-analog-id';\n"],"mappings":";;;;AAGA,IAAa,eAAe"}
|
package/src/index.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import { PluginOptions } from
|
|
2
|
-
import type { AstroIntegration } from
|
|
1
|
+
import type { PluginOptions } from "@analogjs/vite-plugin-angular";
|
|
2
|
+
import type { AstroIntegration } from "astro";
|
|
3
3
|
interface AngularOptions {
|
|
4
|
-
|
|
4
|
+
vite?: PluginOptions;
|
|
5
|
+
/**
|
|
6
|
+
* Enable stricter rendering, which ensures Angular style tags are added to the document head instead of next to the
|
|
7
|
+
* component in the body.
|
|
8
|
+
*
|
|
9
|
+
* Enabling this option disables astro's streaming under SSR.
|
|
10
|
+
*/
|
|
11
|
+
strictStylePlacement?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Use Angular's `provideClientHydration` to hydrate components.
|
|
14
|
+
*/
|
|
15
|
+
useAngularHydration?: boolean;
|
|
5
16
|
}
|
|
6
|
-
export default function
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
17
|
+
export default function(options?: AngularOptions): AstroIntegration;
|
package/src/index.js
CHANGED
|
@@ -1,67 +1,71 @@
|
|
|
1
|
-
import viteAngular from
|
|
2
|
-
import { enableProdMode } from
|
|
3
|
-
import * as vite from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import viteAngular from "@analogjs/vite-plugin-angular";
|
|
2
|
+
import { enableProdMode } from "@angular/core";
|
|
3
|
+
import * as vite from "vite";
|
|
4
|
+
//#region packages/astro-angular/src/index.ts
|
|
5
|
+
function getRenderer(ngHydration) {
|
|
6
|
+
return {
|
|
7
|
+
name: "@analogjs/astro-angular",
|
|
8
|
+
clientEntrypoint: ngHydration ? "@analogjs/astro-angular/client-ngh.js" : "@analogjs/astro-angular/client.js",
|
|
9
|
+
serverEntrypoint: ngHydration ? "@analogjs/astro-angular/server-ngh.js" : "@analogjs/astro-angular/server.js"
|
|
10
|
+
};
|
|
10
11
|
}
|
|
11
12
|
function getViteConfiguration(pluginOptions) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
13
|
+
const isRolldown = !!vite.rolldownVersion;
|
|
14
|
+
return {
|
|
15
|
+
[isRolldown ? "oxc" : "esbuild"]: { ...isRolldown ? { jsx: { development: true } } : { jsxDev: true } },
|
|
16
|
+
optimizeDeps: {
|
|
17
|
+
include: [
|
|
18
|
+
"@angular/platform-browser",
|
|
19
|
+
"@angular/core",
|
|
20
|
+
pluginOptions?.useAngularHydration ? "@analogjs/astro-angular/client-ngh.js" : "@analogjs/astro-angular/client.js"
|
|
21
|
+
],
|
|
22
|
+
exclude: [
|
|
23
|
+
"@angular/platform-server",
|
|
24
|
+
"@analogjs/astro-angular/server.js",
|
|
25
|
+
"@analogjs/astro-angular/server-ngh.js"
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
plugins: [
|
|
29
|
+
viteAngular(pluginOptions?.vite),
|
|
30
|
+
{
|
|
31
|
+
name: "@analogjs/astro-angular-platform-server",
|
|
32
|
+
transform(code, id) {
|
|
33
|
+
if (id.includes("platform-server")) {
|
|
34
|
+
code = code.replace(/global\./g, "globalThis.");
|
|
35
|
+
return { code: code.replace("new xhr2.XMLHttpRequest", "new (xhr2.default.XMLHttpRequest || xhr2.default)") };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "analogjs-astro-client-ngservermode",
|
|
41
|
+
configEnvironment(name) {
|
|
42
|
+
if (name === "client") return { define: { ngServerMode: "false" } };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
ssr: { noExternal: ["@angular/**", "@analogjs/**"] }
|
|
47
|
+
};
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
49
|
+
function src_default(options) {
|
|
50
|
+
process.env["ANALOG_ASTRO"] = "true";
|
|
51
|
+
return {
|
|
52
|
+
name: "@analogjs/astro-angular",
|
|
53
|
+
hooks: {
|
|
54
|
+
"astro:config:setup": ({ addRenderer, updateConfig, addMiddleware }) => {
|
|
55
|
+
addRenderer(getRenderer(options?.useAngularHydration));
|
|
56
|
+
updateConfig({ vite: getViteConfiguration(options) });
|
|
57
|
+
if (options?.strictStylePlacement) addMiddleware({
|
|
58
|
+
order: "pre",
|
|
59
|
+
entrypoint: "@analogjs/astro-angular/middleware"
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
"astro:config:done": () => {
|
|
63
|
+
if (process.env.NODE_ENV === "production") enableProdMode();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
66
67
|
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { src_default as default };
|
|
70
|
+
|
|
67
71
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import viteAngular from '@analogjs/vite-plugin-angular';\nimport type { PluginOptions } from '@analogjs/vite-plugin-angular';\nimport { enableProdMode } from '@angular/core';\nimport type { AstroIntegration, AstroRenderer, ViteUserConfig } from 'astro';\nimport * as vite from 'vite';\n\ninterface AngularOptions {\n vite?: PluginOptions;\n /**\n * Enable stricter rendering, which ensures Angular style tags are added to the document head instead of next to the\n * component in the body.\n *\n * Enabling this option disables astro's streaming under SSR.\n */\n strictStylePlacement?: boolean;\n /**\n * Use Angular's `provideClientHydration` to hydrate components.\n */\n useAngularHydration?: boolean;\n}\n\nfunction getRenderer(ngHydration: boolean | undefined): AstroRenderer {\n return {\n name: '@analogjs/astro-angular',\n clientEntrypoint: ngHydration\n ? '@analogjs/astro-angular/client-ngh.js'\n : '@analogjs/astro-angular/client.js',\n serverEntrypoint: ngHydration\n ? '@analogjs/astro-angular/server-ngh.js'\n : '@analogjs/astro-angular/server.js',\n };\n}\n\nfunction getViteConfiguration(pluginOptions?: AngularOptions) {\n const isRolldown = !!vite.rolldownVersion;\n return {\n [isRolldown ? 'oxc' : 'esbuild']: {\n ...(isRolldown ? { jsx: { development: true } } : { jsxDev: true }),\n },\n optimizeDeps: {\n include: [\n '@angular/platform-browser',\n '@angular/core',\n pluginOptions?.useAngularHydration\n ? '@analogjs/astro-angular/client-ngh.js'\n : '@analogjs/astro-angular/client.js',\n ],\n exclude: [\n '@angular/platform-server',\n '@analogjs/astro-angular/server.js',\n '@analogjs/astro-angular/server-ngh.js',\n ],\n },\n\n plugins: [\n viteAngular(pluginOptions?.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 name: 'analogjs-astro-client-ngservermode',\n configEnvironment(name: string) {\n if (name === 'client') {\n return {\n define: {\n ngServerMode: 'false',\n },\n };\n }\n\n return undefined;\n },\n },\n ],\n ssr: {\n noExternal: ['@angular/**', '@analogjs/**'],\n },\n };\n}\n\nexport default function (options?: AngularOptions): AstroIntegration {\n process.env['ANALOG_ASTRO'] = 'true';\n\n return {\n name: '@analogjs/astro-angular',\n hooks: {\n 'astro:config:setup': ({ addRenderer, updateConfig, addMiddleware }) => {\n addRenderer(getRenderer(options?.useAngularHydration));\n updateConfig({\n vite: getViteConfiguration(options),\n });\n if (options?.strictStylePlacement) {\n addMiddleware({\n order: 'pre',\n entrypoint: '@analogjs/astro-angular/middleware',\n });\n }\n },\n 'astro:config:done': () => {\n if (process.env['NODE_ENV'] === 'production') {\n enableProdMode();\n }\n },\n },\n };\n}\n"],"mappings":";;;;AAqBA,SAAS,YAAY,aAAiD;AACpE,QAAO;EACL,MAAM;EACN,kBAAkB,cACd,0CACA;EACJ,kBAAkB,cACd,0CACA;EACL;;AAGH,SAAS,qBAAqB,eAAgC;CAC5D,MAAM,aAAa,CAAC,CAAC,KAAK;AAC1B,QAAO;GACJ,aAAa,QAAQ,YAAY,EAChC,GAAI,aAAa,EAAE,KAAK,EAAE,aAAa,MAAM,EAAE,GAAG,EAAE,QAAQ,MAAM,EACnE;EACD,cAAc;GACZ,SAAS;IACP;IACA;IACA,eAAe,sBACX,0CACA;IACL;GACD,SAAS;IACP;IACA;IACA;IACD;GACF;EAED,SAAS;GACP,YAAY,eAAe,KAAK;GAChC;IACE,MAAM;IACN,UAAU,MAAc,IAAY;AAClC,SAAI,GAAG,SAAS,kBAAkB,EAAE;AAClC,aAAO,KAAK,QAAQ,aAAa,cAAc;AAE/C,aAAO,EACL,MAAM,KAAK,QACT,2BACA,oDACD,EACF;;;IAKN;GACD;IACE,MAAM;IACN,kBAAkB,MAAc;AAC9B,SAAI,SAAS,SACX,QAAO,EACL,QAAQ,EACN,cAAc,SACf,EACF;;IAKN;GACF;EACD,KAAK,EACH,YAAY,CAAC,eAAe,eAAe,EAC5C;EACF;;AAGH,SAAA,YAAyB,SAA4C;AACnE,SAAQ,IAAI,kBAAkB;AAE9B,QAAO;EACL,MAAM;EACN,OAAO;GACL,uBAAuB,EAAE,aAAa,cAAc,oBAAoB;AACtE,gBAAY,YAAY,SAAS,oBAAoB,CAAC;AACtD,iBAAa,EACX,MAAM,qBAAqB,QAAQ,EACpC,CAAC;AACF,QAAI,SAAS,qBACX,eAAc;KACZ,OAAO;KACP,YAAY;KACb,CAAC;;GAGN,2BAA2B;AACzB,QAAA,QAAA,IAAA,aAAgC,aAC9B,iBAAgB;;GAGrB;EACF"}
|