@analogjs/astro-angular 3.0.0-alpha.99 → 3.0.0-beta.2

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.
@@ -5,7 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
8
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
9
  var __exportAll = (all, no_symbols) => {
10
10
  let target = {};
11
11
  for (var name in all) __defProp(target, name, {
@@ -25,7 +25,7 @@ var __copyProps = (to, from, except, desc) => {
25
25
  }
26
26
  return to;
27
27
  };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
29
29
  value: mod,
30
30
  enumerable: true
31
31
  }) : target, mod));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/astro-angular",
3
- "version": "3.0.0-alpha.99",
3
+ "version": "3.0.0-beta.2",
4
4
  "description": "Use Angular components within Astro",
5
5
  "type": "module",
6
6
  "author": "Brandon Roberts <robertsbt@gmail.com>",
@@ -56,7 +56,7 @@
56
56
  "url": "https://github.com/sponsors/brandonroberts"
57
57
  },
58
58
  "dependencies": {
59
- "@analogjs/vite-plugin-angular": "3.0.0-alpha.99",
59
+ "@analogjs/vite-plugin-angular": "3.0.0-beta.2",
60
60
  "rehype": "^13.0.2"
61
61
  },
62
62
  "peerDependencies": {
package/src/client-ngh.js CHANGED
@@ -28,12 +28,13 @@ var client_ngh_default = (element) => {
28
28
  },
29
29
  ...Component.clientProviders || []
30
30
  ] }).then((appRef) => {
31
- registerRootComponent(appRef, createComponent(Component, {
31
+ const componentRef = createComponent(Component, {
32
32
  environmentInjector: appRef.injector,
33
33
  hostElement,
34
34
  projectableNodes,
35
35
  bindings: createComponentBindings(mirror, props, hostElement)
36
- }));
36
+ });
37
+ registerRootComponent(appRef, componentRef);
37
38
  return appRef;
38
39
  }).catch((error) => {
39
40
  console.error("Failed to hydrate Angular component:", error);
@@ -1 +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} 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 registerRootComponent,\n} from './create-component.ts';\nimport { ID_PROP_NAME } from './id.ts';\nimport { ensureSsrIntegrityMarker } from './ssr-integrity.ts';\nimport { buildProjectableNodes, collectProjectedNodes } from './projection.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 slots?: 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 // Hydration reuses the server-rendered DOM, so hand Angular the projected\n // nodes it already rendered instead of freshly parsed copies.\n const projectableNodes =\n (reuseDom && ngAppId\n ? collectProjectedNodes(hostElement, mirror, ngAppId)\n : undefined) ?? buildProjectableNodes(mirror, slots, document);\n\n return 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 projectableNodes,\n bindings: createComponentBindings(mirror, props, hostElement),\n });\n\n registerRootComponent(appRef, componentRef);\n\n return appRef;\n })\n .catch((error) => {\n console.error('Failed to hydrate Angular component:', error);\n });\n };\n};\n"],"mappings":";;;;;;;AAwBA,IAAA,sBAAgB,YAAyB;AACvC,SACE,WAIA,OACA,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;EAIvD,MAAM,oBACH,YAAY,UACT,sBAAsB,aAAa,QAAQ,QAAQ,GACnD,KAAA,MAAc,sBAAsB,QAAQ,OAAO,SAAS;AAElE,SAAO,kBAAkB,EACvB,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;AAQhB,yBAAsB,QAPD,gBAAgB,WAAW;IAC9C,qBAAqB,OAAO;IAC5B;IACA;IACA,UAAU,wBAAwB,QAAQ,OAAO,YAAY;IAC9D,CAAC,CAEyC;AAE3C,UAAO;IACP,CACD,OAAO,UAAU;AAChB,WAAQ,MAAM,wCAAwC,MAAM;IAC5D"}
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} 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 registerRootComponent,\n} from './create-component.ts';\nimport { ID_PROP_NAME } from './id.ts';\nimport { ensureSsrIntegrityMarker } from './ssr-integrity.ts';\nimport { buildProjectableNodes, collectProjectedNodes } from './projection.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 slots?: 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 // Hydration reuses the server-rendered DOM, so hand Angular the projected\n // nodes it already rendered instead of freshly parsed copies.\n const projectableNodes =\n (reuseDom && ngAppId\n ? collectProjectedNodes(hostElement, mirror, ngAppId)\n : undefined) ?? buildProjectableNodes(mirror, slots, document);\n\n return 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 projectableNodes,\n bindings: createComponentBindings(mirror, props, hostElement),\n });\n\n registerRootComponent(appRef, componentRef);\n\n return appRef;\n })\n .catch((error) => {\n console.error('Failed to hydrate Angular component:', error);\n });\n };\n};\n"],"mappings":";;;;;;;AAwBA,IAAA,sBAAgB,YAAyB;CACvC,QACE,WAIA,OACA,UACG;EACH,MAAM,SAAS,qBAAqB,SAAS;EAE7C,IAAI,CAAC,QAEH;EAGF,yBAAyB;EAEzB,IAAI,cAAc,QAAQ,cAAc,OAAO,QAAQ;EACvD,IAAI,WAAW;EAEf,IAAI,CAAC,aAAa;GAEhB,cAAc,SAAS,cAAc,uBAAuB,MAAM,CAAC;GACnE,QAAQ,YAAY,WAAW;GAC/B,WAAW;EACb;EAEA,MAAM,UAAU,aAAa,aAAa,YAAY;EAItD,MAAM,oBACH,YAAY,UACT,sBAAsB,aAAa,QAAQ,OAAO,IAClD,KAAA,MAAc,sBAAsB,QAAQ,OAAO,QAAQ;EAEjE,OAAO,kBAAkB,EACvB,WAAW;GACT,+BAA+B;GAC/B,WACI,uBAAuB,GAAI,UAAU,oBAAoB,KAAK,CAAC,CAAE,IACjE,CAAC;GACL;IACE,SAAS;IACT,UAAU,WAAW;GACvB;GACA,GAAI,UAAU,mBAAmB,CAAC;EACpC,EACF,CAAC,CAAC,CACC,MAAM,WAAW;GAChB,MAAM,eAAe,gBAAgB,WAAW;IAC9C,qBAAqB,OAAO;IAC5B;IACA;IACA,UAAU,wBAAwB,QAAQ,OAAO,WAAW;GAC9D,CAAC;GAED,sBAAsB,QAAQ,YAAY;GAE1C,OAAO;EACT,CAAC,CAAC,CACD,OAAO,UAAU;GAChB,QAAQ,MAAM,wCAAwC,KAAK;EAC7D,CAAC;CACL;AACF"}
package/src/client.js.map CHANGED
@@ -1 +1 @@
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';\nimport { buildProjectableNodes } from './projection.ts';\n\nexport default (\n element: HTMLElement,\n): ((\n Component: ComponentType<unknown> & {\n clientProviders?: (Provider | EnvironmentProviders)[];\n },\n props?: Record<string, unknown>,\n slots?: unknown,\n) => void) => {\n return (\n Component: ComponentType<unknown> & {\n clientProviders?: (Provider | EnvironmentProviders)[];\n },\n props?: Record<string, unknown>,\n slots?: unknown,\n ): void => {\n const mirror = reflectComponentType(Component);\n\n if (!mirror) {\n // Not an Angular component\n return;\n }\n\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 projectableNodes: buildProjectableNodes(mirror, slots, document),\n });\n\n if (props) {\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":";;;;;AAYA,IAAA,kBACE,YAOY;AACZ,SACE,WAGA,OACA,UACS;EACT,MAAM,SAAS,qBAAqB,UAAU;AAE9C,MAAI,CAAC,OAEH;AAGF,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;IACb,kBAAkB,sBAAsB,QAAQ,OAAO,SAAS;IACjE,CAAC;AAEF,OAAI;SACG,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,OAAO,QAAQ,UAAU,QAAQ,mBAAmB;IACtD,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"}
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';\nimport { buildProjectableNodes } from './projection.ts';\n\nexport default (\n element: HTMLElement,\n): ((\n Component: ComponentType<unknown> & {\n clientProviders?: (Provider | EnvironmentProviders)[];\n },\n props?: Record<string, unknown>,\n slots?: unknown,\n) => void) => {\n return (\n Component: ComponentType<unknown> & {\n clientProviders?: (Provider | EnvironmentProviders)[];\n },\n props?: Record<string, unknown>,\n slots?: unknown,\n ): void => {\n const mirror = reflectComponentType(Component);\n\n if (!mirror) {\n // Not an Angular component\n return;\n }\n\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 projectableNodes: buildProjectableNodes(mirror, slots, document),\n });\n\n if (props) {\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":";;;;;AAYA,IAAA,kBACE,YAOY;CACZ,QACE,WAGA,OACA,UACS;EACT,MAAM,SAAS,qBAAqB,SAAS;EAE7C,IAAI,CAAC,QAEH;EAGF,kBAAkB,EAChB,WAAW,CACT,+BAA+B,GAC/B,GAAI,UAAU,mBAAmB,CAAC,CACpC,EACF,CAAC,CAAC,CAAC,MAAM,WAA2B;GAClC,MAAM,eAAe,gBAAgB,WAAW;IAC9C,qBAAqB,OAAO;IAC5B,aAAa;IACb,kBAAkB,sBAAsB,QAAQ,OAAO,QAAQ;GACjE,CAAC;GAED,IAAI,OACG;SAAA,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,GAC7C,IACE,OAAO,OAAO,MACX,EAAE,cAAc,eACf,iBAAiB,OAAO,aAAa,GACzC,GAEA,aAAa,SAAS,KAAK,KAAK;GAAA;GAKtC,IAAI,OAAO,QAAQ,UAAU,QAAQ,mBAAmB;IACtD,MAAM,iBAAiB,IAAI,QAAc;IACzC,QAAQ,aACN,kBACA,MAAM,iBACR;IAEA,OAAO,QAAQ,SAAS,EAAE,cAAc,eAAe;KACrD,MAAM,aAAa,gBAAgB;KAKnC,aAJ+B,SAIrB,WAAW,CAClB,KAAK,UAAU,cAAc,CAAC,CAAC,CAC/B,WAAW,WAAW;MACrB,MAAM,QAAQ,IAAI,YAAY,YAAY;OACxC,SAAS;OACT,YAAY;OACZ,UAAU;OACV;MACF,CAAC;MACD,QAAQ,cAAc,KAAK;KAC7B,CAAC;IACL,CAAC;IAED,OAAO,gBAAgB;KACrB,eAAe,KAAK;KACpB,eAAe,SAAS;IAC1B,CAAC;GACH;GAEA,OAAO,WAAW,aAAa,QAAQ;EACzC,CAAC;CACH;AACF"}
@@ -1 +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"}
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,QAA4B;AAEjD,SAAgB,WAAW,QAA4B;CACrD,IAAI,MAAM,SAAS,IAAI,MAAM;CAC7B,IAAI,KACF,OAAO;CAET,MAAM;EACJ,GAAG;EACH,QAAQ;GACN,OAAO,YAAY,KAAK,EAAE,SAAS;EACrC;CACF;CACA,SAAS,IAAI,QAAQ,GAAG;CACxB,OAAO;AACT;AAEA,SAAgB,YAAY,KAAsB;CAChD,MAAM,KAAK,IAAI,MAAM;CACrB,IAAI;CACJ,OAAO;AACT"}
@@ -38,6 +38,6 @@ function registerRootComponent(appRef, componentRef) {
38
38
  appRef.injector.get(APP_BOOTSTRAP_LISTENER, []).forEach((listener) => listener(componentRef));
39
39
  }
