@contentful/experiences-angular 0.2.0

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.
Files changed (79) hide show
  1. package/CHANGELOG.md +189 -0
  2. package/README.md +368 -0
  3. package/dist/client-experience-renderer.component.d.ts +42 -0
  4. package/dist/client-experience-renderer.component.d.ts.map +1 -0
  5. package/dist/client-experience-renderer.component.js +155 -0
  6. package/dist/client-experience-renderer.component.js.map +1 -0
  7. package/dist/component-error.component.d.ts +14 -0
  8. package/dist/component-error.component.d.ts.map +1 -0
  9. package/dist/component-error.component.js +81 -0
  10. package/dist/component-error.component.js.map +1 -0
  11. package/dist/context.d.ts +21 -0
  12. package/dist/context.d.ts.map +1 -0
  13. package/dist/context.js +54 -0
  14. package/dist/context.js.map +1 -0
  15. package/dist/debug-experience.component.d.ts +17 -0
  16. package/dist/debug-experience.component.d.ts.map +1 -0
  17. package/dist/debug-experience.component.js +143 -0
  18. package/dist/debug-experience.component.js.map +1 -0
  19. package/dist/design-utils.d.ts +22 -0
  20. package/dist/design-utils.d.ts.map +1 -0
  21. package/dist/design-utils.js +40 -0
  22. package/dist/design-utils.js.map +1 -0
  23. package/dist/experience-defaults.d.ts +16 -0
  24. package/dist/experience-defaults.d.ts.map +1 -0
  25. package/dist/experience-defaults.js +27 -0
  26. package/dist/experience-defaults.js.map +1 -0
  27. package/dist/experience-scope.d.ts +33 -0
  28. package/dist/experience-scope.d.ts.map +1 -0
  29. package/dist/experience-scope.js +90 -0
  30. package/dist/experience-scope.js.map +1 -0
  31. package/dist/index.d.ts +40 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +62 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/inject-active-viewport.d.ts +32 -0
  36. package/dist/inject-active-viewport.d.ts.map +1 -0
  37. package/dist/inject-active-viewport.js +78 -0
  38. package/dist/inject-active-viewport.js.map +1 -0
  39. package/dist/inject-design-values.d.ts +14 -0
  40. package/dist/inject-design-values.d.ts.map +1 -0
  41. package/dist/inject-design-values.js +24 -0
  42. package/dist/inject-design-values.js.map +1 -0
  43. package/dist/inject-experience-plan.d.ts +15 -0
  44. package/dist/inject-experience-plan.d.ts.map +1 -0
  45. package/dist/inject-experience-plan.js +39 -0
  46. package/dist/inject-experience-plan.js.map +1 -0
  47. package/dist/inject-live-preview-experience.d.ts +13 -0
  48. package/dist/inject-live-preview-experience.d.ts.map +1 -0
  49. package/dist/inject-live-preview-experience.js +47 -0
  50. package/dist/inject-live-preview-experience.js.map +1 -0
  51. package/dist/inject-live-preview.d.ts +16 -0
  52. package/dist/inject-live-preview.d.ts.map +1 -0
  53. package/dist/inject-live-preview.js +14 -0
  54. package/dist/inject-live-preview.js.map +1 -0
  55. package/dist/missing-component.component.d.ts +14 -0
  56. package/dist/missing-component.component.d.ts.map +1 -0
  57. package/dist/missing-component.component.js +83 -0
  58. package/dist/missing-component.component.js.map +1 -0
  59. package/dist/node-render-engine.d.ts +109 -0
  60. package/dist/node-render-engine.d.ts.map +1 -0
  61. package/dist/node-render-engine.js +528 -0
  62. package/dist/node-render-engine.js.map +1 -0
  63. package/dist/node-renderer.directive.d.ts +46 -0
  64. package/dist/node-renderer.directive.d.ts.map +1 -0
  65. package/dist/node-renderer.directive.js +96 -0
  66. package/dist/node-renderer.directive.js.map +1 -0
  67. package/dist/node-scopes.d.ts +39 -0
  68. package/dist/node-scopes.d.ts.map +1 -0
  69. package/dist/node-scopes.js +75 -0
  70. package/dist/node-scopes.js.map +1 -0
  71. package/dist/server-experience-renderer.component.d.ts +46 -0
  72. package/dist/server-experience-renderer.component.d.ts.map +1 -0
  73. package/dist/server-experience-renderer.component.js +159 -0
  74. package/dist/server-experience-renderer.component.js.map +1 -0
  75. package/dist/types.d.ts +137 -0
  76. package/dist/types.d.ts.map +1 -0
  77. package/dist/types.js +44 -0
  78. package/dist/types.js.map +1 -0
  79. package/package.json +57 -0