40
40
  //#endregion
41
- export { createComponentBindings, createInputBindings, getComponentElementTag, registerRootComponent };
41
+ export { createComponentBindings, createInputBindings, createOutputBindings, getComponentElementTag, registerRootComponent };
42
42
 
43
43
  //# sourceMappingURL=create-component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-component.js","names":[],"sources":["../../src/create-component.ts"],"sourcesContent":["import {\n APP_BOOTSTRAP_LISTENER,\n type ApplicationRef,\n type Binding,\n type ComponentMirror,\n type ComponentRef,\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\n/**\n * Registers a component created with `createComponent` as a root component,\n * the way `bootstrapApplication` does: attach the view, track it on the\n * application, run the initial change detection and notify\n * `APP_BOOTSTRAP_LISTENER`s such as the router's.\n */\nexport function registerRootComponent(\n appRef: ApplicationRef,\n componentRef: ComponentRef<unknown>,\n): void {\n appRef.attachView(componentRef.hostView);\n appRef.tick();\n appRef.components.push(componentRef);\n appRef.injector\n .get(APP_BOOTSTRAP_LISTENER, [])\n .forEach((listener) => listener(componentRef));\n}\n"],"mappings":";;;AAWA,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;;;;;;;;AAS9C,SAAgB,sBACd,QACA,cACM;AACN,QAAO,WAAW,aAAa,SAAS;AACxC,QAAO,MAAM;AACb,QAAO,WAAW,KAAK,aAAa;AACpC,QAAO,SACJ,IAAI,wBAAwB,EAAE,CAAC,CAC/B,SAAS,aAAa,SAAS,aAAa,CAAC"}
1
+ {"version":3,"file":"create-component.js","names":[],"sources":["../../src/create-component.ts"],"sourcesContent":["import {\n APP_BOOTSTRAP_LISTENER,\n type ApplicationRef,\n type Binding,\n type ComponentMirror,\n type ComponentRef,\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\n/**\n * Registers a component created with `createComponent` as a root component,\n * the way `bootstrapApplication` does: attach the view, track it on the\n * application, run the initial change detection and notify\n * `APP_BOOTSTRAP_LISTENER`s such as the router's.\n */\nexport function registerRootComponent(\n appRef: ApplicationRef,\n componentRef: ComponentRef<unknown>,\n): void {\n appRef.attachView(componentRef.hostView);\n appRef.tick();\n appRef.components.push(componentRef);\n appRef.injector\n .get(APP_BOOTSTRAP_LISTENER, [])\n .forEach((listener) => listener(componentRef));\n}\n"],"mappings":";;;AAWA,SAAgB,uBACd,QACQ;CACR,OAAO,OAAO,SAAS,MAAM,GAAG,CAAC,CAAC,MAAM;AAC1C;AAEA,SAAgB,oBACd,QACA,OACW;CACX,IAAI,CAAC,OACH,OAAO,CAAC;CASV,OANsB,OAAO,QAAQ,KAAK,CAAC,CACxC,QAAQ,CAAC,SACR,OAAO,OAAO,MAAM,EAAE,mBAAmB,iBAAiB,GAAG,CAC/D,CAAC,CACA,KAAK,CAAC,KAAK,WAAW,aAAa,WAAW,KAAK,CAE/C;AACT;AAEA,SAAgB,qBACd,aACA,QACW;CAaX,OAZuB,OAAO,QAAQ,KAAK,EAAE,mBAC3C,cAAc,eAAe,WAAW;EACtC,MAAM,QAAQ,IAAI,YAAY,cAAc;GAC1C,SAAS;GACT,YAAY;GACZ,UAAU;GACV;EACF,CAAC;EACD,YAAY,cAAc,KAAK;CACjC,CAAC,CAGI;AACT;AAEA,SAAgB,wBACd,QACA,OACA,aACW;CACX,MAAM,gBAAgB,oBAAoB,QAAQ,KAAK;CAEvD,IAAI,CAAC,OAAO,QAAQ,UAAU,CAAC,QAAA,qBAAyB,CAAC,aACvD,OAAO;CAGT,MAAM,iBAAiB,qBAAqB,aAAa,MAAM;CAE/D,OAAO,CAAC,GAAG,eAAe,GAAG,cAAc;AAC7C;;;;;;;AAQA,SAAgB,sBACd,QACA,cACM;CACN,OAAO,WAAW,aAAa,QAAQ;CACvC,OAAO,KAAK;CACZ,OAAO,WAAW,KAAK,YAAY;CACnC,OAAO,SACJ,IAAI,wBAAwB,CAAC,CAAC,CAAC,CAC/B,SAAS,aAAa,SAAS,YAAY,CAAC;AACjD"}
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import viteAngular from '@analogjs/vite-plugin-angular';\nimport type {\n AnalogIntegrationPlugin,\n PluginOptions,\n TransformFilter,\n} 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 * Restricts which modules Angular compiles. Return `false` to leave a\n * module to other Astro integrations. Registered with Angular through the\n * `analog.setup()` hook of an internal Vite plugin.\n */\n transformFilter?: TransformFilter;\n /**\n * Adds Angular style tags to the document head instead of next to the\n * component in the body. Defaults to `true`.\n *\n * This disables Astro's streaming under SSR. Set to `false` to keep streaming.\n */\n strictStylePlacement?: boolean;\n /**\n * Use Angular's `provideClientHydration` to hydrate components. Defaults to\n * `true`. Set to `false` to bootstrap components on the client instead.\n */\n useAngularHydration?: boolean;\n}\n\nfunction getRenderer(ngHydration: boolean): 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\nconst SERVER_ENTRYPOINTS = [\n '@angular/platform-server',\n '@analogjs/astro-angular/server.js',\n '@analogjs/astro-angular/server-ngh.js',\n];\n\n/**\n * Modules the dependency optimizer must leave alone on the server.\n * `@angular/core` is excluded on top of the server entrypoints because\n * pre-bundling it produces a second copy of the Angular runtime, so components\n * render against a different runtime than the one they were registered in —\n * surfacing as empty SSR output plus `NG0912` component ID collisions.\n */\nconst SERVER_OPTIMIZE_DEPS_EXCLUDE = [...SERVER_ENTRYPOINTS, '@angular/core'];\n\nfunction transformFilterPlugin(\n filter: TransformFilter,\n): AnalogIntegrationPlugin {\n return {\n name: '@analogjs/astro-angular-transform-filter',\n analog: {\n setup(ctx) {\n ctx.registerTransformFilter(filter);\n },\n },\n };\n}\n\nfunction getViteConfiguration(\n ngHydration: boolean,\n pluginOptions?: AngularOptions,\n) {\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 ngHydration\n ? '@analogjs/astro-angular/client-ngh.js'\n : '@analogjs/astro-angular/client.js',\n ],\n exclude: SERVER_ENTRYPOINTS,\n },\n\n plugins: [\n viteAngular(pluginOptions?.vite),\n ...(pluginOptions?.transformFilter\n ? [transformFilterPlugin(pluginOptions.transformFilter)]\n : []),\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 // Top-level `optimizeDeps` only seeds the client environment. Adapters\n // that run SSR in their own environment — `@astrojs/cloudflare`, which\n // serves the `ssr` environment on `workerd` — get none of the excludes\n // above, so Angular's server entrypoints are pre-bundled there and the\n // renderer breaks. Re-declare them per server environment.\n name: 'analogjs-astro-server-optimize-deps',\n configEnvironment(name: string) {\n if (name === 'client') {\n return undefined;\n }\n\n return {\n optimizeDeps: {\n exclude: SERVER_OPTIMIZE_DEPS_EXCLUDE,\n },\n };\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 const ngHydration = options?.useAngularHydration !== false;\n addRenderer(getRenderer(ngHydration));\n updateConfig({\n vite: getViteConfiguration(ngHydration, options),\n });\n if (options?.strictStylePlacement !== false) {\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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AAM;EACN,OAAO;GACL,uBAAuB,EAAE,aAAa,cAAc,oBAAoB;IACtE,MAAM,cAAc,SAAS,wBAAwB;AACrD,gBAAY,YAAY,YAAY,CAAC;AACrC,iBAAa,EACX,MAAM,qBAAqB,aAAa,QAAQ,EACjD,CAAC;AACF,QAAI,SAAS,yBAAyB,MACpC,eAAc;KACZ,OAAO;KACP,YAAY;KACb,CAAC;;GAGN,2BAA2B;AACzB,QAAA,QAAA,IAAA,aAAgC,aAC9B,iBAAgB;;GAGrB;EACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import viteAngular from '@analogjs/vite-plugin-angular';\nimport type {\n AnalogIntegrationPlugin,\n PluginOptions,\n TransformFilter,\n} 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 * Restricts which modules Angular compiles. Return `false` to leave a\n * module to other Astro integrations. Registered with Angular through the\n * `analog.setup()` hook of an internal Vite plugin.\n */\n transformFilter?: TransformFilter;\n /**\n * Adds Angular style tags to the document head instead of next to the\n * component in the body. Defaults to `true`.\n *\n * This disables Astro's streaming under SSR. Set to `false` to keep streaming.\n */\n strictStylePlacement?: boolean;\n /**\n * Use Angular's `provideClientHydration` to hydrate components. Defaults to\n * `true`. Set to `false` to bootstrap components on the client instead.\n */\n useAngularHydration?: boolean;\n}\n\nfunction getRenderer(ngHydration: boolean): 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\nconst SERVER_ENTRYPOINTS = [\n '@angular/platform-server',\n '@analogjs/astro-angular/server.js',\n '@analogjs/astro-angular/server-ngh.js',\n];\n\n/**\n * Modules the dependency optimizer must leave alone on the server.\n * `@angular/core` is excluded on top of the server entrypoints because\n * pre-bundling it produces a second copy of the Angular runtime, so components\n * render against a different runtime than the one they were registered in —\n * surfacing as empty SSR output plus `NG0912` component ID collisions.\n */\nconst SERVER_OPTIMIZE_DEPS_EXCLUDE = [...SERVER_ENTRYPOINTS, '@angular/core'];\n\nfunction transformFilterPlugin(\n filter: TransformFilter,\n): AnalogIntegrationPlugin {\n return {\n name: '@analogjs/astro-angular-transform-filter',\n analog: {\n setup(ctx) {\n ctx.registerTransformFilter(filter);\n },\n },\n };\n}\n\nfunction getViteConfiguration(\n ngHydration: boolean,\n pluginOptions?: AngularOptions,\n) {\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 ngHydration\n ? '@analogjs/astro-angular/client-ngh.js'\n : '@analogjs/astro-angular/client.js',\n ],\n exclude: SERVER_ENTRYPOINTS,\n },\n\n plugins: [\n viteAngular(pluginOptions?.vite),\n ...(pluginOptions?.transformFilter\n ? [transformFilterPlugin(pluginOptions.transformFilter)]\n : []),\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 // Top-level `optimizeDeps` only seeds the client environment. Adapters\n // that run SSR in their own environment — `@astrojs/cloudflare`, which\n // serves the `ssr` environment on `workerd` — get none of the excludes\n // above, so Angular's server entrypoints are pre-bundled there and the\n // renderer breaks. Re-declare them per server environment.\n name: 'analogjs-astro-server-optimize-deps',\n configEnvironment(name: string) {\n if (name === 'client') {\n return undefined;\n }\n\n return {\n optimizeDeps: {\n exclude: SERVER_OPTIMIZE_DEPS_EXCLUDE,\n },\n };\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 const ngHydration = options?.useAngularHydration !== false;\n addRenderer(getRenderer(ngHydration));\n updateConfig({\n vite: getViteConfiguration(ngHydration, options),\n });\n if (options?.strictStylePlacement !== false) {\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":";;;;AAgCA,SAAS,YAAY,aAAqC;CACxD,OAAO;EACL,MAAM;EACN,kBAAkB,cACd,0CACA;EACJ,kBAAkB,cACd,0CACA;CACN;AACF;AAEA,IAAM,qBAAqB;CACzB;CACA;CACA;AACF;;;;;;;;AASA,IAAM,+BAA+B,CAAC,GAAG,oBAAoB,eAAe;AAE5E,SAAS,sBACP,QACyB;CACzB,OAAO;EACL,MAAM;EACN,QAAQ,EACN,MAAM,KAAK;GACT,IAAI,wBAAwB,MAAM;EACpC,EACF;CACF;AACF;AAEA,SAAS,qBACP,aACA,eACA;CACA,MAAM,aAAa,CAAC,CAAC,KAAK;CAC1B,OAAO;GACJ,aAAa,QAAQ,YAAY,EAChC,GAAI,aAAa,EAAE,KAAK,EAAE,aAAa,KAAK,EAAE,IAAI,EAAE,QAAQ,KAAK,EACnE;EACA,cAAc;GACZ,SAAS;IACP;IACA;IACA,cACI,0CACA;GACN;GACA,SAAS;EACX;EAEA,SAAS;GACP,YAAY,eAAe,IAAI;GAC/B,GAAI,eAAe,kBACf,CAAC,sBAAsB,cAAc,eAAe,CAAC,IACrD,CAAC;GACL;IACE,MAAM;IACN,UAAU,MAAc,IAAY;KAClC,IAAI,GAAG,SAAS,iBAAiB,GAAG;MAClC,OAAO,KAAK,QAAQ,aAAa,aAAa;MAE9C,OAAO,EACL,MAAM,KAAK,QACT,2BACA,mDACF,EACF;KACF;IAGF;GACF;GACA;IACE,MAAM;IACN,kBAAkB,MAAc;KAC9B,IAAI,SAAS,UACX,OAAO,EACL,QAAQ,EACN,cAAc,QAChB,EACF;IAIJ;GACF;GACA;IAME,MAAM;IACN,kBAAkB,MAAc;KAC9B,IAAI,SAAS,UACX;KAGF,OAAO,EACL,cAAc,EACZ,SAAS,6BACX,EACF;IACF;GACF;EACF;EACA,KAAK,EACH,YAAY,CAAC,eAAe,cAAc,EAC5C;CACF;AACF;AAEA,SAAA,YAAyB,SAA4C;CACnE,QAAQ,IAAI,kBAAkB;CAE9B,OAAO;EACL,MAAM;EACN,OAAO;GACL,uBAAuB,EAAE,aAAa,cAAc,oBAAoB;IACtE,MAAM,cAAc,SAAS,wBAAwB;IACrD,YAAY,YAAY,WAAW,CAAC;IACpC,aAAa,EACX,MAAM,qBAAqB,aAAa,OAAO,EACjD,CAAC;IACD,IAAI,SAAS,yBAAyB,OACpC,cAAc;KACZ,OAAO;KACP,YAAY;IACd,CAAC;GAEL;GACA,2BAA2B;IACzB,IAAA,QAAA,IAAA,aAAgC,cAC9B,eAAe;GAEnB;EACF;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","names":[],"sources":["../../src/middleware.ts"],"sourcesContent":["import type { MiddlewareHandler } from 'astro';\nimport type { Root, RootContent, Element } from 'hast';\nimport { rehype } from 'rehype';\n\nconst processor = rehype();\n\nexport const onRequest: MiddlewareHandler = async (_ctx, next) => {\n const response = await next();\n if (response.headers.get('content-type')?.includes('text/html') !== true) {\n return response;\n }\n\n // Find all <style ng-app-id=\"...\"> tags in the body and move them to the head\n\n const responseBody = await response.text();\n\n const tree = processor.parse(responseBody);\n\n const stack: (Root | RootContent)[] = [tree];\n\n const styleTags: Element[] = [];\n let head: Element | null = null;\n\n while (stack.length) {\n const top = stack.pop()!;\n\n if (top.type === 'element' && top.tagName === 'template') {\n // Templates create a shadow-root, so styles should not be moved outside.\n continue;\n }\n\n if (top.type === 'element' && top.tagName === 'style') {\n if ('ng-app-id' in top.properties) {\n styleTags.push(top);\n }\n continue;\n }\n\n if (top.type === 'element' && top.tagName === 'head' && !head) {\n head = top;\n continue;\n }\n\n if (top.type !== 'root' && top.type !== 'element') {\n continue;\n }\n\n for (let index = top.children.length - 1; index >= 0; index--) {\n const child = top.children[index];\n\n stack.push(child);\n\n if (\n child.type === 'element' &&\n child.tagName === 'style' &&\n 'ng-app-id' in child.properties\n ) {\n top.children.splice(index, 1);\n }\n }\n }\n\n if (head) {\n head.children.push(...styleTags);\n } else {\n const head: Element = {\n type: 'element',\n children: styleTags,\n properties: {},\n tagName: 'head',\n };\n\n tree.children.unshift(head);\n }\n\n const newBody = processor.stringify(tree);\n\n const newResponse = new Response(newBody, response);\n newResponse.headers.set(\n 'content-length',\n Buffer.byteLength(newBody).toFixed(0),\n );\n\n return newResponse;\n};\n"],"mappings":";;AAIA,IAAM,YAAY,QAAQ;AAE1B,IAAa,YAA+B,OAAO,MAAM,SAAS;CAChE,MAAM,WAAW,MAAM,MAAM;AAC7B,KAAI,SAAS,QAAQ,IAAI,eAAe,EAAE,SAAS,YAAY,KAAK,KAClE,QAAO;CAKT,MAAM,eAAe,MAAM,SAAS,MAAM;CAE1C,MAAM,OAAO,UAAU,MAAM,aAAa;CAE1C,MAAM,QAAgC,CAAC,KAAK;CAE5C,MAAM,YAAuB,EAAE;CAC/B,IAAI,OAAuB;AAE3B,QAAO,MAAM,QAAQ;EACnB,MAAM,MAAM,MAAM,KAAK;AAEvB,MAAI,IAAI,SAAS,aAAa,IAAI,YAAY,WAE5C;AAGF,MAAI,IAAI,SAAS,aAAa,IAAI,YAAY,SAAS;AACrD,OAAI,eAAe,IAAI,WACrB,WAAU,KAAK,IAAI;AAErB;;AAGF,MAAI,IAAI,SAAS,aAAa,IAAI,YAAY,UAAU,CAAC,MAAM;AAC7D,UAAO;AACP;;AAGF,MAAI,IAAI,SAAS,UAAU,IAAI,SAAS,UACtC;AAGF,OAAK,IAAI,QAAQ,IAAI,SAAS,SAAS,GAAG,SAAS,GAAG,SAAS;GAC7D,MAAM,QAAQ,IAAI,SAAS;AAE3B,SAAM,KAAK,MAAM;AAEjB,OACE,MAAM,SAAS,aACf,MAAM,YAAY,WAClB,eAAe,MAAM,WAErB,KAAI,SAAS,OAAO,OAAO,EAAE;;;AAKnC,KAAI,KACF,MAAK,SAAS,KAAK,GAAG,UAAU;MAC3B;EACL,MAAM,OAAgB;GACpB,MAAM;GACN,UAAU;GACV,YAAY,EAAE;GACd,SAAS;GACV;AAED,OAAK,SAAS,QAAQ,KAAK;;CAG7B,MAAM,UAAU,UAAU,UAAU,KAAK;CAEzC,MAAM,cAAc,IAAI,SAAS,SAAS,SAAS;AACnD,aAAY,QAAQ,IAClB,kBACA,OAAO,WAAW,QAAQ,CAAC,QAAQ,EAAE,CACtC;AAED,QAAO"}
1
+ {"version":3,"file":"middleware.js","names":[],"sources":["../../src/middleware.ts"],"sourcesContent":["import type { MiddlewareHandler } from 'astro';\nimport type { Root, RootContent, Element } from 'hast';\nimport { rehype } from 'rehype';\n\nconst processor = rehype();\n\nexport const onRequest: MiddlewareHandler = async (_ctx, next) => {\n const response = await next();\n if (response.headers.get('content-type')?.includes('text/html') !== true) {\n return response;\n }\n\n // Find all <style ng-app-id=\"...\"> tags in the body and move them to the head\n\n const responseBody = await response.text();\n\n const tree = processor.parse(responseBody);\n\n const stack: (Root | RootContent)[] = [tree];\n\n const styleTags: Element[] = [];\n let head: Element | null = null;\n\n while (stack.length) {\n const top = stack.pop()!;\n\n if (top.type === 'element' && top.tagName === 'template') {\n // Templates create a shadow-root, so styles should not be moved outside.\n continue;\n }\n\n if (top.type === 'element' && top.tagName === 'style') {\n if ('ng-app-id' in top.properties) {\n styleTags.push(top);\n }\n continue;\n }\n\n if (top.type === 'element' && top.tagName === 'head' && !head) {\n head = top;\n continue;\n }\n\n if (top.type !== 'root' && top.type !== 'element') {\n continue;\n }\n\n for (let index = top.children.length - 1; index >= 0; index--) {\n const child = top.children[index];\n\n stack.push(child);\n\n if (\n child.type === 'element' &&\n child.tagName === 'style' &&\n 'ng-app-id' in child.properties\n ) {\n top.children.splice(index, 1);\n }\n }\n }\n\n if (head) {\n head.children.push(...styleTags);\n } else {\n const head: Element = {\n type: 'element',\n children: styleTags,\n properties: {},\n tagName: 'head',\n };\n\n tree.children.unshift(head);\n }\n\n const newBody = processor.stringify(tree);\n\n const newResponse = new Response(newBody, response);\n newResponse.headers.set(\n 'content-length',\n Buffer.byteLength(newBody).toFixed(0),\n );\n\n return newResponse;\n};\n"],"mappings":";;AAIA,IAAM,YAAY,OAAO;AAEzB,IAAa,YAA+B,OAAO,MAAM,SAAS;CAChE,MAAM,WAAW,MAAM,KAAK;CAC5B,IAAI,SAAS,QAAQ,IAAI,cAAc,CAAC,EAAE,SAAS,WAAW,MAAM,MAClE,OAAO;CAKT,MAAM,eAAe,MAAM,SAAS,KAAK;CAEzC,MAAM,OAAO,UAAU,MAAM,YAAY;CAEzC,MAAM,QAAgC,CAAC,IAAI;CAE3C,MAAM,YAAuB,CAAC;CAC9B,IAAI,OAAuB;CAE3B,OAAO,MAAM,QAAQ;EACnB,MAAM,MAAM,MAAM,IAAI;EAEtB,IAAI,IAAI,SAAS,aAAa,IAAI,YAAY,YAE5C;EAGF,IAAI,IAAI,SAAS,aAAa,IAAI,YAAY,SAAS;GACrD,IAAI,eAAe,IAAI,YACrB,UAAU,KAAK,GAAG;GAEpB;EACF;EAEA,IAAI,IAAI,SAAS,aAAa,IAAI,YAAY,UAAU,CAAC,MAAM;GAC7D,OAAO;GACP;EACF;EAEA,IAAI,IAAI,SAAS,UAAU,IAAI,SAAS,WACtC;EAGF,KAAK,IAAI,QAAQ,IAAI,SAAS,SAAS,GAAG,SAAS,GAAG,SAAS;GAC7D,MAAM,QAAQ,IAAI,SAAS;GAE3B,MAAM,KAAK,KAAK;GAEhB,IACE,MAAM,SAAS,aACf,MAAM,YAAY,WAClB,eAAe,MAAM,YAErB,IAAI,SAAS,OAAO,OAAO,CAAC;EAEhC;CACF;CAEA,IAAI,MACF,KAAK,SAAS,KAAK,GAAG,SAAS;MAC1B;EACL,MAAM,OAAgB;GACpB,MAAM;GACN,UAAU;GACV,YAAY,CAAC;GACb,SAAS;EACX;EAEA,KAAK,SAAS,QAAQ,IAAI;CAC5B;CAEA,MAAM,UAAU,UAAU,UAAU,IAAI;CAExC,MAAM,cAAc,IAAI,SAAS,SAAS,QAAQ;CAClD,YAAY,QAAQ,IAClB,kBACA,OAAO,WAAW,OAAO,CAAC,CAAC,QAAQ,CAAC,CACtC;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"projection.js","names":[],"sources":["../../src/projection.ts"],"sourcesContent":["import type { ComponentMirror } from '@angular/core';\nimport { isSameSelector, parseSelectorList } from './selector.ts';\n\nconst ELEMENT_NODE = 1;\nconst TEXT_NODE = 3;\nconst COMMENT_NODE = 8;\nconst SHOW_COMMENT = 128;\n\nconst MARKER_PREFIX = 'analog-slot:';\n\n/**\n * Distributes the HTML Astro rendered for the component's slots across the\n * component's `<ng-content>` slots, using Angular's own selector semantics.\n *\n * The result is indexed to match `mirror.ngContentSelectors`. Angular does not\n * apply `select` matching to `projectableNodes`, so the matching happens here.\n * @param mirror The component mirror, to read the `ng-content` selectors\n * @param slots The slot HTML passed by Astro, keyed by slot name\n * @param document The document the component is rendered into\n * @returns The nodes to project, or `undefined` when the component has no `ng-content`\n */\nexport function buildProjectableNodes(\n mirror: ComponentMirror<unknown>,\n slots: unknown,\n document: Document,\n): Node[][] | undefined {\n const selectors = mirror.ngContentSelectors;\n\n if (!selectors.length) {\n return undefined;\n }\n\n const projectableNodes: Node[][] = selectors.map(() => []);\n // As in Angular, unmatched content goes to the last default slot.\n const wildcardIndex = selectors.lastIndexOf('*');\n\n for (const node of parseSlots(slots, document)) {\n // Angular drops whitespace-only text nodes between elements at compile\n // time, so projecting them would only suppress `ng-content` fallbacks.\n if (node.nodeType === TEXT_NODE && !node.textContent?.trim()) {\n continue;\n }\n\n const matched = selectors.findIndex(\n (selector) => selector !== '*' && matches(node, selector),\n );\n const target = matched > -1 ? matched : wildcardIndex;\n\n if (target > -1) {\n projectableNodes[target].push(node);\n }\n }\n\n return projectableNodes;\n}\n\n/**\n * Wraps each non-empty slot in comment markers, so the client can find the\n * server-rendered nodes again when hydrating. Angular reuses the DOM during\n * hydration, so it must be handed those nodes rather than freshly parsed ones.\n * @param projectableNodes The distributed nodes, see `buildProjectableNodes`\n * @param appId The island's APP_ID, to keep markers apart from nested islands\n * @param document The document the component is rendered into\n */\nexport function markProjectableNodes(\n projectableNodes: Node[][],\n appId: string,\n document: Document,\n): Node[][] {\n return projectableNodes.map((nodes, index) =>\n nodes.length\n ? [\n document.createComment(`${MARKER_PREFIX}${appId}:${index}`),\n ...nodes,\n document.createComment(`/${MARKER_PREFIX}${appId}:${index}`),\n ]\n : nodes,\n );\n}\n\n/**\n * Collects the server-rendered projected nodes from the host element using the\n * markers added by `markProjectableNodes`.\n * @returns The nodes per slot, or `undefined` when the host carries no markers\n */\nexport function collectProjectedNodes(\n hostElement: Element,\n mirror: ComponentMirror<unknown>,\n appId: string,\n): Node[][] | undefined {\n const selectors = mirror.ngContentSelectors;\n\n if (!selectors.length) {\n return undefined;\n }\n\n const projectableNodes: Node[][] = selectors.map(() => []);\n const walker = hostElement.ownerDocument.createTreeWalker(\n hostElement,\n SHOW_COMMENT,\n );\n let found = false;\n\n for (let start = walker.nextNode(); start; start = walker.nextNode()) {\n const match = start.textContent?.startsWith(`${MARKER_PREFIX}${appId}:`)\n ? Number(start.textContent.slice(`${MARKER_PREFIX}${appId}:`.length))\n : NaN;\n\n if (Number.isNaN(match) || match >= selectors.length) {\n continue;\n }\n\n const end = `/${MARKER_PREFIX}${appId}:${match}`;\n const nodes: Node[] = [start];\n let node = start.nextSibling;\n\n while (\n node &&\n !(node.nodeType === COMMENT_NODE && node.textContent === end)\n ) {\n nodes.push(node);\n node = node.nextSibling;\n }\n\n if (node) {\n nodes.push(node);\n }\n\n projectableNodes[match] = nodes;\n found = true;\n }\n\n return found ? projectableNodes : undefined;\n}\n\nfunction parseSlots(slots: unknown, document: Document): Node[] {\n const html =\n slots && typeof slots === 'object'\n ? Object.values(slots).join('')\n : String(slots ?? '');\n\n if (!html) {\n return [];\n }\n\n const template = document.createElement('template');\n template.innerHTML = html;\n\n return Array.from(template.content.childNodes);\n}\n\nfunction matches(node: Node, selector: string): boolean {\n if (node.nodeType !== ELEMENT_NODE) {\n return false;\n }\n\n const element = node as Element;\n const projectAs = element.getAttribute('ngProjectAs');\n\n // As in Angular, `ngProjectAs` replaces the element's own selector and is\n // compared structurally against the `select` list.\n if (projectAs !== null) {\n const [alias] = parseSelectorList(projectAs);\n return parseSelectorList(selector).some((candidate) =>\n isSameSelector(alias, candidate),\n );\n }\n\n try {\n return element.matches(selector);\n } catch {\n // `ngContentSelectors` may contain selectors that `matches()` rejects.\n return false;\n }\n}\n"],"mappings":";;AAGA,IAAM,eAAe;AACrB,IAAM,YAAY;AAClB,IAAM,eAAe;AACrB,IAAM,eAAe;AAErB,IAAM,gBAAgB;;;;;;;;;;;;AAatB,SAAgB,sBACd,QACA,OACA,UACsB;CACtB,MAAM,YAAY,OAAO;AAEzB,KAAI,CAAC,UAAU,OACb;CAGF,MAAM,mBAA6B,UAAU,UAAU,EAAE,CAAC;CAE1D,MAAM,gBAAgB,UAAU,YAAY,IAAI;AAEhD,MAAK,MAAM,QAAQ,WAAW,OAAO,SAAS,EAAE;AAG9C,MAAI,KAAK,aAAa,aAAa,CAAC,KAAK,aAAa,MAAM,CAC1D;E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AAM,OACJ,SAAS,OAAO,UAAU,WACtB,OAAO,OAAO,MAAM,CAAC,KAAK,GAAG,GAC7B,OAAO,SAAS,GAAG;AAEzB,KAAI,CAAC,KACH,QAAO,EAAE;CAGX,MAAM,WAAW,SAAS,cAAc,WAAW;AACnD,UAAS,YAAY;AAErB,QAAO,MAAM,KAAK,SAAS,QAAQ,WAAW;;AAGhD,SAAS,QAAQ,MAAY,UAA2B;AACtD,KAAI,KAAK,aAAa,aACpB,QAAO;CAGT,MAAM,UAAU;CAChB,MAAM,YAAY,QAAQ,aAAa,cAAc;AAIrD,KAAI,cAAc,MAAM;EACtB,MAAM,CAAC,SAAS,kBAAkB,UAAU;AAC5C,SAAO,kBAAkB,SAAS,CAAC,MAAM,cACvC,eAAe,OAAO,UAAU,CACjC;;AAGH,KAAI;AACF,SAAO,QAAQ,QAAQ,SAAS;SAC1B;AAEN,SAAO"}
1
+ {"version":3,"file":"projection.js","names":[],"sources":["../../src/projection.ts"],"sourcesContent":["import type { ComponentMirror } from '@angular/core';\nimport { isSameSelector, parseSelectorList } from './selector.ts';\n\nconst ELEMENT_NODE = 1;\nconst TEXT_NODE = 3;\nconst COMMENT_NODE = 8;\nconst SHOW_COMMENT = 128;\n\nconst MARKER_PREFIX = 'analog-slot:';\n\n/**\n * Distributes the HTML Astro rendered for the component's slots across the\n * component's `<ng-content>` slots, using Angular's own selector semantics.\n *\n * The result is indexed to match `mirror.ngContentSelectors`. Angular does not\n * apply `select` matching to `projectableNodes`, so the matching happens here.\n * @param mirror The component mirror, to read the `ng-content` selectors\n * @param slots The slot HTML passed by Astro, keyed by slot name\n * @param document The document the component is rendered into\n * @returns The nodes to project, or `undefined` when the component has no `ng-content`\n */\nexport function buildProjectableNodes(\n mirror: ComponentMirror<unknown>,\n slots: unknown,\n document: Document,\n): Node[][] | undefined {\n const selectors = mirror.ngContentSelectors;\n\n if (!selectors.length) {\n return undefined;\n }\n\n const projectableNodes: Node[][] = selectors.map(() => []);\n // As in Angular, unmatched content goes to the last default slot.\n const wildcardIndex = selectors.lastIndexOf('*');\n\n for (const node of parseSlots(slots, document)) {\n // Angular drops whitespace-only text nodes between elements at compile\n // time, so projecting them would only suppress `ng-content` fallbacks.\n if (node.nodeType === TEXT_NODE && !node.textContent?.trim()) {\n continue;\n }\n\n const matched = selectors.findIndex(\n (selector) => selector !== '*' && matches(node, selector),\n );\n const target = matched > -1 ? matched : wildcardIndex;\n\n if (target > -1) {\n projectableNodes[target].push(node);\n }\n }\n\n return projectableNodes;\n}\n\n/**\n * Wraps each non-empty slot in comment markers, so the client can find the\n * server-rendered nodes again when hydrating. Angular reuses the DOM during\n * hydration, so it must be handed those nodes rather than freshly parsed ones.\n * @param projectableNodes The distributed nodes, see `buildProjectableNodes`\n * @param appId The island's APP_ID, to keep markers apart from nested islands\n * @param document The document the component is rendered into\n */\nexport function markProjectableNodes(\n projectableNodes: Node[][],\n appId: string,\n document: Document,\n): Node[][] {\n return projectableNodes.map((nodes, index) =>\n nodes.length\n ? [\n document.createComment(`${MARKER_PREFIX}${appId}:${index}`),\n ...nodes,\n document.createComment(`/${MARKER_PREFIX}${appId}:${index}`),\n ]\n : nodes,\n );\n}\n\n/**\n * Collects the server-rendered projected nodes from the host element using the\n * markers added by `markProjectableNodes`.\n * @returns The nodes per slot, or `undefined` when the host carries no markers\n */\nexport function collectProjectedNodes(\n hostElement: Element,\n mirror: ComponentMirror<unknown>,\n appId: string,\n): Node[][] | undefined {\n const selectors = mirror.ngContentSelectors;\n\n if (!selectors.length) {\n return undefined;\n }\n\n const projectableNodes: Node[][] = selectors.map(() => []);\n const walker = hostElement.ownerDocument.createTreeWalker(\n hostElement,\n SHOW_COMMENT,\n );\n let found = false;\n\n for (let start = walker.nextNode(); start; start = walker.nextNode()) {\n const match = start.textContent?.startsWith(`${MARKER_PREFIX}${appId}:`)\n ? Number(start.textContent.slice(`${MARKER_PREFIX}${appId}:`.length))\n : NaN;\n\n if (Number.isNaN(match) || match >= selectors.length) {\n continue;\n }\n\n const end = `/${MARKER_PREFIX}${appId}:${match}`;\n const nodes: Node[] = [start];\n let node = start.nextSibling;\n\n while (\n node &&\n !(node.nodeType === COMMENT_NODE && node.textContent === end)\n ) {\n nodes.push(node);\n node = node.nextSibling;\n }\n\n if (node) {\n nodes.push(node);\n }\n\n projectableNodes[match] = nodes;\n found = true;\n }\n\n return found ? projectableNodes : undefined;\n}\n\nfunction parseSlots(slots: unknown, document: Document): Node[] {\n const html =\n slots && typeof slots === 'object'\n ? Object.values(slots).join('')\n : String(slots ?? '');\n\n if (!html) {\n return [];\n }\n\n const template = document.createElement('template');\n template.innerHTML = html;\n\n return Array.from(template.content.childNodes);\n}\n\nfunction matches(node: Node, selector: string): boolean {\n if (node.nodeType !== ELEMENT_NODE) {\n return false;\n }\n\n const element = node as Element;\n const projectAs = element.getAttribute('ngProjectAs');\n\n // As in Angular, `ngProjectAs` replaces the element's own selector and is\n // compared structurally against the `select` list.\n if (projectAs !== null) {\n const [alias] = parseSelectorList(projectAs);\n return parseSelectorList(selector).some((candidate) =>\n isSameSelector(alias, candidate),\n );\n }\n\n try {\n return element.matches(selector);\n } catch {\n // `ngContentSelectors` may contain selectors that `matches()` rejects.\n return false;\n }\n}\n"],"mappings":";;AAGA,IAAM,eAAe;AACrB,IAAM,YAAY;AAClB,IAAM,eAAe;AACrB,IAAM,eAAe;AAErB,IAAM,gBAAgB;;;;;;;;;;;;AAatB,SAAgB,sBACd,QACA,OACA,UACsB;CACtB,MAAM,YAAY,OAAO;CAEzB,IAAI,CAAC,UAAU,QACb;CAGF,MAAM,mBAA6B,UAAU,UAAU,CAAC,CAAC;CAEzD,MAAM,gBAAgB,UAAU,YAAY,GAAG;CAE/C,KAAK,MAAM,QAAQ,WAAW,OAAO,QAAQ,GAAG;EAG9C,IAAI,KAAK,aAAa,aAAa,CAAC,KAAK,aAAa,KAAK,GACzD;EAGF,MAAM,UAAU,UAAU,WACvB,aAAa,aAAa,OAAO,QAAQ,MAAM,QAAQ,CAC1D;EACA,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AC,CAAC,KAAK,EAAE,IAC5B,OAAO,SAAS,EAAE;CAExB,IAAI,CAAC,MACH,OAAO,CAAC;CAGV,MAAM,WAAW,SAAS,cAAc,UAAU;CAClD,SAAS,YAAY;CAErB,OAAO,MAAM,KAAK,SAAS,QAAQ,UAAU;AAC/C;AAEA,SAAS,QAAQ,MAAY,UAA2B;CACtD,IAAI,KAAK,aAAa,cACpB,OAAO;CAGT,MAAM,UAAU;CAChB,MAAM,YAAY,QAAQ,aAAa,aAAa;CAIpD,IAAI,cAAc,MAAM;EACtB,MAAM,CAAC,SAAS,kBAAkB,SAAS;EAC3C,OAAO,kBAAkB,QAAQ,CAAC,CAAC,MAAM,cACvC,eAAe,OAAO,SAAS,CACjC;CACF;CAEA,IAAI;EACF,OAAO,QAAQ,QAAQ,QAAQ;CACjC,QAAQ;EAEN,OAAO;CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"selector.js","names":[],"sources":["../../src/selector.ts"],"sourcesContent":["/**\n * A CSS selector in the shape Angular's compiler uses for `ng-content` and\n * `ngProjectAs` matching. Ported from `CssSelector` in `@angular/compiler`.\n */\nexport interface ParsedSelector {\n element: string;\n attrs: [string, string][];\n classNames: string[];\n notSelectors: ParsedSelector[];\n}\n\nconst SELECTOR_REGEXP = new RegExp(\n '(\\\\:not\\\\()|' + // 1: \":not(\"\n '(([\\\\.\\\\#]?)[-\\\\w]+)|' + // 2: \"tag\"; 3: \".\"/\"#\"\n '(?:\\\\[([-.\\\\w*\\\\\\\\$]+)(?:=([\"\\']?)([^\\\\]\"\\']*)\\\\5)?\\\\])|' + // 4: attribute; 5: quote; 6: value\n '(\\\\))|' + // 7: \")\"\n '(\\\\s*,\\\\s*)', // 8: \",\"\n 'g',\n);\n\nconst NOT = 1;\nconst TAG = 2;\nconst PREFIX = 3;\nconst ATTRIBUTE = 4;\nconst ATTRIBUTE_VALUE = 6;\nconst NOT_END = 7;\nconst SEPARATOR = 8;\n\nfunction createSelector(): ParsedSelector {\n return { element: '', attrs: [], classNames: [], notSelectors: [] };\n}\n\nexport function parseSelectorList(selector: string): ParsedSelector[] {\n const results: ParsedSelector[] = [];\n let cssSelector = createSelector();\n let current = cssSelector;\n let inNot = false;\n let match: RegExpExecArray | null;\n\n const regexp = new RegExp(SELECTOR_REGEXP.source, 'g');\n\n while ((match = regexp.exec(selector))) {\n if (match[NOT]) {\n inNot = true;\n current = createSelector();\n cssSelector.notSelectors.push(current);\n }\n\n const tag = match[TAG];\n if (tag) {\n const prefix = match[PREFIX];\n if (prefix === '#') {\n current.attrs.push(['id', tag.slice(1)]);\n } else if (prefix === '.') {\n current.classNames.push(tag.slice(1).toLowerCase());\n } else {\n current.element = tag;\n }\n }\n\n const attribute = match[ATTRIBUTE];\n if (attribute) {\n current.attrs.push([attribute, match[ATTRIBUTE_VALUE] ?? '']);\n }\n\n if (match[NOT_END]) {\n inNot = false;\n current = cssSelector;\n }\n\n if (match[SEPARATOR]) {\n results.push(cssSelector);\n cssSelector = current = createSelector();\n }\n }\n\n results.push(cssSelector);\n\n return results;\n}\n\n/**\n * Structural equality, matching how Angular compares an `ngProjectAs` selector\n * against the selectors of an `ng-content`.\n */\nexport function isSameSelector(a: ParsedSelector, b: ParsedSelector): boolean {\n return (\n normalizeElement(a.element) === normalizeElement(b.element) &&\n a.attrs.length === b.attrs.length &&\n a.attrs.every(([name, value], i) => {\n const [otherName, otherValue] = b.attrs[i];\n return name === otherName && value === otherValue;\n }) &&\n a.classNames.length === b.classNames.length &&\n a.classNames.every((name, i) => name === b.classNames[i]) &&\n a.notSelectors.length === b.notSelectors.length &&\n a.notSelectors.every((not, i) => isSameSelector(not, b.notSelectors[i]))\n );\n}\n\nfunction normalizeElement(element: string): string {\n return element === '*' ? '' : element;\n}\n"],"mappings":";AAWA,IAAM,kCAAkB,IAAI,OAC1B,8GAKA,IACD;AAED,IAAM,MAAM;AACZ,IAAM,MAAM;AACZ,IAAM,SAAS;AACf,IAAM,YAAY;AAClB,IAAM,kBAAkB;AACxB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AE,WAAW,OAAO,MAAM,MAAM,SAAS,EAAE,WAAW,GAAG,IACzD,EAAE,aAAa,WAAW,EAAE,aAAa,UACzC,EAAE,aAAa,OAAO,KAAK,MAAM,eAAe,KAAK,EAAE,aAAa,GAAG,CAAC;;AAI5E,SAAS,iBAAiB,SAAyB;AACjD,QAAO,YAAY,MAAM,KAAK"}
1
+ {"version":3,"file":"selector.js","names":[],"sources":["../../src/selector.ts"],"sourcesContent":["/**\n * A CSS selector in the shape Angular's compiler uses for `ng-content` and\n * `ngProjectAs` matching. Ported from `CssSelector` in `@angular/compiler`.\n */\nexport interface ParsedSelector {\n element: string;\n attrs: [string, string][];\n classNames: string[];\n notSelectors: ParsedSelector[];\n}\n\nconst SELECTOR_REGEXP = new RegExp(\n '(\\\\:not\\\\()|' + // 1: \":not(\"\n '(([\\\\.\\\\#]?)[-\\\\w]+)|' + // 2: \"tag\"; 3: \".\"/\"#\"\n '(?:\\\\[([-.\\\\w*\\\\\\\\$]+)(?:=([\"\\']?)([^\\\\]\"\\']*)\\\\5)?\\\\])|' + // 4: attribute; 5: quote; 6: value\n '(\\\\))|' + // 7: \")\"\n '(\\\\s*,\\\\s*)', // 8: \",\"\n 'g',\n);\n\nconst NOT = 1;\nconst TAG = 2;\nconst PREFIX = 3;\nconst ATTRIBUTE = 4;\nconst ATTRIBUTE_VALUE = 6;\nconst NOT_END = 7;\nconst SEPARATOR = 8;\n\nfunction createSelector(): ParsedSelector {\n return { element: '', attrs: [], classNames: [], notSelectors: [] };\n}\n\nexport function parseSelectorList(selector: string): ParsedSelector[] {\n const results: ParsedSelector[] = [];\n let cssSelector = createSelector();\n let current = cssSelector;\n let inNot = false;\n let match: RegExpExecArray | null;\n\n const regexp = new RegExp(SELECTOR_REGEXP.source, 'g');\n\n while ((match = regexp.exec(selector))) {\n if (match[NOT]) {\n inNot = true;\n current = createSelector();\n cssSelector.notSelectors.push(current);\n }\n\n const tag = match[TAG];\n if (tag) {\n const prefix = match[PREFIX];\n if (prefix === '#') {\n current.attrs.push(['id', tag.slice(1)]);\n } else if (prefix === '.') {\n current.classNames.push(tag.slice(1).toLowerCase());\n } else {\n current.element = tag;\n }\n }\n\n const attribute = match[ATTRIBUTE];\n if (attribute) {\n current.attrs.push([attribute, match[ATTRIBUTE_VALUE] ?? '']);\n }\n\n if (match[NOT_END]) {\n inNot = false;\n current = cssSelector;\n }\n\n if (match[SEPARATOR]) {\n results.push(cssSelector);\n cssSelector = current = createSelector();\n }\n }\n\n results.push(cssSelector);\n\n return results;\n}\n\n/**\n * Structural equality, matching how Angular compares an `ngProjectAs` selector\n * against the selectors of an `ng-content`.\n */\nexport function isSameSelector(a: ParsedSelector, b: ParsedSelector): boolean {\n return (\n normalizeElement(a.element) === normalizeElement(b.element) &&\n a.attrs.length === b.attrs.length &&\n a.attrs.every(([name, value], i) => {\n const [otherName, otherValue] = b.attrs[i];\n return name === otherName && value === otherValue;\n }) &&\n a.classNames.length === b.classNames.length &&\n a.classNames.every((name, i) => name === b.classNames[i]) &&\n a.notSelectors.length === b.notSelectors.length &&\n a.notSelectors.every((not, i) => isSameSelector(not, b.notSelectors[i]))\n );\n}\n\nfunction normalizeElement(element: string): string {\n return element === '*' ? '' : element;\n}\n"],"mappings":";AAWA,IAAM,kCAAkB,IAAI,OAC1B,8GAKA,GACF;AAEA,IAAM,MAAM;AACZ,IAAM,MAAM;AACZ,IAAM,SAAS;AACf,IAAM,YAAY;AAClB,IAAM,kBAAkB;AACxB,IAAM,UAAU;AAChB,IAAM,YAAY;AAElB,SAAS,iBAAiC;CACxC,OAAO;EAAE,SAAS;EAAI,OAAO,CAAC;EAAG,YAAY,CAAC;EAAG,cAAc,CAAC;CAAE;AACpE;AAEA,SAAgB,kBAAkB,UAAoC;CACpE,MAAM,UAA4B,CAAC;CACnC,IAAI,cAAc,eAAe;CACjC,IAAI,UAAU;CAEd,IAAI;CAEJ,MAAM,SAAS,IAAI,OAAO,gBAAgB,QAAQ,GAAG;CAErD,OAAQ,QAAQ,OAA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{
45
45
  },
46
46
  ...Component.renderProviders || []
47
47
  ] }, context);
48
- registerRootComponent(appRef, createComponent(Component, {
48
+ const componentRef = createComponent(Component, {
49
49
  environmentInjector: appRef.injector,
50
50
  hostElement,
51
51
  projectableNodes,
52
52
  bindings: createInputBindings(mirror, props)
53
- }));
53
+ });
54
+ registerRootComponent(appRef, componentRef);
54
55
  return appRef;
55
56
  };
56
57
  const html = await renderApplication(bootstrap, { document });
@@ -1 +1 @@
1
- {"version":3,"file":"server-ngh.js","names":[],"sources":["../../src/server-ngh.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\n\nimport type { EnvironmentProviders, Provider, Type } from '@angular/core';\nimport {\n createComponent,\n reflectComponentType,\n provideZonelessChangeDetection,\n DOCUMENT,\n APP_ID,\n} from '@angular/core';\nimport {\n provideServerRendering,\n renderApplication,\n ɵSERVER_CONTEXT,\n platformServer,\n} from '@angular/platform-server';\nimport {\n createApplication,\n type HydrationFeature,\n type HydrationFeatureKind,\n provideClientHydration,\n type BootstrapContext,\n} from '@angular/platform-browser';\nimport type { AstroComponentMetadata, SSRLoadedRendererValue } from 'astro';\nimport { getContext, incrementId, type RendererContext } from './context.ts';\nimport { ID_PROP_NAME } from './id.ts';\nimport {\n createInputBindings,\n getComponentElementTag,\n registerRootComponent,\n} from './create-component.ts';\nimport { buildProjectableNodes, markProjectableNodes } from './projection.ts';\n\nconst require = createRequire(import.meta.url);\nlet jsActionContractScript: string | undefined = undefined;\n\nconst HYDRATION_SCRIPT_ID = 'ng-event-dispatch-contract';\n\nfunction getHydrationScript(): string {\n jsActionContractScript ??=\n `<script type=\"text/javascript\" id=\"${HYDRATION_SCRIPT_ID}\">` +\n readFileSync(\n require.resolve('@angular/core/event-dispatch-contract.min.js'),\n 'utf-8',\n ) +\n '</script>';\n return jsActionContractScript;\n}\n\nasync function check(Component: Type<unknown>) {\n return !!reflectComponentType(Component);\n}\n\nasync function renderToStaticMarkup(\n this: RendererContext,\n Component: Type<unknown> & {\n renderProviders?: (Provider | EnvironmentProviders)[];\n hydrationFeatures?: () => HydrationFeature<HydrationFeatureKind>[];\n },\n props: Record<string, unknown>,\n children: unknown,\n metadata?: AstroComponentMetadata,\n) {\n const mirror = reflectComponentType(Component);\n\n if (!mirror) {\n // This should be unreachable: the `check` function verifies that Component is an Angular component.\n throw new Error(\n (metadata?.displayName || '<unknown component>') +\n ' is not an Angular component',\n );\n }\n\n const elementTag = getComponentElementTag(mirror);\n const ngAppId = props?.[ID_PROP_NAME] || incrementId(getContext(this.result));\n\n // When the platform ref is destroyed, it will reset ngServerMode back to `undefined` if it was not defined when it is\n // created. See https://github.com/angular/angular/blob/2ce0e98f79a02ddc550d00580e8e232cfed3bfb2/packages/platform-server/src/server.ts#L138\n globalThis.ngServerMode = true;\n\n const platformRef = platformServer();\n const document = platformRef.injector.get(DOCUMENT);\n\n // Incremental hydration requires the event dispatch script to be present.\n document.body.innerHTML = `${getHydrationScript()}<${elementTag} ${ID_PROP_NAME}=\"${ngAppId}\"></${elementTag}>`;\n\n const hostElement = document.querySelector(elementTag) as Element;\n let projectableNodes = buildProjectableNodes(mirror, children, document);\n\n if (metadata?.hydrate && projectableNodes) {\n projectableNodes = markProjectableNodes(\n projectableNodes,\n String(ngAppId),\n document,\n );\n }\n\n const bootstrap = async (context?: BootstrapContext) => {\n const appRef = await createApplication(\n {\n providers: [\n provideServerRendering(),\n { provide: ɵSERVER_CONTEXT, useValue: 'analog' },\n provideZonelessChangeDetection(),\n metadata?.hydrate\n ? provideClientHydration(...(Component.hydrationFeatures?.() || []))\n : [],\n {\n provide: APP_ID,\n useValue: ngAppId,\n },\n ...(Component.renderProviders || []),\n ],\n },\n context,\n );\n\n const componentRef = createComponent(Component, {\n environmentInjector: appRef.injector,\n hostElement,\n projectableNodes,\n bindings: createInputBindings(mirror, props),\n });\n\n registerRootComponent(appRef, componentRef);\n\n return appRef;\n };\n\n const html = await renderApplication(bootstrap, {\n document,\n });\n\n document.documentElement.innerHTML = html;\n let styleTags = '';\n\n document.head.childNodes.forEach((node) => {\n if (node.nodeName === 'STYLE') {\n styleTags += (node as HTMLElement).outerHTML;\n }\n });\n\n // Remove the hydration script, so only one is present on the page.\n document.getElementById(HYDRATION_SCRIPT_ID)?.remove();\n\n const correctedHtml = styleTags + document.body.innerHTML;\n\n platformRef.destroy();\n\n return { html: correctedHtml };\n}\n\nexport default {\n check,\n renderToStaticMarkup,\n renderHydrationScript: () => getHydrationScript(),\n} satisfies SSRLoadedRendererValue;\n"],"mappings":";;;;;;;;;;AAkCA,IAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAC9C,IAAI,yBAA6C,KAAA;AAEjD,IAAM,sBAAsB;AAE5B,SAAS,qBAA6B;AACpC,4BACE,sCAAsC,oBAAoB,MAC1D,aACE,QAAQ,QAAQ,+CAA+C,EAC/D,QACD,GACD;AACF,QAAO;;AAGT,eAAe,MAAM,WAA0B;AAC7C,QAAO,CAAC,CAAC,qBAAqB,UAAU;;AAG1C,eAAe,qBAEb,WAIA,OACA,UACA,UACA;CACA,MAAM,SAAS,qBAAqB,UAAU;AAE9C,KAAI,CAAC,OAEH,OAAM,IAAI,OACP,UAAU,eAAe,yBACxB,+BACH;CAGH,MAAM,aAAa,uBAAuB,OAAO;CACjD,MAAM,UAAU,QAAA,qBAAyB,YAAY,WAAW,KAAK,OAAO,CAAC;AAI7E,YAAW,eAAe;CAE1B,MAAM,cAAc,gBAAgB;CACpC,MAAM,WAAW,YAAY,SAAS,IAAI,SAAS;AAGnD,UAAS,KAAK,YAAY,GAAG,oBAAoB,CAAC,GAAG,WAAW,GAAG,aAAa,IAAI,QAAQ,MAAM,WAAW;CAE7G,MAAM,cAAc,SAAS,cAAc,WAAW;CACtD,IAAI,mBAAmB,sBAAsB,QAAQ,UAAU,SAAS;AAExE,KAAI,UAAU,WAAW,iBACvB,oBAAmB,qBACjB,kBACA,OAAO,QAAQ,EACf,SACD;CAGH,MAAM,YAAY,OAAO,YAA+B;EACtD,MAAM,SAAS,MAAM,kBACnB,EACE,WAAW;GACT,wBAAwB;GACxB;IAAE,SAAS;IAAiB,UAAU;IAAU;GAChD,gCAAgC;GAChC,UAAU,UACN,uBAAuB,GAAI,UAAU,qBAAqB,IAAI,EAAE,CAAE,GAClE,EAAE;GACN;IACE,SAAS;IACT,UAAU;IACX;GACD,GAAI,UAAU,mBAAmB,EAAE;GACpC,EACF,EACD,QACD;AASD,wBAAsB,QAPD,gBAAgB,WAAW;GAC9C,qBAAqB,OAAO;GAC5B;GACA;GACA,UAAU,oBAAoB,QAAQ,MAAM;GAC7C,CAAC,CAEyC;AAE3C,SAAO;;CAGT,MAAM,OAAO,MAAM,kBAAkB,WAAW,EAC9C,UACD,CAAC;AAEF,UAAS,gBAAgB,YAAY;CACrC,IAAI,YAAY;AAEhB,UAAS,KAAK,WAAW,SAAS,SAAS;AACzC,MAAI,KAAK,aAAa,QACpB,cAAc,KAAqB;GAErC;AAGF,UAAS,eAAe,oBAAoB,EAAE,QAAQ;CAEtD,MAAM,gBAAgB,YAAY,SAAS,KAAK;AAEhD,aAAY,SAAS;AAErB,QAAO,EAAE,MAAM,eAAe;;AAGhC,IAAA,qBAAe;CACb;CACA;CACA,6BAA6B,oBAAoB;CAClD"}
1
+ {"version":3,"file":"server-ngh.js","names":[],"sources":["../../src/server-ngh.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\n\nimport type { EnvironmentProviders, Provider, Type } from '@angular/core';\nimport {\n createComponent,\n reflectComponentType,\n provideZonelessChangeDetection,\n DOCUMENT,\n APP_ID,\n} from '@angular/core';\nimport {\n provideServerRendering,\n renderApplication,\n ɵSERVER_CONTEXT,\n platformServer,\n} from '@angular/platform-server';\nimport {\n createApplication,\n type HydrationFeature,\n type HydrationFeatureKind,\n provideClientHydration,\n type BootstrapContext,\n} from '@angular/platform-browser';\nimport type { AstroComponentMetadata, SSRLoadedRendererValue } from 'astro';\nimport { getContext, incrementId, type RendererContext } from './context.ts';\nimport { ID_PROP_NAME } from './id.ts';\nimport {\n createInputBindings,\n getComponentElementTag,\n registerRootComponent,\n} from './create-component.ts';\nimport { buildProjectableNodes, markProjectableNodes } from './projection.ts';\n\nconst require = createRequire(import.meta.url);\nlet jsActionContractScript: string | undefined = undefined;\n\nconst HYDRATION_SCRIPT_ID = 'ng-event-dispatch-contract';\n\nfunction getHydrationScript(): string {\n jsActionContractScript ??=\n `<script type=\"text/javascript\" id=\"${HYDRATION_SCRIPT_ID}\">` +\n readFileSync(\n require.resolve('@angular/core/event-dispatch-contract.min.js'),\n 'utf-8',\n ) +\n '</script>';\n return jsActionContractScript;\n}\n\nasync function check(Component: Type<unknown>) {\n return !!reflectComponentType(Component);\n}\n\nasync function renderToStaticMarkup(\n this: RendererContext,\n Component: Type<unknown> & {\n renderProviders?: (Provider | EnvironmentProviders)[];\n hydrationFeatures?: () => HydrationFeature<HydrationFeatureKind>[];\n },\n props: Record<string, unknown>,\n children: unknown,\n metadata?: AstroComponentMetadata,\n) {\n const mirror = reflectComponentType(Component);\n\n if (!mirror) {\n // This should be unreachable: the `check` function verifies that Component is an Angular component.\n throw new Error(\n (metadata?.displayName || '<unknown component>') +\n ' is not an Angular component',\n );\n }\n\n const elementTag = getComponentElementTag(mirror);\n const ngAppId = props?.[ID_PROP_NAME] || incrementId(getContext(this.result));\n\n // When the platform ref is destroyed, it will reset ngServerMode back to `undefined` if it was not defined when it is\n // created. See https://github.com/angular/angular/blob/2ce0e98f79a02ddc550d00580e8e232cfed3bfb2/packages/platform-server/src/server.ts#L138\n globalThis.ngServerMode = true;\n\n const platformRef = platformServer();\n const document = platformRef.injector.get(DOCUMENT);\n\n // Incremental hydration requires the event dispatch script to be present.\n document.body.innerHTML = `${getHydrationScript()}<${elementTag} ${ID_PROP_NAME}=\"${ngAppId}\"></${elementTag}>`;\n\n const hostElement = document.querySelector(elementTag) as Element;\n let projectableNodes = buildProjectableNodes(mirror, children, document);\n\n if (metadata?.hydrate && projectableNodes) {\n projectableNodes = markProjectableNodes(\n projectableNodes,\n String(ngAppId),\n document,\n );\n }\n\n const bootstrap = async (context?: BootstrapContext) => {\n const appRef = await createApplication(\n {\n providers: [\n provideServerRendering(),\n { provide: ɵSERVER_CONTEXT, useValue: 'analog' },\n provideZonelessChangeDetection(),\n metadata?.hydrate\n ? provideClientHydration(...(Component.hydrationFeatures?.() || []))\n : [],\n {\n provide: APP_ID,\n useValue: ngAppId,\n },\n ...(Component.renderProviders || []),\n ],\n },\n context,\n );\n\n const componentRef = createComponent(Component, {\n environmentInjector: appRef.injector,\n hostElement,\n projectableNodes,\n bindings: createInputBindings(mirror, props),\n });\n\n registerRootComponent(appRef, componentRef);\n\n return appRef;\n };\n\n const html = await renderApplication(bootstrap, {\n document,\n });\n\n document.documentElement.innerHTML = html;\n let styleTags = '';\n\n document.head.childNodes.forEach((node) => {\n if (node.nodeName === 'STYLE') {\n styleTags += (node as HTMLElement).outerHTML;\n }\n });\n\n // Remove the hydration script, so only one is present on the page.\n document.getElementById(HYDRATION_SCRIPT_ID)?.remove();\n\n const correctedHtml = styleTags + document.body.innerHTML;\n\n platformRef.destroy();\n\n return { html: correctedHtml };\n}\n\nexport default {\n check,\n renderToStaticMarkup,\n renderHydrationScript: () => getHydrationScript(),\n} satisfies SSRLoadedRendererValue;\n"],"mappings":";;;;;;;;;;AAkCA,IAAM,UAAU,cAAc,YAAY,GAAG;AAC7C,IAAI,yBAA6C,KAAA;AAEjD,IAAM,sBAAsB;AAE5B,SAAS,qBAA6B;CACpC,2BACE,sCAAsC,oBAAoB,MAC1D,aACE,QAAQ,QAAQ,8CAA8C,GAC9D,OACF,IACA;CACF,OAAO;AACT;AAEA,eAAe,MAAM,WAA0B;CAC7C,OAAO,CAAC,CAAC,qBAAqB,SAAS;AACzC;AAEA,eAAe,qBAEb,WAIA,OACA,UACA,UACA;CACA,MAAM,SAAS,qBAAqB,SAAS;CAE7C,IAAI,CAAC,QAEH,MAAM,IAAI,OACP,UAAU,eAAe,yBACxB,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;AAC/B;AAEA,IAAA,qBAAe;CACb;CACA;CACA,6BAA6B,mBAAmB;AAClD"}
package/src/server.js CHANGED
@@ -26,12 +26,13 @@ async function renderToStaticMarkup(Component, props, children) {
26
26
  provideZonelessChangeDetection(),
27
27
  ...Component.renderProviders || []
28
28
  ] }, context);