@@ -0,0 +1,96 @@
1
+ /*
2
+ * The two rendering primitives customers reach for: `*cfNodes` for a whole slot,
3
+ * `*cfNode` for one child at a time.
4
+ *
5
+ * Structural directives, not components, so nothing the adapter owns lands in
6
+ * the DOM — see the note at the top of node-render-engine.ts for why that
7
+ * matters. Neither directive ever uses its `TemplateRef`: the microsyntax is
8
+ * borrowed purely because `*foo` is how Angular expresses "this element is an
9
+ * anchor, not an element". Written out, `<ng-container *cfNodes="nodes()">`
10
+ * desugars to an `<ng-template>` whose only DOM trace is a comment.
11
+ *
12
+ * Both create synchronously from the input setter, the same point
13
+ * `NgComponentOutlet` creates from in `ngOnChanges` — a single `detectChanges()`
14
+ * has to produce the whole tree, which rules out deferring to an `effect`.
15
+ * `ngDoCheck` then covers the one input the engine reads but is not bound to:
16
+ * the registry on `ExperienceScope`.
17
+ */
18
+ import { Directive, Injector, Input, ViewContainerRef, inject, } from '@angular/core';
19
+ import { ExperienceScope } from './experience-scope.js';
20
+ import { NodeRenderEngine } from './node-render-engine.js';
21
+ import * as i0 from "@angular/core";
22
+ /**
23
+ * Renders a slot's nodes as direct children of the surrounding element.
24
+ *
25
+ * ```html
26
+ * <div class="grid"><ng-container *cfNodes="children()"></ng-container></div>
27
+ * ```
28
+ *
29
+ * Load-bearing in this adapter rather than an escape hatch: Angular has no lazy
30
+ * renderable-child primitive for arbitrary named slots, so each slot arrives as
31
+ * a same-named `PortableRenderNode[]` input and this is how it gets rendered.
32
+ */
33
+ export class NodesRendererDirective {
34
+ constructor() {
35
+ // `inject(Injector)` is the anchor's own injector — the same value
36
+ // `NgComponentOutlet` defaults to — so the element-injector walk-up from a
37
+ // created component reaches the enclosing node's scopes.
38
+ this.engine = new NodeRenderEngine(inject(ViewContainerRef), inject(Injector), inject(ExperienceScope));
39
+ }
40
+ /**
41
+ * Not `required`, so a component can forward an optional slot input straight
42
+ * through — `*cfNodes="children()"` where `children` may be undefined —
43
+ * without a non-null assertion at every call site.
44
+ */
45
+ set cfNodes(value) {
46
+ this.engine.setNodes(value ?? []);
47
+ }
48
+ ngDoCheck() {
49
+ this.engine.checkConfig();
50
+ }
51
+ ngOnDestroy() {
52
+ this.engine.destroy();
53
+ }
54
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: NodesRendererDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
55
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.28", type: NodesRendererDirective, isStandalone: true, selector: "[cfNodes]", inputs: { cfNodes: "cfNodes" }, ngImport: i0 }); }
56
+ }
57
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: NodesRendererDirective, decorators: [{
58
+ type: Directive,
59
+ args: [{ selector: '[cfNodes]' }]
60
+ }], propDecorators: { cfNodes: [{
61
+ type: Input
62
+ }] } });
63
+ /**
64
+ * Renders a single node. Use it to wrap, reorder or drop slot children
65
+ * individually:
66
+ *
67
+ * ```html
68
+ * @for (child of children() ?? []; track $index) {
69
+ * <div class="cell"><ng-container *cfNode="child"></ng-container></div>
70
+ * }
71
+ * ```
72
+ */
73
+ export class NodeRendererDirective {
74
+ constructor() {
75
+ this.engine = new NodeRenderEngine(inject(ViewContainerRef), inject(Injector), inject(ExperienceScope));
76
+ }
77
+ set cfNode(value) {
78
+ this.engine.setNodes([value]);
79
+ }
80
+ ngDoCheck() {
81
+ this.engine.checkConfig();
82
+ }
83
+ ngOnDestroy() {
84
+ this.engine.destroy();
85
+ }
86
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: NodeRendererDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
87
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.28", type: NodeRendererDirective, isStandalone: true, selector: "[cfNode]", inputs: { cfNode: "cfNode" }, ngImport: i0 }); }
88
+ }
89
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: NodeRendererDirective, decorators: [{
90
+ type: Directive,
91
+ args: [{ selector: '[cfNode]' }]
92
+ }], propDecorators: { cfNode: [{
93
+ type: Input,
94
+ args: [{ required: true }]
95
+ }] } });
96
+ //# sourceMappingURL=node-renderer.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-renderer.directive.js","sourceRoot":"","sources":["../src/node-renderer.directive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,SAAS,EAET,QAAQ,EACR,KAAK,EAEL,gBAAgB,EAChB,MAAM,GACP,MAAM,eAAe,CAAC;AAIvB,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;;AAE3D;;;;;;;;;;GAUG;AAEH,MAAM,OAAO,sBAAsB;IADnC;QAEE,mEAAmE;QACnE,2EAA2E;QAC3E,yDAAyD;QACxC,WAAM,GAAG,IAAI,gBAAgB,CAC5C,MAAM,CAAC,gBAAgB,CAAC,EACxB,MAAM,CAAC,QAAQ,CAAC,EAChB,MAAM,CAAC,eAAe,CAAC,CACxB,CAAC;KAkBH;IAhBC;;;;OAIG;IACH,IAAa,OAAO,CAAC,KAA8C;QACjE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,SAAS;QACP,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;IAED,WAAW;QACT,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;+GAzBU,sBAAsB;mGAAtB,sBAAsB;;4FAAtB,sBAAsB;kBADlC,SAAS;mBAAC,EAAE,QAAQ,EAAE,WAAW,EAAE;;sBAgBjC,KAAK;;AAaR;;;;;;;;;GASG;AAEH,MAAM,OAAO,qBAAqB;IADlC;QAEmB,WAAM,GAAG,IAAI,gBAAgB,CAC5C,MAAM,CAAC,gBAAgB,CAAC,EACxB,MAAM,CAAC,QAAQ,CAAC,EAChB,MAAM,CAAC,eAAe,CAAC,CACxB,CAAC;KAaH;IAXC,IAA+B,MAAM,CAAC,KAAyB;QAC7D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,SAAS;QACP,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;IAED,WAAW;QACT,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;+GAjBU,qBAAqB;mGAArB,qBAAqB;;4FAArB,qBAAqB;kBADjC,SAAS;mBAAC,EAAE,QAAQ,EAAE,UAAU,EAAE;;sBAQhC,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE"}
@@ -0,0 +1,39 @@
1
+ import { type Signal } from '@angular/core';
2
+ import type { ContentfulComponent, ContentfulExperienceTemplate } from './types.js';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * Viewport-cascaded, token-resolved design values for the enclosing node.
6
+ * Provided on every rendered node, so `injectDesignValues()` always reads the
7
+ * nearest one.
8
+ */
9
+ export declare class DesignScope {
10
+ private readonly source;
11
+ readonly resolvedDesign: Signal<Record<string, unknown>>;
12
+ connect(read: () => Record<string, unknown>): void;
13
+ static ɵfac: i0.ɵɵFactoryDeclaration<DesignScope, never>;
14
+ static ɵprov: i0.ɵɵInjectableDeclaration<DesignScope>;
15
+ }
16
+ /**
17
+ * Raw Contentful payload for the enclosing component node.
18
+ *
19
+ * The getter may return `undefined`: a wrapper connects the scope from its
20
+ * constructor, before Angular has bound its `node` input. Nothing inside the
21
+ * node's subtree exists yet at that point, so the gap is unobservable — but it
22
+ * is real, and typing it away would need a lie.
23
+ */
24
+ export declare class ComponentScope {
25
+ private readonly source;
26
+ readonly node: Signal<ContentfulComponent | undefined>;
27
+ connect(read: () => ContentfulComponent | undefined): void;
28
+ static ɵfac: i0.ɵɵFactoryDeclaration<ComponentScope, never>;
29
+ static ɵprov: i0.ɵɵInjectableDeclaration<ComponentScope>;
30
+ }
31
+ /** Raw Contentful payload for the enclosing experience template node. */
32
+ export declare class ExperienceTemplateScope {
33
+ private readonly source;
34
+ readonly template: Signal<ContentfulExperienceTemplate | undefined>;
35
+ connect(read: () => ContentfulExperienceTemplate | undefined): void;
36
+ static ɵfac: i0.ɵɵFactoryDeclaration<ExperienceTemplateScope, never>;
37
+ static ɵprov: i0.ɵɵInjectableDeclaration<ExperienceTemplateScope>;
38
+ }
39
+ //# sourceMappingURL=node-scopes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-scopes.d.ts","sourceRoot":"","sources":["../src/node-scopes.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAc,KAAK,MAAM,EAAoB,MAAM,eAAe,CAAC;AAE1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;;AAEpF;;;;GAIG;AACH,qBACa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwD;IAE/E,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAEtD;IAEF,OAAO,CAAC,IAAI,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;yCAPvC,WAAW;6CAAX,WAAW;CAUvB;AAED;;;;;;;GAOG;AACH,qBACa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgE;IAEvF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAqC;IAE3F,OAAO,CAAC,IAAI,EAAE,MAAM,mBAAmB,GAAG,SAAS,GAAG,IAAI;yCAL/C,cAAc;6CAAd,cAAc;CAQ1B;AAED,yEAAyE;AACzE,qBACa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyE;IAEhG,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,4BAA4B,GAAG,SAAS,CAAC,CAEjE;IAEF,OAAO,CAAC,IAAI,EAAE,MAAM,4BAA4B,GAAG,SAAS,GAAG,IAAI;yCAPxD,uBAAuB;6CAAvB,uBAAuB;CAUnC"}
@@ -0,0 +1,75 @@
1
+ /*
2
+ * Per-node DI scopes — the Angular analogue of the Svelte adapter's
3
+ * `setContentfulComponent()` / `setContentfulExperienceTemplate()` /
4
+ * `setResolvedDesign()` context writes.
5
+ *
6
+ * Three separate `@Injectable()` classes, deliberately never collapsed into one
7
+ * per-node object. Angular resolves providers by walking *up* the element
8
+ * injector tree, so a component node nested inside an experience template
9
+ * provides `ComponentScope` + `DesignScope` while leaving
10
+ * `ExperienceTemplateScope` unshadowed — the walk-up then reaches the enclosing
11
+ * template's scope. A single combined scope would shadow it and break that
12
+ * lookup.
13
+ *
14
+ * Each scope stores a getter rather than a snapshot, for the reasons documented
15
+ * in experience-scope.ts.
16
+ */
17
+ import { Injectable, computed, signal } from '@angular/core';
18
+ import * as i0 from "@angular/core";
19
+ /**
20
+ * Viewport-cascaded, token-resolved design values for the enclosing node.
21
+ * Provided on every rendered node, so `injectDesignValues()` always reads the
22
+ * nearest one.
23
+ */
24
+ export class DesignScope {
25
+ constructor() {
26
+ this.source = signal(null, ...(ngDevMode ? [{ debugName: "source" }] : []));
27
+ this.resolvedDesign = computed(() => this.source()?.() ?? {}, ...(ngDevMode ? [{ debugName: "resolvedDesign" }] : []));
28
+ }
29
+ connect(read) {
30
+ this.source.set(read);
31
+ }
32
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: DesignScope, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
33
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: DesignScope }); }
34
+ }
35
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: DesignScope, decorators: [{
36
+ type: Injectable
37
+ }] });
38
+ /**
39
+ * Raw Contentful payload for the enclosing component node.
40
+ *
41
+ * The getter may return `undefined`: a wrapper connects the scope from its
42
+ * constructor, before Angular has bound its `node` input. Nothing inside the
43
+ * node's subtree exists yet at that point, so the gap is unobservable — but it
44
+ * is real, and typing it away would need a lie.
45
+ */
46
+ export class ComponentScope {
47
+ constructor() {
48
+ this.source = signal(null, ...(ngDevMode ? [{ debugName: "source" }] : []));
49
+ this.node = computed(() => this.source()?.(), ...(ngDevMode ? [{ debugName: "node" }] : []));
50
+ }
51
+ connect(read) {
52
+ this.source.set(read);
53
+ }
54
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: ComponentScope, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
55
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: ComponentScope }); }
56
+ }
57
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: ComponentScope, decorators: [{
58
+ type: Injectable
59
+ }] });
60
+ /** Raw Contentful payload for the enclosing experience template node. */
61
+ export class ExperienceTemplateScope {
62
+ constructor() {
63
+ this.source = signal(null, ...(ngDevMode ? [{ debugName: "source" }] : []));
64
+ this.template = computed(() => this.source()?.(), ...(ngDevMode ? [{ debugName: "template" }] : []));
65
+ }
66
+ connect(read) {
67
+ this.source.set(read);
68
+ }
69
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: ExperienceTemplateScope, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
70
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: ExperienceTemplateScope }); }
71
+ }
72
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: ExperienceTemplateScope, decorators: [{
73
+ type: Injectable
74
+ }] });
75
+ //# sourceMappingURL=node-scopes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-scopes.js","sourceRoot":"","sources":["../src/node-scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAe,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;;AAI1E;;;;GAIG;AAEH,MAAM,OAAO,WAAW;IADxB;QAEmB,WAAM,GAAG,MAAM,CAAyC,IAAI,kDAAC,CAAC;QAEtE,mBAAc,GAAoC,QAAQ,CACjE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,0DAC9B,CAAC;KAKH;IAHC,OAAO,CAAC,IAAmC;QACzC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;+GATU,WAAW;mHAAX,WAAW;;4FAAX,WAAW;kBADvB,UAAU;;AAaX;;;;;;;GAOG;AAEH,MAAM,OAAO,cAAc;IAD3B;QAEmB,WAAM,GAAG,MAAM,CAAiD,IAAI,kDAAC,CAAC;QAE9E,SAAI,GAA4C,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,gDAAC,CAAC;KAK5F;IAHC,OAAO,CAAC,IAA2C;QACjD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;+GAPU,cAAc;mHAAd,cAAc;;4FAAd,cAAc;kBAD1B,UAAU;;AAWX,yEAAyE;AAEzE,MAAM,OAAO,uBAAuB;IADpC;QAEmB,WAAM,GAAG,MAAM,CAA0D,IAAI,kDAAC,CAAC;QAEvF,aAAQ,GAAqD,QAAQ,CAAC,GAAG,EAAE,CAClF,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,oDAClB,CAAC;KAKH;IAHC,OAAO,CAAC,IAAoD;QAC1D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;+GATU,uBAAuB;mHAAvB,uBAAuB;;4FAAvB,uBAAuB;kBADnC,UAAU"}
@@ -0,0 +1,46 @@
1
+ import { type Type } from '@angular/core';
2
+ import type { PortableRenderPlan } from '@contentful/experiences-sdk-core';
3
+ import type { Config } from './types.js';
4
+ import * as i0 from "@angular/core";
5
+ export declare class ServerExperienceRendererComponent {
6
+ protected readonly experienceValue: import("@angular/core").WritableSignal<PortableRenderPlan | null>;
7
+ private readonly debugValue;
8
+ protected readonly resolvedDebug: import("@angular/core").Signal<boolean>;
9
+ private readonly configValue;
10
+ private readonly initialViewportIdValue;
11
+ private readonly metadataValue;
12
+ private readonly renderUnknownValue;
13
+ private readonly renderErrorValue;
14
+ /** A resolved render plan, or `null` while one is still being fetched. */
15
+ set experience(value: PortableRenderPlan | null | undefined);
16
+ set config(value: Config);
17
+ /**
18
+ * Viewport to render for, typically derived from the request's User-Agent.
19
+ * Defaults to the viewport the plan was pre-resolved against.
20
+ */
21
+ set initialViewportId(value: string | undefined);
22
+ /** Shallow-merges over the plan's `metadata`. Only needed to override it. */
23
+ set metadata(value: Record<string, unknown> | undefined);
24
+ /**
25
+ * Renders the resolved plan above the experience for inspection. Defaults to
26
+ * the plan's `debug`; `[debug]="false"` overrides a debug-on plan.
27
+ */
28
+ set debug(value: boolean | undefined);
29
+ /** Replaces the default missing-component box. Receives `componentId` and `nodeId`. */
30
+ set renderUnknown(value: Type<unknown> | undefined);
31
+ /** Replaces the default error box rendered when a registered component throws. */
32
+ set renderError(value: Type<unknown> | undefined);
33
+ /**
34
+ * A `computed`, not a one-shot build: on the server it evaluates once and
35
+ * caches, but the same class is cheap to keep correct if inputs do change
36
+ * (a test harness rebinding, a resolved plan arriving late).
37
+ */
38
+ private readonly renderContext;
39
+ private readonly scope;
40
+ /** Resolve-time + render-time diagnostics, merged for `<cf-debug-experience>`. */
41
+ protected readonly errors: import("@angular/core").Signal<Error[]>;
42
+ constructor();
43
+ static ɵfac: i0.ɵɵFactoryDeclaration<ServerExperienceRendererComponent, never>;
44
+ static ɵcmp: i0.ɵɵComponentDeclaration<ServerExperienceRendererComponent, "cf-server-experience", never, { "experience": { "alias": "experience"; "required": true; }; "config": { "alias": "config"; "required": true; }; "initialViewportId": { "alias": "initialViewportId"; "required": false; }; "metadata": { "alias": "metadata"; "required": false; }; "debug": { "alias": "debug"; "required": false; }; "renderUnknown": { "alias": "renderUnknown"; "required": false; }; "renderError": { "alias": "renderError"; "required": false; }; }, {}, never, never, true, never>;
45
+ }
46
+ //# sourceMappingURL=server-experience-renderer.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-experience-renderer.component.d.ts","sourceRoot":"","sources":["../src/server-experience-renderer.component.ts"],"names":[],"mappings":"AAaA,OAAO,EAIL,KAAK,IAAI,EAIV,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAQ3E,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,YAAY,CAAC;;AAExD,qBAyBa,iCAAiC;IAC5C,SAAS,CAAC,QAAQ,CAAC,eAAe,oEAA2C;IAE7E,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA0C;IACrE,SAAS,CAAC,QAAQ,CAAC,aAAa,0CAE9B;IACF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA+B;IAC3D,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAyC;IAChF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0D;IACxF,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoD;IACvF,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkD;IAEnF,0EAA0E;IAC1E,IAA+B,UAAU,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,EAErF;IAED,IAA+B,MAAM,CAAC,KAAK,EAAE,MAAM,EAElD;IAED;;;OAGG;IACH,IAAa,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAEvD;IAED,6EAA6E;IAC7E,IAAa,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAE/D;IAED;;;OAGG;IACH,IAAa,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAE5C;IAED,uFAAuF;IACvF,IAAa,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,SAAS,EAE1D;IAED,kFAAkF;IAClF,IAAa,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,SAAS,EAExD;IAED;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAsB3B;IAEH,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2B;IAEjD,kFAAkF;IAClF,SAAS,CAAC,QAAQ,CAAC,MAAM,0CAGtB;;yCAxFQ,iCAAiC;2CAAjC,iCAAiC;CAgG7C"}
@@ -0,0 +1,159 @@
1
+ /*
2
+ * Server-side entry point. Port of adapter-svelte/src/ServerExperienceRenderer.svelte.
3
+ *
4
+ * Resolves the active viewport once, from `initialViewportId`, and never
5
+ * reconsiders — no `matchMedia`, no listeners, nothing that touches `window`.
6
+ * Use it wherever the render happens outside a browser: an `@angular/ssr` server
7
+ * route, a prerender, an email or PDF pipeline.
8
+ *
9
+ * For a browser render that should follow viewport changes, use
10
+ * `<cf-experience>` instead. The two are mutually exclusive: SSR cannot react to
11
+ * a viewport the server cannot observe.
12
+ */
13
+ import { ChangeDetectionStrategy, Component, Input, computed, inject, signal, } from '@angular/core';
14
+ import { getViewportIndex } from '@contentful/experiences-design';
15
+ import { ComponentErrorComponent } from './component-error.component.js';
16
+ import { DebugExperienceComponent } from './debug-experience.component.js';
17
+ import { DEFAULT_CONTEXT, EMPTY_CONFIG, FALLBACK_VIEWPORT } from './experience-defaults.js';
18
+ import { ExperienceScope } from './experience-scope.js';
19
+ import { MissingComponentComponent } from './missing-component.component.js';
20
+ import { NodesRendererDirective } from './node-renderer.directive.js';
21
+ import * as i0 from "@angular/core";
22
+ export class ServerExperienceRendererComponent {
23
+ /** A resolved render plan, or `null` while one is still being fetched. */
24
+ set experience(value) {
25
+ this.experienceValue.set(value ?? null);
26
+ }
27
+ set config(value) {
28
+ this.configValue.set(value);
29
+ }
30
+ /**
31
+ * Viewport to render for, typically derived from the request's User-Agent.
32
+ * Defaults to the viewport the plan was pre-resolved against.
33
+ */
34
+ set initialViewportId(value) {
35
+ this.initialViewportIdValue.set(value);
36
+ }
37
+ /** Shallow-merges over the plan's `metadata`. Only needed to override it. */
38
+ set metadata(value) {
39
+ this.metadataValue.set(value);
40
+ }
41
+ /**
42
+ * Renders the resolved plan above the experience for inspection. Defaults to
43
+ * the plan's `debug`; `[debug]="false"` overrides a debug-on plan.
44
+ */
45
+ set debug(value) {
46
+ this.debugValue.set(value);
47
+ }
48
+ /** Replaces the default missing-component box. Receives `componentId` and `nodeId`. */
49
+ set renderUnknown(value) {
50
+ this.renderUnknownValue.set(value ?? MissingComponentComponent);
51
+ }
52
+ /** Replaces the default error box rendered when a registered component throws. */
53
+ set renderError(value) {
54
+ this.renderErrorValue.set(value ?? ComponentErrorComponent);
55
+ }
56
+ constructor() {
57
+ this.experienceValue = signal(null, ...(ngDevMode ? [{ debugName: "experienceValue" }] : []));
58
+ // `undefined` means "not bound", distinct from an explicit `[debug]="false"`.
59
+ this.debugValue = signal(undefined, ...(ngDevMode ? [{ debugName: "debugValue" }] : []));
60
+ this.resolvedDebug = computed(() => this.debugValue() ?? this.experienceValue()?.debug ?? false, ...(ngDevMode ? [{ debugName: "resolvedDebug" }] : []));
61
+ this.configValue = signal(null, ...(ngDevMode ? [{ debugName: "configValue" }] : []));
62
+ this.initialViewportIdValue = signal(undefined, ...(ngDevMode ? [{ debugName: "initialViewportIdValue" }] : []));
63
+ this.metadataValue = signal(undefined, ...(ngDevMode ? [{ debugName: "metadataValue" }] : []));
64
+ this.renderUnknownValue = signal(MissingComponentComponent, ...(ngDevMode ? [{ debugName: "renderUnknownValue" }] : []));
65
+ this.renderErrorValue = signal(ComponentErrorComponent, ...(ngDevMode ? [{ debugName: "renderErrorValue" }] : []));
66
+ /**
67
+ * A `computed`, not a one-shot build: on the server it evaluates once and
68
+ * caches, but the same class is cheap to keep correct if inputs do change
69
+ * (a test harness rebinding, a resolved plan arriving late).
70
+ */
71
+ this.renderContext = computed(() => {
72
+ const experience = this.experienceValue();
73
+ const initialViewportId = this.initialViewportIdValue();
74
+ // Default to the pre-resolved viewport so first paint needs no recompute.
75
+ const activeViewportIndex = !experience
76
+ ? 0
77
+ : initialViewportId === undefined
78
+ ? experience.fallbackViewportIndex
79
+ : getViewportIndex(experience.viewports, initialViewportId);
80
+ return {
81
+ ...DEFAULT_CONTEXT,
82
+ debug: this.resolvedDebug(),
83
+ metadata: {
84
+ ...DEFAULT_CONTEXT.metadata,
85
+ ...(experience?.metadata ?? {}),
86
+ ...(this.metadataValue() ?? {}),
87
+ },
88
+ viewports: experience?.viewports ?? [],
89
+ activeViewport: experience?.viewports[activeViewportIndex] ?? FALLBACK_VIEWPORT,
90
+ activeViewportIndex,
91
+ fallbackViewportIndex: experience?.fallbackViewportIndex ?? 0,
92
+ };
93
+ }, ...(ngDevMode ? [{ debugName: "renderContext" }] : []));
94
+ this.scope = inject(ExperienceScope);
95
+ /** Resolve-time + render-time diagnostics, merged for `<cf-debug-experience>`. */
96
+ this.errors = computed(() => [
97
+ ...(this.experienceValue()?.diagnostics ?? []),
98
+ ...this.scope.diagnostics(),
99
+ ], ...(ngDevMode ? [{ debugName: "errors" }] : []));
100
+ this.scope.connectExperience(() => this.renderContext());
101
+ this.scope.connectConfig(() => this.configValue() ?? EMPTY_CONFIG);
102
+ this.scope.connectRenderUnknown(() => this.renderUnknownValue());
103
+ this.scope.connectRenderError(() => this.renderErrorValue());
104
+ }
105
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: ServerExperienceRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
106
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.28", type: ServerExperienceRendererComponent, isStandalone: true, selector: "cf-server-experience", inputs: { experience: "experience", config: "config", initialViewportId: "initialViewportId", metadata: "metadata", debug: "debug", renderUnknown: "renderUnknown", renderError: "renderError" }, providers: [ExperienceScope], ngImport: i0, template: `
107
+ @if (experienceValue(); as experience) {
108
+ <ng-container *cfNodes="experience.nodes"></ng-container>
109
+ @if (resolvedDebug()) {
110
+ <cf-debug-experience [experience]="experience" [errors]="errors()" />
111
+ }
112
+ }
113
+ `, isInline: true, dependencies: [{ kind: "component", type: DebugExperienceComponent, selector: "cf-debug-experience", inputs: ["experience", "defaultOpen", "errors"] }, { kind: "directive", type: NodesRendererDirective, selector: "[cfNodes]", inputs: ["cfNodes"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
114
+ }
115
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.28", ngImport: i0, type: ServerExperienceRendererComponent, decorators: [{
116
+ type: Component,
117
+ args: [{
118
+ selector: 'cf-server-experience',
119
+ imports: [DebugExperienceComponent, NodesRendererDirective],
120
+ providers: [ExperienceScope],
121
+ changeDetection: ChangeDetectionStrategy.OnPush,
122
+ // The `<cf-server-experience>` host element itself stays a real element — it is
123
+ // the customer's mount point, and they may well style it. Only the plumbing
124
+ // *inside* it is anchor-only: `*cfNodes` puts the top-level nodes here as
125
+ // siblings of a comment, so nothing the adapter owns wraps them.
126
+ //
127
+ // The node tree renders before `<cf-debug-experience>` here for consistency
128
+ // with the React adapter's element-order fix — Angular's own reactivity
129
+ // (`errors` is a signal read at template-check time) doesn't strictly
130
+ // require this ordering the way React's synchronous single-pass render
131
+ // does, but matching it keeps the three adapters' templates readable
132
+ // side-by-side.
133
+ template: `
134
+ @if (experienceValue(); as experience) {
135
+ <ng-container *cfNodes="experience.nodes"></ng-container>
136
+ @if (resolvedDebug()) {
137
+ <cf-debug-experience [experience]="experience" [errors]="errors()" />
138
+ }
139
+ }
140
+ `,
141
+ }]
142
+ }], ctorParameters: () => [], propDecorators: { experience: [{
143
+ type: Input,
144
+ args: [{ required: true }]
145
+ }], config: [{
146
+ type: Input,
147
+ args: [{ required: true }]
148
+ }], initialViewportId: [{
149
+ type: Input
150
+ }], metadata: [{
151
+ type: Input
152
+ }], debug: [{
153
+ type: Input
154
+ }], renderUnknown: [{
155
+ type: Input
156
+ }], renderError: [{
157
+ type: Input
158
+ }] } });
159
+ //# sourceMappingURL=server-experience-renderer.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-experience-renderer.component.js","sourceRoot":"","sources":["../src/server-experience-renderer.component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,KAAK,EAEL,QAAQ,EACR,MAAM,EACN,MAAM,GACP,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;;AA4BtE,MAAM,OAAO,iCAAiC;IAa5C,0EAA0E;IAC1E,IAA+B,UAAU,CAAC,KAA4C;QACpF,IAAI,CAAC,eAAe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Context, ResolveContext, ResolveToken } from '@contentful/experiences-sdk-core';
3
+ export type { ResolveContext, ResolveToken };
4
+ /**
5
+ * The full Contentful-side payload for a single component instance, exposed
6
+ * via `injectContentfulComponent()` to any descendant of a rendered Experience
7
+ * node. Useful for custom design-property resolution outside the SDK's
8
+ * cascade, branching by `componentId` in a generic wrapper, keying
9
+ * analytics on `nodeId`, rendering a raw-payload panel in preview, or
10
+ * re-rendering a slot's nodes yourself through the exported `*cfNodes`.
11
+ *
12
+ * Design properties stay in their **raw discriminated form** here (the same
13
+ * shape `ctx.design` carries inside `resolveData`). The viewport-cascaded,
14
+ * token-resolved values are what `injectDesignValues()` returns.
15
+ */
16
+ export interface ContentfulComponent {
17
+ componentId: string;
18
+ nodeId?: string;
19
+ content: Record<string, unknown>;
20
+ design: Record<string, DesignPropValue>;
21
+ resolved?: Record<string, unknown>;
22
+ /**
23
+ * Raw per-slot node arrays from the payload. Every slot is also passed as a
24
+ * same-named `PortableRenderNode[]` input (`children` is not special); these
25
+ * raw nodes are the same arrays, kept here for callers that reach a slot
26
+ * through the context rather than through a declared input.
27
+ */
28
+ slots: Record<string, unknown>;
29
+ }
30
+ /**
31
+ * Same shape as `ContentfulComponent`, but for an Experience Template node.
32
+ * Exposed via `injectContentfulExperienceTemplate()` inside an Experience
33
+ * Template's component tree.
34
+ */
35
+ export interface ContentfulExperienceTemplate {
36
+ experienceTemplateId: string;
37
+ nodeId?: string;
38
+ content: Record<string, unknown>;
39
+ design: Record<string, DesignPropValue>;
40
+ resolved?: Record<string, unknown>;
41
+ }
42
+ /** Render-time experience context, read with `injectExperience()`. Declared in core so all adapters share one shape. */
43
+ export type { RenderContext };
44
+ /**
45
+ * Customer-supplied configuration for a single component type. The `component`
46
+ * receives the merged props (design + content + resolveData + one
47
+ * `PortableRenderNode[]` input per slot); resolved design values auto-fill
48
+ * matching inputs and are also readable via `injectDesignValues()`. Runtime
49
+ * context and raw payload come from `injectExperience()` /
50
+ * `injectContentfulComponent()`.
51
+ *
52
+ * Only keys the component declares as inputs are assigned — see
53
+ * `Registration` and the README's parity table.
54
+ */
55
+ export interface ComponentConfig<Props extends object = Record<string, unknown>> {
56
+ /**
57
+ * Lowest-precedence defaults object. Merged in before content / resolveData /
58
+ * slots. Useful for variant fallbacks the editorial layer doesn't always supply.
59
+ */
60
+ defaults?: Partial<Props>;
61
+ resolveData?: (ctx: ResolveContext) => Partial<Props> | Promise<Partial<Props>>;
62
+ component: Type<unknown>;
63
+ }
64
+ /**
65
+ * Registry value. Register a bare Angular component class for the common case,
66
+ * or the full `ComponentConfig` shape when you need defaults or a `resolveData`
67
+ * hook.
68
+ *
69
+ * button: ButtonComponent, // bare
70
+ * header: { component: HeaderComponent, defaults: {...} }, // with defaults
71
+ * card: defineComponent<CardProps>({ component: CardComponent, resolveData: ... }),
72
+ */
73
+ export type Registration<Props extends object = Record<string, unknown>> = Type<unknown> | ComponentConfig<Props>;
74
+ /**
75
+ * Customer-supplied configuration for a coded Experience Template. Identical in
76
+ * shape and behavior to `ComponentConfig` — an Experience Template is just a
77
+ * node whose implementation lives in the `experienceTemplates` registry. Its
78
+ * slots arrive as named `PortableRenderNode[]` inputs (a `content` slot becomes
79
+ * a `content` input), so there is no `children` special case.
80
+ */
81
+ export interface ExperienceTemplateConfig<Props extends object = Record<string, unknown>> {
82
+ /**
83
+ * Lowest-precedence defaults object. Merged in before content / resolveData /
84
+ * slots. Useful for variant fallbacks the editorial layer doesn't always supply.
85
+ */
86
+ defaults?: Partial<Props>;
87
+ resolveData?: (ctx: ResolveContext) => Partial<Props> | Promise<Partial<Props>>;
88
+ component: Type<unknown>;
89
+ }
90
+ export type ExperienceTemplateRegistration<Props extends object = Record<string, unknown>> = Type<unknown> | ExperienceTemplateConfig<Props>;
91
+ export declare function defineExperienceTemplate<Props extends object = Record<string, unknown>>(config: ExperienceTemplateConfig<Props>): ExperienceTemplateConfig<Props>;
92
+ export declare function defineComponent<Props extends object = Record<string, unknown>>(config: ComponentConfig<Props>): ComponentConfig<Props>;
93
+ /**
94
+ * Component registry — keyed by `componentId` (last slash-segment of
95
+ * `component.sys.urn`).
96
+ */
97
+ export type Components = Record<string, Registration<any>>;
98
+ /**
99
+ * Experience Template registry — keyed by `experienceTemplateId` (last
100
+ * slash-segment of an Experience Template node's own
101
+ * `experienceTemplate.sys.urn`). Not read from `payload.sys`; templates are
102
+ * ordinary nodes.
103
+ */
104
+ export type ExperienceTemplates = Record<string, ExperienceTemplateRegistration<any>>;
105
+ export interface Config {
106
+ components: Components;
107
+ experienceTemplates?: ExperienceTemplates;
108
+ /**
109
+ * Resolves `DesignToken` values to runtime values before they reach a
110
+ * component. If omitted, they pass through unchanged. See `ResolveToken`
111
+ * in `@contentful/experiences-sdk-core` for the full contract.
112
+ */
113
+ resolveToken?: ResolveToken;
114
+ }
115
+ /**
116
+ * Normalize a registry entry — bare Angular component class OR config object —
117
+ * into the common `ComponentConfig` shape used by the renderer. Component
118
+ * classes are functions; config objects are plain objects with a `component`
119
+ * field, so `typeof` is enough to discriminate.
120
+ */
121
+ export declare function normalizeComponentRegistration<P extends object>(reg: Registration<P>): ComponentConfig<P>;
122
+ export declare function normalizeExperienceTemplateRegistration<P extends object>(reg: ExperienceTemplateRegistration<P>): ExperienceTemplateConfig<P>;
123
+ /**
124
+ * Renders the unregistered-component placeholder. Receives `componentId` and
125
+ * `nodeId` inputs; anything it does not declare is dropped, same as any other
126
+ * rendered component.
127
+ */
128
+ export type RenderUnknown = Type<unknown>;
129
+ /**
130
+ * Renders the fallback for a registered component that threw. Receives
131
+ * `componentId`, `nodeId`, and `message` inputs; anything it does not
132
+ * declare is dropped, same as any other rendered component.
133
+ */
134
+ export type RenderError = Type<unknown>;
135
+ /** Convenience alias — the slot input shape customer components declare. */
136
+ export type SlotNodes = PortableRenderNode[];
137
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAoBA,OAAO,KA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G;AAEH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,8BAA8B,CAAC,GAAG,CAAC,CAAC,CAAC;AAEtF,MAAM,WAAW,MAAM;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C;;;;OAIG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,MAAM,EAC7D,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,GACnB,eAAe,CAAC,CAAC,CAAC,CAKpB;AAED,wBAAgB,uCAAuC,CAAC,CAAC,SAAS,MAAM,EACtE,GAAG,EAAE,8BAA8B,CAAC,CAAC,CAAC,GACrC,wBAAwB,CAAC,CAAC,CAAC,CAK7B;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;AAE1C;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;AAExC,4EAA4E;AAC5E,MAAM,MAAM,SAAS,GAAG,kBAAkB,EAAE,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,44 @@
1
+ /*
2
+ * Port of the Svelte adapter's types, with `Component<any>` → `Type<unknown>`.
3
+ *
4
+ * Input declaration convention for this package: every component in `src/`
5
+ * declares its inputs with the `@Input()` decorator plus a setter that writes
6
+ * into a private signal, never with the signal-based `input()`.
7
+ *
8
+ * Signal inputs are AOT-only. Angular's JIT compiler builds a component def's
9
+ * `inputs` map from decorator metadata and never scans class-field initializers,
10
+ * so under JIT an `input()` field is invisible to `reflectComponentType()` and
11
+ * `ComponentRef.setInput()` rejects it (NG0303). This suite runs on JIT — see
12
+ * the note in vitest.config.ts — so the decorator form is load-bearing here.
13
+ *
14
+ * This constraint applies only to the adapter's own components and its test
15
+ * fixtures. Customer-registered components are compiled by the customer's own
16
+ * AOT build and may declare signal inputs freely: the renderer discovers them
17
+ * with `reflectComponentType()` and assigns them with `setInput()`, both of
18
+ * which are runtime APIs that read whatever the component def already carries.
19
+ */
20
+ export function defineExperienceTemplate(config) {
21
+ return config;
22
+ }
23
+ export function defineComponent(config) {
24
+ return config;
25
+ }
26
+ /**
27
+ * Normalize a registry entry — bare Angular component class OR config object —
28
+ * into the common `ComponentConfig` shape used by the renderer. Component
29
+ * classes are functions; config objects are plain objects with a `component`
30
+ * field, so `typeof` is enough to discriminate.
31
+ */
32
+ export function normalizeComponentRegistration(reg) {
33
+ if (typeof reg === 'function') {
34
+ return { component: reg };
35
+ }
36
+ return reg;
37
+ }
38
+ export function normalizeExperienceTemplateRegistration(reg) {
39
+ if (typeof reg === 'function') {
40
+ return { component: reg };
41
+ }
42
+ return reg;
43
+ }
44
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AA8GH,MAAM,UAAU,wBAAwB,CACtC,MAAuC;IAEvC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,MAA8B;IAE9B,OAAO,MAAM,CAAC;AAChB,CAAC;AA6BD;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAC5C,GAAoB;IAEpB,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO,EAAE,SAAS,EAAE,GAAoB,EAAwB,CAAC;IACnE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,uCAAuC,CACrD,GAAsC;IAEtC,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO,EAAE,SAAS,EAAE,GAAoB,EAAiC,CAAC;IAC5E,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}