29
- registerRootComponent(appRef, createComponent(Component, {
29
+ const componentRef = createComponent(Component, {
30
30
  environmentInjector: appRef.injector,
31
31
  hostElement,
32
32
  projectableNodes,
33
33
  bindings: createInputBindings(mirror, props)
34
- }));
34
+ });
35
+ registerRootComponent(appRef, componentRef);
35
36
  return appRef;
36
37
  };
37
38
  const html = await renderApplication(bootstrap, { document });
package/src/server.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":[],"sources":["../../src/server.ts"],"sourcesContent":["import type {\n EnvironmentProviders,\n Provider,\n ɵComponentType as ComponentType,\n} from '@angular/core';\nimport {\n createComponent,\n reflectComponentType,\n provideZonelessChangeDetection,\n DOCUMENT,\n} from '@angular/core';\nimport {\n provideServerRendering,\n renderApplication,\n ɵSERVER_CONTEXT,\n platformServer,\n} from '@angular/platform-server';\nimport {\n createApplication,\n type BootstrapContext,\n} from '@angular/platform-browser';\nimport {\n createInputBindings,\n getComponentElementTag,\n registerRootComponent,\n} from './create-component.ts';\nimport { buildProjectableNodes } from './projection.ts';\n\nfunction check(\n Component: ComponentType<unknown>,\n _props: Record<string, unknown>,\n _children: unknown,\n): boolean {\n return !!reflectComponentType(Component);\n}\n\nasync function renderToStaticMarkup(\n Component: ComponentType<unknown> & {\n renderProviders: (Provider | EnvironmentProviders)[];\n },\n props: Record<string, unknown>,\n children: unknown,\n): Promise<{ html: string }> {\n const mirror = reflectComponentType(Component);\n\n if (!mirror) {\n // This should be unreachable: the `check` function verifies that Component is an Angular component.\n throw new Error(Component.name + ' is not an Angular component');\n }\n\n const elementTag = getComponentElementTag(mirror);\n\n const platformRef = platformServer();\n const document = platformRef.injector.get(DOCUMENT);\n document.body.innerHTML = `<${elementTag}></${elementTag}>`;\n\n const hostElement = document.querySelector(elementTag) as Element;\n const projectableNodes = buildProjectableNodes(mirror, children, document);\n\n const bootstrap = async (context?: BootstrapContext) => {\n const appRef = await createApplication(\n {\n providers: [\n provideServerRendering(),\n { provide: ɵSERVER_CONTEXT, useValue: 'analog' },\n provideZonelessChangeDetection(),\n ...(Component.renderProviders || []),\n ],\n },\n context,\n );\n\n const componentRef = createComponent(Component, {\n environmentInjector: appRef.injector,\n hostElement,\n projectableNodes,\n bindings: createInputBindings(mirror, props),\n });\n\n registerRootComponent(appRef, componentRef);\n\n return appRef;\n };\n\n const html = await renderApplication(bootstrap, {\n document,\n });\n\n document.documentElement.innerHTML = html;\n let styleTags = '';\n\n document.head.childNodes.forEach((node) => {\n if (node.nodeName === 'STYLE') {\n styleTags += (node as HTMLElement).outerHTML;\n }\n });\n\n const correctedHtml = styleTags + document.body.innerHTML;\n\n platformRef.destroy();\n\n return { html: correctedHtml };\n}\n\nconst renderer: {\n check: typeof check;\n renderToStaticMarkup: typeof renderToStaticMarkup;\n} = {\n check: check,\n renderToStaticMarkup: renderToStaticMarkup,\n};\nexport default renderer;\n"],"mappings":";;;;;;AA4BA,SAAS,MACP,WACA,QACA,WACS;AACT,QAAO,CAAC,CAAC,qBAAqB,UAAU;;AAG1C,eAAe,qBACb,WAGA,OACA,UAC2B;CAC3B,MAAM,SAAS,qBAAqB,UAAU;AAE9C,KAAI,CAAC,OAEH,OAAM,IAAI,MAAM,UAAU,OAAO,+BAA+B;CAGlE,MAAM,aAAa,uBAAuB,OAAO;CAEjD,MAAM,cAAc,gBAAgB;CACpC,MAAM,WAAW,YAAY,SAAS,IAAI,SAAS;AACnD,UAAS,KAAK,YAAY,IAAI,WAAW,KAAK,WAAW;CAEzD,MAAM,cAAc,SAAS,cAAc,WAAW;CACtD,MAAM,mBAAmB,sBAAsB,QAAQ,UAAU,SAAS;CAE1E,MAAM,YAAY,OAAO,YAA+B;EACtD,MAAM,SAAS,MAAM,kBACnB,EACE,WAAW;GACT,wBAAwB;GACxB;IAAE,SAAS;IAAiB,UAAU;IAAU;GAChD,gCAAgC;GAChC,GAAI,UAAU,mBAAmB,EAAE;GACpC,EACF,EACD,QACD;AASD,wBAAsB,QAPD,gBAAgB,WAAW;GAC9C,qBAAqB,OAAO;GAC5B;GACA;GACA,UAAU,oBAAoB,QAAQ,MAAM;GAC7C,CAAC,CAEyC;AAE3C,SAAO;;CAGT,MAAM,OAAO,MAAM,kBAAkB,WAAW,EAC9C,UACD,CAAC;AAEF,UAAS,gBAAgB,YAAY;CACrC,IAAI,YAAY;AAEhB,UAAS,KAAK,WAAW,SAAS,SAAS;AACzC,MAAI,KAAK,aAAa,QACpB,cAAc,KAAqB;GAErC;CAEF,MAAM,gBAAgB,YAAY,SAAS,KAAK;AAEhD,aAAY,SAAS;AAErB,QAAO,EAAE,MAAM,eAAe;;AAGhC,IAAM,WAGF;CACK;CACe;CACvB"}
1
+ {"version":3,"file":"server.js","names":[],"sources":["../../src/server.ts"],"sourcesContent":["import type {\n EnvironmentProviders,\n Provider,\n ɵComponentType as ComponentType,\n} from '@angular/core';\nimport {\n createComponent,\n reflectComponentType,\n provideZonelessChangeDetection,\n DOCUMENT,\n} from '@angular/core';\nimport {\n provideServerRendering,\n renderApplication,\n ɵSERVER_CONTEXT,\n platformServer,\n} from '@angular/platform-server';\nimport {\n createApplication,\n type BootstrapContext,\n} from '@angular/platform-browser';\nimport {\n createInputBindings,\n getComponentElementTag,\n registerRootComponent,\n} from './create-component.ts';\nimport { buildProjectableNodes } from './projection.ts';\n\nfunction check(\n Component: ComponentType<unknown>,\n _props: Record<string, unknown>,\n _children: unknown,\n): boolean {\n return !!reflectComponentType(Component);\n}\n\nasync function renderToStaticMarkup(\n Component: ComponentType<unknown> & {\n renderProviders: (Provider | EnvironmentProviders)[];\n },\n props: Record<string, unknown>,\n children: unknown,\n): Promise<{ html: string }> {\n const mirror = reflectComponentType(Component);\n\n if (!mirror) {\n // This should be unreachable: the `check` function verifies that Component is an Angular component.\n throw new Error(Component.name + ' is not an Angular component');\n }\n\n const elementTag = getComponentElementTag(mirror);\n\n const platformRef = platformServer();\n const document = platformRef.injector.get(DOCUMENT);\n document.body.innerHTML = `<${elementTag}></${elementTag}>`;\n\n const hostElement = document.querySelector(elementTag) as Element;\n const projectableNodes = buildProjectableNodes(mirror, children, document);\n\n const bootstrap = async (context?: BootstrapContext) => {\n const appRef = await createApplication(\n {\n providers: [\n provideServerRendering(),\n { provide: ɵSERVER_CONTEXT, useValue: 'analog' },\n provideZonelessChangeDetection(),\n ...(Component.renderProviders || []),\n ],\n },\n context,\n );\n\n const componentRef = createComponent(Component, {\n environmentInjector: appRef.injector,\n hostElement,\n projectableNodes,\n bindings: createInputBindings(mirror, props),\n });\n\n registerRootComponent(appRef, componentRef);\n\n return appRef;\n };\n\n const html = await renderApplication(bootstrap, {\n document,\n });\n\n document.documentElement.innerHTML = html;\n let styleTags = '';\n\n document.head.childNodes.forEach((node) => {\n if (node.nodeName === 'STYLE') {\n styleTags += (node as HTMLElement).outerHTML;\n }\n });\n\n const correctedHtml = styleTags + document.body.innerHTML;\n\n platformRef.destroy();\n\n return { html: correctedHtml };\n}\n\nconst renderer: {\n check: typeof check;\n renderToStaticMarkup: typeof renderToStaticMarkup;\n} = {\n check: check,\n renderToStaticMarkup: renderToStaticMarkup,\n};\nexport default renderer;\n"],"mappings":";;;;;;AA4BA,SAAS,MACP,WACA,QACA,WACS;CACT,OAAO,CAAC,CAAC,qBAAqB,SAAS;AACzC;AAEA,eAAe,qBACb,WAGA,OACA,UAC2B;CAC3B,MAAM,SAAS,qBAAqB,SAAS;CAE7C,IAAI,CAAC,QAEH,MAAM,IAAI,MAAM,UAAU,OAAO,8BAA8B;CAGjE,MAAM,aAAa,uBAAuB,MAAM;CAEhD,MAAM,cAAc,eAAe;CACnC,MAAM,WAAW,YAAY,SAAS,IAAI,QAAQ;CAClD,SAAS,KAAK,YAAY,IAAI,WAAW,KAAK,WAAW;CAEzD,MAAM,cAAc,SAAS,cAAc,UAAU;CACrD,MAAM,mBAAmB,sBAAsB,QAAQ,UAAU,QAAQ;CAEzE,MAAM,YAAY,OAAO,YAA+B;EACtD,MAAM,SAAS,MAAM,kBACnB,EACE,WAAW;GACT,uBAAuB;GACvB;IAAE,SAAS;IAAiB,UAAU;GAAS;GAC/C,+BAA+B;GAC/B,GAAI,UAAU,mBAAmB,CAAC;EACpC,EACF,GACA,OACF;EAEA,MAAM,eAAe,gBAAgB,WAAW;GAC9C,qBAAqB,OAAO;GAC5B;GACA;GACA,UAAU,oBAAoB,QAAQ,KAAK;EAC7C,CAAC;EAED,sBAAsB,QAAQ,YAAY;EAE1C,OAAO;CACT;CAEA,MAAM,OAAO,MAAM,kBAAkB,WAAW,EAC9C,SACF,CAAC;CAED,SAAS,gBAAgB,YAAY;CACrC,IAAI,YAAY;CAEhB,SAAS,KAAK,WAAW,SAAS,SAAS;EACzC,IAAI,KAAK,aAAa,SACpB,aAAc,KAAqB;CAEvC,CAAC;CAED,MAAM,gBAAgB,YAAY,SAAS,KAAK;CAEhD,YAAY,QAAQ;CAEpB,OAAO,EAAE,MAAM,cAAc;AAC/B;AAEA,IAAM,WAGF;CACK;CACe;AACxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"ssr-integrity.js","names":[],"sources":["../../src/ssr-integrity.ts"],"sourcesContent":["import {\n ɵCLIENT_RENDER_MODE_FLAG,\n ɵSSR_CONTENT_INTEGRITY_MARKER,\n} from '@angular/core';\n\nexport function ensureSsrIntegrityMarker(): void {\n // Insert Angular client hydration marker\n // See https://github.com/angular/angular/issues/67785\n if (\n document.body.firstChild?.nodeType !== Node.COMMENT_NODE ||\n document.body.firstChild.textContent !== ɵSSR_CONTENT_INTEGRITY_MARKER\n ) {\n document.body.prepend(\n document.createComment(ɵSSR_CONTENT_INTEGRITY_MARKER),\n );\n }\n\n if (!document.body.hasAttribute(ɵCLIENT_RENDER_MODE_FLAG)) {\n document.body.setAttribute(ɵCLIENT_RENDER_MODE_FLAG, '');\n }\n}\n"],"mappings":";;AAKA,SAAgB,2BAAiC;AAG/C,KACE,SAAS,KAAK,YAAY,aAAa,KAAK,gBAC5C,SAAS,KAAK,WAAW,gBAAgB,8BAEzC,UAAS,KAAK,QACZ,SAAS,cAAc,8BAA8B,CACtD;AAGH,KAAI,CAAC,SAAS,KAAK,aAAa,yBAAyB,CACvD,UAAS,KAAK,aAAa,0BAA0B,GAAG"}
1
+ {"version":3,"file":"ssr-integrity.js","names":[],"sources":["../../src/ssr-integrity.ts"],"sourcesContent":["import {\n ɵCLIENT_RENDER_MODE_FLAG,\n ɵSSR_CONTENT_INTEGRITY_MARKER,\n} from '@angular/core';\n\nexport function ensureSsrIntegrityMarker(): void {\n // Insert Angular client hydration marker\n // See https://github.com/angular/angular/issues/67785\n if (\n document.body.firstChild?.nodeType !== Node.COMMENT_NODE ||\n document.body.firstChild.textContent !== ɵSSR_CONTENT_INTEGRITY_MARKER\n ) {\n document.body.prepend(\n document.createComment(ɵSSR_CONTENT_INTEGRITY_MARKER),\n );\n }\n\n if (!document.body.hasAttribute(ɵCLIENT_RENDER_MODE_FLAG)) {\n document.body.setAttribute(ɵCLIENT_RENDER_MODE_FLAG, '');\n }\n}\n"],"mappings":";;AAKA,SAAgB,2BAAiC;CAG/C,IACE,SAAS,KAAK,YAAY,aAAa,KAAK,gBAC5C,SAAS,KAAK,WAAW,gBAAgB,+BAEzC,SAAS,KAAK,QACZ,SAAS,cAAc,6BAA6B,CACtD;CAGF,IAAI,CAAC,SAAS,KAAK,aAAa,wBAAwB,GACtD,SAAS,KAAK,aAAa,0BAA0B,EAAE;AAE3D"}
package/src/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["export function addOutputListener(\n analogId: string,\n outputName: string,\n callback: (...args: unknown[]) => unknown,\n eventListenerOptions: EventListenerOptions = {},\n): () => void {\n const observer = new MutationObserver((mutations) => {\n const foundTarget = mutations.find(\n (mutation) =>\n (mutation.target as HTMLElement).dataset?.['analogId'] === analogId,\n )?.target;\n\n if (foundTarget) {\n foundTarget.addEventListener(outputName, callback, eventListenerOptions);\n observer.disconnect();\n }\n });\n observer.observe(document.body, { attributes: true, subtree: true });\n\n return (): void => observer.disconnect();\n}\n"],"mappings":";AAAA,SAAgB,kBACd,UACA,YACA,UACA,uBAA6C,EAAE,EACnC;CACZ,MAAM,WAAW,IAAI,kBAAkB,cAAc;EACnD,MAAM,cAAc,UAAU,MAC3B,aACE,SAAS,OAAuB,UAAU,gBAAgB,SAC9D,EAAE;AAEH,MAAI,aAAa;AACf,eAAY,iBAAiB,YAAY,UAAU,qBAAqB;AACxE,YAAS,YAAY;;GAEvB;AACF,UAAS,QAAQ,SAAS,MAAM;EAAE,YAAY;EAAM,SAAS;EAAM,CAAC;AAEpE,cAAmB,SAAS,YAAY"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["export function addOutputListener(\n analogId: string,\n outputName: string,\n callback: (...args: unknown[]) => unknown,\n eventListenerOptions: EventListenerOptions = {},\n): () => void {\n const observer = new MutationObserver((mutations) => {\n const foundTarget = mutations.find(\n (mutation) =>\n (mutation.target as HTMLElement).dataset?.['analogId'] === analogId,\n )?.target;\n\n if (foundTarget) {\n foundTarget.addEventListener(outputName, callback, eventListenerOptions);\n observer.disconnect();\n }\n });\n observer.observe(document.body, { attributes: true, subtree: true });\n\n return (): void => observer.disconnect();\n}\n"],"mappings":";AAAA,SAAgB,kBACd,UACA,YACA,UACA,uBAA6C,CAAC,GAClC;CACZ,MAAM,WAAW,IAAI,kBAAkB,cAAc;EACnD,MAAM,cAAc,UAAU,MAC3B,aACE,SAAS,OAAuB,UAAU,gBAAgB,QAC/D,CAAC,EAAE;EAEH,IAAI,aAAa;GACf,YAAY,iBAAiB,YAAY,UAAU,oBAAoB;GACvE,SAAS,WAAW;EACtB;CACF,CAAC;CACD,SAAS,QAAQ,SAAS,MAAM;EAAE,YAAY;EAAM,SAAS;CAAK,CAAC;CAEnE,aAAmB,SAAS,WAAW;AACzC"}