@rulecms/widget-angular 0.7.0 → 0.8.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.
- package/fesm2022/rulecms-widget-angular.mjs +544 -84
- package/fesm2022/rulecms-widget-angular.mjs.map +1 -1
- package/lib/fetch/fetch-rule-cms-widget.d.ts +42 -7
- package/lib/fetch/fetch-rule-cms-widget.d.ts.map +1 -1
- package/lib/helpers/index.d.ts +1 -0
- package/lib/helpers/index.d.ts.map +1 -1
- package/lib/helpers/with-widget-placeholder-values.d.ts +25 -0
- package/lib/helpers/with-widget-placeholder-values.d.ts.map +1 -0
- package/lib/id-utils/dev-client-token.d.ts +15 -0
- package/lib/id-utils/dev-client-token.d.ts.map +1 -1
- package/lib/library-registry/types.d.ts +7 -0
- package/lib/library-registry/types.d.ts.map +1 -1
- package/lib/render/breakpoint-variant-render.component.d.ts +2 -1
- package/lib/render/breakpoint-variant-render.component.d.ts.map +1 -1
- package/lib/render/display-component.component.d.ts +4 -1
- package/lib/render/display-component.component.d.ts.map +1 -1
- package/lib/render/render-components-for-device.component.d.ts +2 -1
- package/lib/render/render-components-for-device.component.d.ts.map +1 -1
- package/lib/render/render-components-inner.component.d.ts +4 -1
- package/lib/render/render-components-inner.component.d.ts.map +1 -1
- package/lib/render/render-components.component.d.ts +2 -1
- package/lib/render/render-components.component.d.ts.map +1 -1
- package/lib/widget/rule-cms-widget.component.d.ts +33 -2
- package/lib/widget/rule-cms-widget.component.d.ts.map +1 -1
- package/lib/widget/widget-data.types.d.ts +6 -0
- package/lib/widget/widget-data.types.d.ts.map +1 -1
- package/lib/widget/widget-selection/build-widget-resolve-request.d.ts +23 -0
- package/lib/widget/widget-selection/build-widget-resolve-request.d.ts.map +1 -0
- package/lib/widget/widget-selection/get-or-create-anonymous-id.d.ts +11 -0
- package/lib/widget/widget-selection/get-or-create-anonymous-id.d.ts.map +1 -0
- package/lib/widget/widget-selection/is-widget-resolve-fallback-status.d.ts +8 -0
- package/lib/widget/widget-selection/is-widget-resolve-fallback-status.d.ts.map +1 -0
- package/lib/widget/widget-selection/normalize-widget-resolve-response.d.ts +16 -0
- package/lib/widget/widget-selection/normalize-widget-resolve-response.d.ts.map +1 -0
- package/lib/widget/widget-selection/stable-json-stringify.d.ts +8 -0
- package/lib/widget/widget-selection/stable-json-stringify.d.ts.map +1 -0
- package/lib/widget/widget-selection/to-ruleset-key.d.ts +7 -0
- package/lib/widget/widget-selection/to-ruleset-key.d.ts.map +1 -0
- package/lib/widget/widget-selection/types.d.ts +78 -0
- package/lib/widget/widget-selection/types.d.ts.map +1 -0
- package/package.json +1 -1
- package/public-api.d.ts +4 -1
- package/public-api.d.ts.map +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Input, Component, HostBinding, ErrorHandler, Optional, Inject } from '@angular/core';
|
|
2
|
+
import { Injectable, Input, Component, HostBinding, EventEmitter, ErrorHandler, Output, Optional, Inject } from '@angular/core';
|
|
3
3
|
import { NgComponentOutlet, NgStyle, NgTemplateOutlet } from '@angular/common';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -265,6 +265,10 @@ const WIDGET_CACHE_API_ORIGIN = 'https://widget-cache.rulecms.com';
|
|
|
265
265
|
const PUBLISHED_WIDGET_API_PATH = '/api/v1/c/widget/get';
|
|
266
266
|
/** Live draft client API path — no cache; reads the widget table directly. */
|
|
267
267
|
const DEV_WIDGET_API_PATH = '/api/v1/c/dev/widget/get';
|
|
268
|
+
/** Published ruleset resolve path (POST) — picks a widget by params, returns its payload. */
|
|
269
|
+
const PUBLISHED_WIDGET_RESOLVE_API_PATH = '/api/v1/c/widget/resolve';
|
|
270
|
+
/** Live draft ruleset resolve path (POST) — compiles the draft ruleset in-process. */
|
|
271
|
+
const DEV_WIDGET_RESOLVE_API_PATH = '/api/v1/c/dev/widget/resolve';
|
|
268
272
|
function isDevClientToken(token) {
|
|
269
273
|
return typeof token === 'string' && token.startsWith(DEV_CLIENT_TOKEN_PREFIX);
|
|
270
274
|
}
|
|
@@ -292,6 +296,17 @@ function buildWidgetFetchUrl({ publishedKey, token, endpoint, }) {
|
|
|
292
296
|
const origin = resolveWidgetApiOrigin(token, endpoint);
|
|
293
297
|
return `${origin}${apiPath}?${queryParams.toString()}`;
|
|
294
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Builds the ruleset resolve URL. The token, ruleset key and params travel in
|
|
301
|
+
* the POST body, so the URL carries no query string. Development tokens
|
|
302
|
+
* (`dev.…`) hit the draft resolve route; everything else uses the published one.
|
|
303
|
+
*/
|
|
304
|
+
function buildWidgetResolveUrl({ token, endpoint, }) {
|
|
305
|
+
const apiPath = isDevClientToken(token)
|
|
306
|
+
? DEV_WIDGET_RESOLVE_API_PATH
|
|
307
|
+
: PUBLISHED_WIDGET_RESOLVE_API_PATH;
|
|
308
|
+
return `${resolveWidgetApiOrigin(token, endpoint)}${apiPath}`;
|
|
309
|
+
}
|
|
295
310
|
|
|
296
311
|
const getDragItemId = ({ id, prefix }) => {
|
|
297
312
|
return `${prefix}_${id}`;
|
|
@@ -2100,6 +2115,39 @@ function resolveWidgetInstanceProps({ componentProps, ancestorColumnIds, columnI
|
|
|
2100
2115
|
return undefined;
|
|
2101
2116
|
}
|
|
2102
2117
|
|
|
2118
|
+
/**
|
|
2119
|
+
* The one key copied from `rulecms-widget`'s `placeholderValues` onto a card.
|
|
2120
|
+
* Must stay the key `r-text` reads (`PLACEHOLDER_VALUES_PROP` in
|
|
2121
|
+
* `@rulecms/source-components-angular`). The renderer copies the value and does
|
|
2122
|
+
* not look inside it.
|
|
2123
|
+
*/
|
|
2124
|
+
const WIDGET_PLACEHOLDER_VALUES_KEY = 'placeholderValues';
|
|
2125
|
+
/**
|
|
2126
|
+
* Widget-wide placeholder values for one component instance.
|
|
2127
|
+
*
|
|
2128
|
+
* When the host passed `placeholderValues` on `rulecms-widget`, every instance
|
|
2129
|
+
* receives that object unless its own `componentProps` entry already has the
|
|
2130
|
+
* key. An entry that sets the key wins even when the value is `null` or
|
|
2131
|
+
* otherwise unusable: that is how one Text opts out. Other keys on the entry,
|
|
2132
|
+
* such as `onClick`, stay. The host's entry is not mutated.
|
|
2133
|
+
*
|
|
2134
|
+
* `undefined` means the widget input was omitted, which is the common case and
|
|
2135
|
+
* must not invent a bag.
|
|
2136
|
+
*/
|
|
2137
|
+
function withWidgetPlaceholderValues({ widgetInstanceProps, placeholderValues, }) {
|
|
2138
|
+
if (placeholderValues === undefined) {
|
|
2139
|
+
return widgetInstanceProps;
|
|
2140
|
+
}
|
|
2141
|
+
if (widgetInstanceProps != null &&
|
|
2142
|
+
Object.prototype.hasOwnProperty.call(widgetInstanceProps, WIDGET_PLACEHOLDER_VALUES_KEY)) {
|
|
2143
|
+
return widgetInstanceProps;
|
|
2144
|
+
}
|
|
2145
|
+
return {
|
|
2146
|
+
...widgetInstanceProps,
|
|
2147
|
+
[WIDGET_PLACEHOLDER_VALUES_KEY]: placeholderValues,
|
|
2148
|
+
};
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2103
2151
|
/**
|
|
2104
2152
|
* Every component instance in a config, as the `/`-joined column-id path that
|
|
2105
2153
|
* `componentProps` keys are matched against. Collections contribute their
|
|
@@ -2678,11 +2726,13 @@ class DisplayComponentComponent {
|
|
|
2678
2726
|
styleProps: componentStyleProps,
|
|
2679
2727
|
className: cardClassName,
|
|
2680
2728
|
widgetInstanceProps: this.widgetInstanceProps,
|
|
2729
|
+
pageViewType: this.pageViewType,
|
|
2730
|
+
columnPath: this.columnPath,
|
|
2681
2731
|
mounts: this.mounts,
|
|
2682
2732
|
};
|
|
2683
2733
|
}
|
|
2684
2734
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: DisplayComponentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2685
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: DisplayComponentComponent, isStandalone: true, selector: "rulecms-display-component", inputs: { componentType: "componentType", libraryId: "libraryId", componentAttributes: "componentAttributes", components: "components", styleProps: "styleProps", widgetInstanceProps: "widgetInstanceProps", mounts: "mounts" }, host: { styleAttribute: "display: contents" }, usesOnChanges: true, ngImport: i0, template: `
|
|
2735
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: DisplayComponentComponent, isStandalone: true, selector: "rulecms-display-component", inputs: { componentType: "componentType", libraryId: "libraryId", componentAttributes: "componentAttributes", components: "components", styleProps: "styleProps", widgetInstanceProps: "widgetInstanceProps", pageViewType: "pageViewType", columnPath: "columnPath", mounts: "mounts" }, host: { styleAttribute: "display: contents" }, usesOnChanges: true, ngImport: i0, template: `
|
|
2686
2736
|
@if (card) {
|
|
2687
2737
|
@if (needsWrapper) {
|
|
2688
2738
|
<div [class]="wrapperClass || undefined" [ngStyle]="wrapperStyle">
|
|
@@ -2735,6 +2785,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
2735
2785
|
type: Input
|
|
2736
2786
|
}], widgetInstanceProps: [{
|
|
2737
2787
|
type: Input
|
|
2788
|
+
}], pageViewType: [{
|
|
2789
|
+
type: Input
|
|
2790
|
+
}], columnPath: [{
|
|
2791
|
+
type: Input
|
|
2738
2792
|
}], mounts: [{
|
|
2739
2793
|
type: Input
|
|
2740
2794
|
}] } });
|
|
@@ -2843,18 +2897,30 @@ class RenderComponentsInnerComponent {
|
|
|
2843
2897
|
}
|
|
2844
2898
|
return collection.collectionRows;
|
|
2845
2899
|
}
|
|
2900
|
+
get pageViewType() {
|
|
2901
|
+
return this.isComposeMode ? PageViewTypes.Compose : PageViewTypes.RenderedPage;
|
|
2902
|
+
}
|
|
2846
2903
|
childAncestorIds(columnId) {
|
|
2847
2904
|
return [...(this.ancestorColumnIds ?? []), columnId];
|
|
2848
2905
|
}
|
|
2906
|
+
columnPathFor(columnId) {
|
|
2907
|
+
if (this.isComposeMode || !columnId) {
|
|
2908
|
+
return undefined;
|
|
2909
|
+
}
|
|
2910
|
+
return [...(this.ancestorColumnIds ?? []), columnId].join(COMPONENT_PROPS_PATH_SEPARATOR);
|
|
2911
|
+
}
|
|
2849
2912
|
instanceProps(columnId) {
|
|
2850
|
-
return
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2913
|
+
return withWidgetPlaceholderValues({
|
|
2914
|
+
widgetInstanceProps: resolveWidgetInstanceProps({
|
|
2915
|
+
componentProps: this.componentProps,
|
|
2916
|
+
ancestorColumnIds: this.ancestorColumnIds,
|
|
2917
|
+
columnId,
|
|
2918
|
+
}),
|
|
2919
|
+
placeholderValues: this.isComposeMode ? undefined : this.placeholderValues,
|
|
2854
2920
|
});
|
|
2855
2921
|
}
|
|
2856
2922
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RenderComponentsInnerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2857
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: RenderComponentsInnerComponent, isStandalone: true, selector: "rulecms-render-inner", inputs: { displayItemList: "displayItemList", isComposeMode: "isComposeMode", isWithinCollection: "isWithinCollection", widgetCollections: "widgetCollections", showDropContainers: "showDropContainers", reduxDeviceDisplayType: "reduxDeviceDisplayType", plugins: "plugins", deviceDisplayType: "deviceDisplayType", componentProps: "componentProps", mounts: "mounts", ancestorColumnIds: "ancestorColumnIds" }, host: { styleAttribute: "display: contents" }, ngImport: i0, template: `
|
|
2923
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: RenderComponentsInnerComponent, isStandalone: true, selector: "rulecms-render-inner", inputs: { displayItemList: "displayItemList", isComposeMode: "isComposeMode", isWithinCollection: "isWithinCollection", widgetCollections: "widgetCollections", showDropContainers: "showDropContainers", reduxDeviceDisplayType: "reduxDeviceDisplayType", plugins: "plugins", deviceDisplayType: "deviceDisplayType", componentProps: "componentProps", mounts: "mounts", placeholderValues: "placeholderValues", ancestorColumnIds: "ancestorColumnIds" }, host: { styleAttribute: "display: contents" }, ngImport: i0, template: `
|
|
2858
2924
|
<ng-template #baseTree>
|
|
2859
2925
|
<rulecms-embed-vertical
|
|
2860
2926
|
[displayItemList]="displayItemList"
|
|
@@ -2885,6 +2951,7 @@ class RenderComponentsInnerComponent {
|
|
|
2885
2951
|
[deviceDisplayType]="deviceDisplayType"
|
|
2886
2952
|
[componentProps]="componentProps"
|
|
2887
2953
|
[mounts]="mounts"
|
|
2954
|
+
[placeholderValues]="placeholderValues"
|
|
2888
2955
|
[ancestorColumnIds]="childAncestorIds(col.id)"
|
|
2889
2956
|
/>
|
|
2890
2957
|
} @else {
|
|
@@ -2895,6 +2962,8 @@ class RenderComponentsInnerComponent {
|
|
|
2895
2962
|
[components]="components"
|
|
2896
2963
|
[styleProps]="columnView(col).styleProps"
|
|
2897
2964
|
[widgetInstanceProps]="instanceProps(col.id)"
|
|
2965
|
+
[pageViewType]="pageViewType"
|
|
2966
|
+
[columnPath]="columnPathFor(col.id)"
|
|
2898
2967
|
[mounts]="mounts"
|
|
2899
2968
|
/>
|
|
2900
2969
|
}
|
|
@@ -2924,6 +2993,7 @@ class RenderComponentsInnerComponent {
|
|
|
2924
2993
|
[deviceDisplayType]="deviceDisplayType"
|
|
2925
2994
|
[componentProps]="componentProps"
|
|
2926
2995
|
[mounts]="mounts"
|
|
2996
|
+
[placeholderValues]="placeholderValues"
|
|
2927
2997
|
[ancestorColumnIds]="ancestorColumnIds"
|
|
2928
2998
|
/>
|
|
2929
2999
|
</div>
|
|
@@ -2932,7 +3002,7 @@ class RenderComponentsInnerComponent {
|
|
|
2932
3002
|
} @else {
|
|
2933
3003
|
<ng-container *ngTemplateOutlet="baseTree" />
|
|
2934
3004
|
}
|
|
2935
|
-
`, isInline: true, dependencies: [{ kind: "component", type: RenderComponentsInnerComponent, selector: "rulecms-render-inner", inputs: ["displayItemList", "isComposeMode", "isWithinCollection", "widgetCollections", "showDropContainers", "reduxDeviceDisplayType", "plugins", "deviceDisplayType", "componentProps", "mounts", "ancestorColumnIds"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: EmbedInVerticalContainerComponent, selector: "rulecms-embed-vertical", inputs: ["displayItemList", "isComposeMode", "showDropContainers", "isWithinCollection", "deviceDisplayType"] }, { kind: "component", type: EmbedInRowComponent, selector: "rulecms-embed-row", inputs: ["row", "isComposeMode", "showDropContainers", "isWithinCollection", "deviceDisplayType"] }, { kind: "component", type: DisplayComponentComponent, selector: "rulecms-display-component", inputs: ["componentType", "libraryId", "componentAttributes", "components", "styleProps", "widgetInstanceProps", "mounts"] }] }); }
|
|
3005
|
+
`, isInline: true, dependencies: [{ kind: "component", type: RenderComponentsInnerComponent, selector: "rulecms-render-inner", inputs: ["displayItemList", "isComposeMode", "isWithinCollection", "widgetCollections", "showDropContainers", "reduxDeviceDisplayType", "plugins", "deviceDisplayType", "componentProps", "mounts", "placeholderValues", "ancestorColumnIds"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: EmbedInVerticalContainerComponent, selector: "rulecms-embed-vertical", inputs: ["displayItemList", "isComposeMode", "showDropContainers", "isWithinCollection", "deviceDisplayType"] }, { kind: "component", type: EmbedInRowComponent, selector: "rulecms-embed-row", inputs: ["row", "isComposeMode", "showDropContainers", "isWithinCollection", "deviceDisplayType"] }, { kind: "component", type: DisplayComponentComponent, selector: "rulecms-display-component", inputs: ["componentType", "libraryId", "componentAttributes", "components", "styleProps", "widgetInstanceProps", "pageViewType", "columnPath", "mounts"] }] }); }
|
|
2936
3006
|
}
|
|
2937
3007
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RenderComponentsInnerComponent, decorators: [{
|
|
2938
3008
|
type: Component,
|
|
@@ -2976,6 +3046,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
2976
3046
|
[deviceDisplayType]="deviceDisplayType"
|
|
2977
3047
|
[componentProps]="componentProps"
|
|
2978
3048
|
[mounts]="mounts"
|
|
3049
|
+
[placeholderValues]="placeholderValues"
|
|
2979
3050
|
[ancestorColumnIds]="childAncestorIds(col.id)"
|
|
2980
3051
|
/>
|
|
2981
3052
|
} @else {
|
|
@@ -2986,6 +3057,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
2986
3057
|
[components]="components"
|
|
2987
3058
|
[styleProps]="columnView(col).styleProps"
|
|
2988
3059
|
[widgetInstanceProps]="instanceProps(col.id)"
|
|
3060
|
+
[pageViewType]="pageViewType"
|
|
3061
|
+
[columnPath]="columnPathFor(col.id)"
|
|
2989
3062
|
[mounts]="mounts"
|
|
2990
3063
|
/>
|
|
2991
3064
|
}
|
|
@@ -3015,6 +3088,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3015
3088
|
[deviceDisplayType]="deviceDisplayType"
|
|
3016
3089
|
[componentProps]="componentProps"
|
|
3017
3090
|
[mounts]="mounts"
|
|
3091
|
+
[placeholderValues]="placeholderValues"
|
|
3018
3092
|
[ancestorColumnIds]="ancestorColumnIds"
|
|
3019
3093
|
/>
|
|
3020
3094
|
</div>
|
|
@@ -3050,6 +3124,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3050
3124
|
type: Input
|
|
3051
3125
|
}], mounts: [{
|
|
3052
3126
|
type: Input
|
|
3127
|
+
}], placeholderValues: [{
|
|
3128
|
+
type: Input
|
|
3053
3129
|
}], ancestorColumnIds: [{
|
|
3054
3130
|
type: Input
|
|
3055
3131
|
}] } });
|
|
@@ -3061,7 +3137,7 @@ class RenderComponentsForDeviceComponent {
|
|
|
3061
3137
|
this.showDropContainers = false;
|
|
3062
3138
|
}
|
|
3063
3139
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RenderComponentsForDeviceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3064
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: RenderComponentsForDeviceComponent, isStandalone: true, selector: "rulecms-render-for-device", inputs: { displayItemList: "displayItemList", isComposeMode: "isComposeMode", isWithinCollection: "isWithinCollection", widgetCollections: "widgetCollections", showDropContainers: "showDropContainers", reduxDeviceDisplayType: "reduxDeviceDisplayType", deviceDisplayType: "deviceDisplayType", plugins: "plugins", componentProps: "componentProps", mounts: "mounts", ancestorColumnIds: "ancestorColumnIds" }, host: { styleAttribute: "display: contents" }, ngImport: i0, template: `
|
|
3140
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: RenderComponentsForDeviceComponent, isStandalone: true, selector: "rulecms-render-for-device", inputs: { displayItemList: "displayItemList", isComposeMode: "isComposeMode", isWithinCollection: "isWithinCollection", widgetCollections: "widgetCollections", showDropContainers: "showDropContainers", reduxDeviceDisplayType: "reduxDeviceDisplayType", deviceDisplayType: "deviceDisplayType", plugins: "plugins", componentProps: "componentProps", mounts: "mounts", placeholderValues: "placeholderValues", ancestorColumnIds: "ancestorColumnIds" }, host: { styleAttribute: "display: contents" }, ngImport: i0, template: `
|
|
3065
3141
|
@if (displayItemList?.rows?.length) {
|
|
3066
3142
|
<rulecms-render-inner
|
|
3067
3143
|
[displayItemList]="displayItemList"
|
|
@@ -3074,10 +3150,11 @@ class RenderComponentsForDeviceComponent {
|
|
|
3074
3150
|
[deviceDisplayType]="deviceDisplayType"
|
|
3075
3151
|
[componentProps]="componentProps"
|
|
3076
3152
|
[mounts]="mounts"
|
|
3153
|
+
[placeholderValues]="placeholderValues"
|
|
3077
3154
|
[ancestorColumnIds]="ancestorColumnIds"
|
|
3078
3155
|
/>
|
|
3079
3156
|
}
|
|
3080
|
-
`, isInline: true, dependencies: [{ kind: "component", type: RenderComponentsInnerComponent, selector: "rulecms-render-inner", inputs: ["displayItemList", "isComposeMode", "isWithinCollection", "widgetCollections", "showDropContainers", "reduxDeviceDisplayType", "plugins", "deviceDisplayType", "componentProps", "mounts", "ancestorColumnIds"] }] }); }
|
|
3157
|
+
`, isInline: true, dependencies: [{ kind: "component", type: RenderComponentsInnerComponent, selector: "rulecms-render-inner", inputs: ["displayItemList", "isComposeMode", "isWithinCollection", "widgetCollections", "showDropContainers", "reduxDeviceDisplayType", "plugins", "deviceDisplayType", "componentProps", "mounts", "placeholderValues", "ancestorColumnIds"] }] }); }
|
|
3081
3158
|
}
|
|
3082
3159
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RenderComponentsForDeviceComponent, decorators: [{
|
|
3083
3160
|
type: Component,
|
|
@@ -3098,6 +3175,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3098
3175
|
[deviceDisplayType]="deviceDisplayType"
|
|
3099
3176
|
[componentProps]="componentProps"
|
|
3100
3177
|
[mounts]="mounts"
|
|
3178
|
+
[placeholderValues]="placeholderValues"
|
|
3101
3179
|
[ancestorColumnIds]="ancestorColumnIds"
|
|
3102
3180
|
/>
|
|
3103
3181
|
}
|
|
@@ -3128,6 +3206,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3128
3206
|
type: Input
|
|
3129
3207
|
}], mounts: [{
|
|
3130
3208
|
type: Input
|
|
3209
|
+
}], placeholderValues: [{
|
|
3210
|
+
type: Input
|
|
3131
3211
|
}], ancestorColumnIds: [{
|
|
3132
3212
|
type: Input
|
|
3133
3213
|
}] } });
|
|
@@ -3142,7 +3222,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3142
3222
|
class LibraryStylesheetsComponent {
|
|
3143
3223
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LibraryStylesheetsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3144
3224
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: LibraryStylesheetsComponent, isStandalone: true, selector: "rulecms-library-stylesheets", inputs: { stylesheets: "stylesheets" }, host: { styleAttribute: "display: contents" }, ngImport: i0, template: `
|
|
3145
|
-
@for (css of stylesheets ?? []; track
|
|
3225
|
+
@for (css of stylesheets ?? []; track $index) {
|
|
3146
3226
|
<style data-rulecms-library-stylesheet="" [innerText]="css"></style>
|
|
3147
3227
|
}
|
|
3148
3228
|
`, isInline: true }); }
|
|
@@ -3153,7 +3233,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3153
3233
|
selector: 'rulecms-library-stylesheets',
|
|
3154
3234
|
standalone: true,
|
|
3155
3235
|
template: `
|
|
3156
|
-
@for (css of stylesheets ?? []; track
|
|
3236
|
+
@for (css of stylesheets ?? []; track $index) {
|
|
3157
3237
|
<style data-rulecms-library-stylesheet="" [innerText]="css"></style>
|
|
3158
3238
|
}
|
|
3159
3239
|
`,
|
|
@@ -3178,7 +3258,7 @@ class BreakpointVariantRenderComponent {
|
|
|
3178
3258
|
this.variantStyles = buildBreakpointVariantStyles(this.resolvedScopeId);
|
|
3179
3259
|
}
|
|
3180
3260
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: BreakpointVariantRenderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3181
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: BreakpointVariantRenderComponent, isStandalone: true, selector: "rulecms-breakpoint-variants", inputs: { displayItemList: "displayItemList", widgetCollections: "widgetCollections", plugins: "plugins", componentProps: "componentProps", mounts: "mounts", scopeIdInput: "scopeIdInput" }, host: { styleAttribute: "display: contents" }, usesOnChanges: true, ngImport: i0, template: `
|
|
3261
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: BreakpointVariantRenderComponent, isStandalone: true, selector: "rulecms-breakpoint-variants", inputs: { displayItemList: "displayItemList", widgetCollections: "widgetCollections", plugins: "plugins", componentProps: "componentProps", mounts: "mounts", placeholderValues: "placeholderValues", scopeIdInput: "scopeIdInput" }, host: { styleAttribute: "display: contents" }, usesOnChanges: true, ngImport: i0, template: `
|
|
3182
3262
|
<rulecms-library-stylesheets [stylesheets]="plugins.sourceComponents?.stylesheets" />
|
|
3183
3263
|
@if (!divergent) {
|
|
3184
3264
|
<rulecms-render-for-device
|
|
@@ -3192,6 +3272,7 @@ class BreakpointVariantRenderComponent {
|
|
|
3192
3272
|
[plugins]="plugins"
|
|
3193
3273
|
[componentProps]="componentProps"
|
|
3194
3274
|
[mounts]="mounts"
|
|
3275
|
+
[placeholderValues]="placeholderValues"
|
|
3195
3276
|
/>
|
|
3196
3277
|
} @else {
|
|
3197
3278
|
<style [innerText]="variantStyles"></style>
|
|
@@ -3208,11 +3289,12 @@ class BreakpointVariantRenderComponent {
|
|
|
3208
3289
|
[plugins]="plugins"
|
|
3209
3290
|
[componentProps]="componentProps"
|
|
3210
3291
|
[mounts]="mounts"
|
|
3292
|
+
[placeholderValues]="placeholderValues"
|
|
3211
3293
|
/>
|
|
3212
3294
|
</div>
|
|
3213
3295
|
}
|
|
3214
3296
|
}
|
|
3215
|
-
`, isInline: true, dependencies: [{ kind: "component", type: RenderComponentsForDeviceComponent, selector: "rulecms-render-for-device", inputs: ["displayItemList", "isComposeMode", "isWithinCollection", "widgetCollections", "showDropContainers", "reduxDeviceDisplayType", "deviceDisplayType", "plugins", "componentProps", "mounts", "ancestorColumnIds"] }, { kind: "component", type: LibraryStylesheetsComponent, selector: "rulecms-library-stylesheets", inputs: ["stylesheets"] }] }); }
|
|
3297
|
+
`, isInline: true, dependencies: [{ kind: "component", type: RenderComponentsForDeviceComponent, selector: "rulecms-render-for-device", inputs: ["displayItemList", "isComposeMode", "isWithinCollection", "widgetCollections", "showDropContainers", "reduxDeviceDisplayType", "deviceDisplayType", "plugins", "componentProps", "mounts", "placeholderValues", "ancestorColumnIds"] }, { kind: "component", type: LibraryStylesheetsComponent, selector: "rulecms-library-stylesheets", inputs: ["stylesheets"] }] }); }
|
|
3216
3298
|
}
|
|
3217
3299
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: BreakpointVariantRenderComponent, decorators: [{
|
|
3218
3300
|
type: Component,
|
|
@@ -3234,6 +3316,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3234
3316
|
[plugins]="plugins"
|
|
3235
3317
|
[componentProps]="componentProps"
|
|
3236
3318
|
[mounts]="mounts"
|
|
3319
|
+
[placeholderValues]="placeholderValues"
|
|
3237
3320
|
/>
|
|
3238
3321
|
} @else {
|
|
3239
3322
|
<style [innerText]="variantStyles"></style>
|
|
@@ -3250,6 +3333,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3250
3333
|
[plugins]="plugins"
|
|
3251
3334
|
[componentProps]="componentProps"
|
|
3252
3335
|
[mounts]="mounts"
|
|
3336
|
+
[placeholderValues]="placeholderValues"
|
|
3253
3337
|
/>
|
|
3254
3338
|
</div>
|
|
3255
3339
|
}
|
|
@@ -3270,6 +3354,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3270
3354
|
type: Input
|
|
3271
3355
|
}], mounts: [{
|
|
3272
3356
|
type: Input
|
|
3357
|
+
}], placeholderValues: [{
|
|
3358
|
+
type: Input
|
|
3273
3359
|
}], scopeIdInput: [{
|
|
3274
3360
|
type: Input
|
|
3275
3361
|
}] } });
|
|
@@ -3318,7 +3404,7 @@ class RenderComponentsComponent {
|
|
|
3318
3404
|
this.deviceDisplayType = resolveDisplayDeviceType(this.phoneQuery?.matches ?? false, this.tabletQuery?.matches ?? false, this.reduxDeviceDisplayType);
|
|
3319
3405
|
}
|
|
3320
3406
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RenderComponentsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3321
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: RenderComponentsComponent, isStandalone: true, selector: "rulecms-render-components", inputs: { displayItemList: "displayItemList", isComposeMode: "isComposeMode", isWithinCollection: "isWithinCollection", widgetCollections: "widgetCollections", showDropContainers: "showDropContainers", reduxDeviceDisplayType: "reduxDeviceDisplayType", plugins: "plugins", componentProps: "componentProps", mounts: "mounts" }, host: { styleAttribute: "display: contents" }, ngImport: i0, template: `
|
|
3407
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: RenderComponentsComponent, isStandalone: true, selector: "rulecms-render-components", inputs: { displayItemList: "displayItemList", isComposeMode: "isComposeMode", isWithinCollection: "isWithinCollection", widgetCollections: "widgetCollections", showDropContainers: "showDropContainers", reduxDeviceDisplayType: "reduxDeviceDisplayType", plugins: "plugins", componentProps: "componentProps", mounts: "mounts", placeholderValues: "placeholderValues" }, host: { styleAttribute: "display: contents" }, ngImport: i0, template: `
|
|
3322
3408
|
@if (!isWithinCollection) {
|
|
3323
3409
|
<rulecms-library-stylesheets [stylesheets]="plugins.sourceComponents?.stylesheets" />
|
|
3324
3410
|
}
|
|
@@ -3333,8 +3419,9 @@ class RenderComponentsComponent {
|
|
|
3333
3419
|
[plugins]="plugins"
|
|
3334
3420
|
[componentProps]="componentProps"
|
|
3335
3421
|
[mounts]="mounts"
|
|
3422
|
+
[placeholderValues]="placeholderValues"
|
|
3336
3423
|
/>
|
|
3337
|
-
`, isInline: true, dependencies: [{ kind: "component", type: RenderComponentsForDeviceComponent, selector: "rulecms-render-for-device", inputs: ["displayItemList", "isComposeMode", "isWithinCollection", "widgetCollections", "showDropContainers", "reduxDeviceDisplayType", "deviceDisplayType", "plugins", "componentProps", "mounts", "ancestorColumnIds"] }, { kind: "component", type: LibraryStylesheetsComponent, selector: "rulecms-library-stylesheets", inputs: ["stylesheets"] }] }); }
|
|
3424
|
+
`, isInline: true, dependencies: [{ kind: "component", type: RenderComponentsForDeviceComponent, selector: "rulecms-render-for-device", inputs: ["displayItemList", "isComposeMode", "isWithinCollection", "widgetCollections", "showDropContainers", "reduxDeviceDisplayType", "deviceDisplayType", "plugins", "componentProps", "mounts", "placeholderValues", "ancestorColumnIds"] }, { kind: "component", type: LibraryStylesheetsComponent, selector: "rulecms-library-stylesheets", inputs: ["stylesheets"] }] }); }
|
|
3338
3425
|
}
|
|
3339
3426
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RenderComponentsComponent, decorators: [{
|
|
3340
3427
|
type: Component,
|
|
@@ -3357,6 +3444,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3357
3444
|
[plugins]="plugins"
|
|
3358
3445
|
[componentProps]="componentProps"
|
|
3359
3446
|
[mounts]="mounts"
|
|
3447
|
+
[placeholderValues]="placeholderValues"
|
|
3360
3448
|
/>
|
|
3361
3449
|
`,
|
|
3362
3450
|
host: { style: 'display: contents' },
|
|
@@ -3382,6 +3470,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3382
3470
|
type: Input
|
|
3383
3471
|
}], mounts: [{
|
|
3384
3472
|
type: Input
|
|
3473
|
+
}], placeholderValues: [{
|
|
3474
|
+
type: Input
|
|
3385
3475
|
}] } });
|
|
3386
3476
|
|
|
3387
3477
|
/**
|
|
@@ -4732,6 +4822,152 @@ function resolveSourceComponentsPlugin(params) {
|
|
|
4732
4822
|
return registry.resolve({ registrations: params.libraries, referenced });
|
|
4733
4823
|
}
|
|
4734
4824
|
|
|
4825
|
+
/**
|
|
4826
|
+
* The draft resolve route wants the bare `ruleset-…` key. Callers may hand us
|
|
4827
|
+
* a published key (`{environmentId}---ruleset-…`) out of habit; strip the
|
|
4828
|
+
* environment prefix so both spellings work with a `dev.` token.
|
|
4829
|
+
*/
|
|
4830
|
+
function toRulesetKey(rulesetPublishedKey) {
|
|
4831
|
+
const separatorIndex = rulesetPublishedKey.lastIndexOf(PUBLISHED_KEY_SEPARATOR);
|
|
4832
|
+
return separatorIndex === -1
|
|
4833
|
+
? rulesetPublishedKey
|
|
4834
|
+
: rulesetPublishedKey.slice(separatorIndex + PUBLISHED_KEY_SEPARATOR.length);
|
|
4835
|
+
}
|
|
4836
|
+
|
|
4837
|
+
const DEFAULT_WIDGET_RESOLVE_CONTENT_TYPE = 'text/plain';
|
|
4838
|
+
/**
|
|
4839
|
+
* Body for the resolve POST. Published tokens send
|
|
4840
|
+
* `{ token, rulesetPublishedKey, params, mode: 'payload' }`; `dev.` tokens hit
|
|
4841
|
+
* the draft route, which wants the bare `rulesetKey` and no `mode`.
|
|
4842
|
+
*/
|
|
4843
|
+
function buildWidgetResolveRequestBody({ token, rulesetPublishedKey, params, }) {
|
|
4844
|
+
if (isDevClientToken(token)) {
|
|
4845
|
+
return {
|
|
4846
|
+
token,
|
|
4847
|
+
rulesetKey: toRulesetKey(rulesetPublishedKey),
|
|
4848
|
+
...(params ? { params } : {}),
|
|
4849
|
+
};
|
|
4850
|
+
}
|
|
4851
|
+
return {
|
|
4852
|
+
token,
|
|
4853
|
+
rulesetPublishedKey,
|
|
4854
|
+
...(params ? { params } : {}),
|
|
4855
|
+
mode: 'payload',
|
|
4856
|
+
};
|
|
4857
|
+
}
|
|
4858
|
+
/**
|
|
4859
|
+
* `fetch` init for the resolve POST. `Content-Type` is the only header —
|
|
4860
|
+
* `text/plain` keeps the request CORS-simple (no preflight); anything else
|
|
4861
|
+
* would add one, so nothing else is set here.
|
|
4862
|
+
*/
|
|
4863
|
+
function buildWidgetResolveRequestInit({ contentType = DEFAULT_WIDGET_RESOLVE_CONTENT_TYPE, ...bodyParams }) {
|
|
4864
|
+
return {
|
|
4865
|
+
method: 'POST',
|
|
4866
|
+
headers: { 'Content-Type': contentType },
|
|
4867
|
+
body: JSON.stringify(buildWidgetResolveRequestBody(bodyParams)),
|
|
4868
|
+
};
|
|
4869
|
+
}
|
|
4870
|
+
|
|
4871
|
+
/** First-party `localStorage` key holding the SDK-generated anonymous id. */
|
|
4872
|
+
const RULECMS_ANONYMOUS_ID_STORAGE_KEY = 'rulecms_anon_id';
|
|
4873
|
+
function generateUuid() {
|
|
4874
|
+
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
4875
|
+
return crypto.randomUUID();
|
|
4876
|
+
}
|
|
4877
|
+
// RFC 4122 v4 layout from Math.random — only for engines without crypto.randomUUID.
|
|
4878
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (char) => {
|
|
4879
|
+
const nibble = (Math.random() * 16) | 0;
|
|
4880
|
+
return (char === 'x' ? nibble : (nibble & 0x3) | 0x8).toString(16);
|
|
4881
|
+
});
|
|
4882
|
+
}
|
|
4883
|
+
/**
|
|
4884
|
+
* Returns the anonymous id used as `params.anonId` for experiments, minting
|
|
4885
|
+
* and persisting one in `localStorage` on first use. Browser-only: returns
|
|
4886
|
+
* `undefined` outside a window (SSR) so the server never invents an id, and
|
|
4887
|
+
* when storage is unavailable (private mode, blocked third-party context) a
|
|
4888
|
+
* per-page-load id is returned without persisting.
|
|
4889
|
+
*/
|
|
4890
|
+
function getOrCreateAnonymousId() {
|
|
4891
|
+
if (typeof window === 'undefined') {
|
|
4892
|
+
return undefined;
|
|
4893
|
+
}
|
|
4894
|
+
try {
|
|
4895
|
+
const existing = window.localStorage.getItem(RULECMS_ANONYMOUS_ID_STORAGE_KEY);
|
|
4896
|
+
if (existing) {
|
|
4897
|
+
return existing;
|
|
4898
|
+
}
|
|
4899
|
+
const created = generateUuid();
|
|
4900
|
+
window.localStorage.setItem(RULECMS_ANONYMOUS_ID_STORAGE_KEY, created);
|
|
4901
|
+
return created;
|
|
4902
|
+
}
|
|
4903
|
+
catch {
|
|
4904
|
+
return generateUuid();
|
|
4905
|
+
}
|
|
4906
|
+
}
|
|
4907
|
+
|
|
4908
|
+
/**
|
|
4909
|
+
* Whether a failed resolve response should be retried through the plain GET of
|
|
4910
|
+
* `fallbackPublishedKey`. Only server-side failures (5xx) qualify: a 4xx means
|
|
4911
|
+
* the request itself is wrong (bad token, unknown ruleset, environment
|
|
4912
|
+
* mismatch), and a fallback widget would just mask that.
|
|
4913
|
+
*/
|
|
4914
|
+
function isWidgetResolveFallbackStatus(status) {
|
|
4915
|
+
return status >= 500;
|
|
4916
|
+
}
|
|
4917
|
+
|
|
4918
|
+
function normalizePublishedResolveResponse(body) {
|
|
4919
|
+
if (!body?.success || !body.data) {
|
|
4920
|
+
return null;
|
|
4921
|
+
}
|
|
4922
|
+
const { selection, ...raw } = body.data;
|
|
4923
|
+
return { raw, selection };
|
|
4924
|
+
}
|
|
4925
|
+
function normalizeDevResolveResponse(body, rulesetPublishedKey) {
|
|
4926
|
+
if (!body?.resolution || !body.widget) {
|
|
4927
|
+
return null;
|
|
4928
|
+
}
|
|
4929
|
+
const { resolution, ...raw } = body;
|
|
4930
|
+
const selection = {
|
|
4931
|
+
rulesetPublishedKey,
|
|
4932
|
+
outcome: resolution.outcome,
|
|
4933
|
+
ruleId: resolution.ruleId ?? null,
|
|
4934
|
+
variantId: resolution.variantId ?? null,
|
|
4935
|
+
widgetKey: resolution.widgetKey,
|
|
4936
|
+
widgetPublishedKey: resolution.widgetPublishedKey,
|
|
4937
|
+
};
|
|
4938
|
+
return { raw, selection };
|
|
4939
|
+
}
|
|
4940
|
+
/**
|
|
4941
|
+
* Reduces either resolve response shape to the existing widget payload plus a
|
|
4942
|
+
* `selection`. Published: `{ success, data: { …payload, selection } }`.
|
|
4943
|
+
* Draft (`dev.` token): unwrapped `{ resolution, widget, childCollections, …css }`.
|
|
4944
|
+
* Returns `null` when the body is not a successful resolve.
|
|
4945
|
+
*/
|
|
4946
|
+
function normalizeWidgetResolveResponse({ token, rulesetPublishedKey, body, }) {
|
|
4947
|
+
return isDevClientToken(token)
|
|
4948
|
+
? normalizeDevResolveResponse(body, rulesetPublishedKey)
|
|
4949
|
+
: normalizePublishedResolveResponse(body);
|
|
4950
|
+
}
|
|
4951
|
+
|
|
4952
|
+
/**
|
|
4953
|
+
* `JSON.stringify` with object keys sorted at every depth, so two objects with
|
|
4954
|
+
* the same values serialize identically regardless of insertion order. Used as
|
|
4955
|
+
* the effect dependency for resolve `params`: a fresh `{ b, a }` on every render
|
|
4956
|
+
* must not trigger a refetch when `{ a, b }` was already sent.
|
|
4957
|
+
*/
|
|
4958
|
+
function stableJsonStringify(value) {
|
|
4959
|
+
return JSON.stringify(value, (_key, current) => {
|
|
4960
|
+
if (current === null || typeof current !== 'object' || Array.isArray(current)) {
|
|
4961
|
+
return current;
|
|
4962
|
+
}
|
|
4963
|
+
const sorted = {};
|
|
4964
|
+
for (const key of Object.keys(current).sort()) {
|
|
4965
|
+
sorted[key] = current[key];
|
|
4966
|
+
}
|
|
4967
|
+
return sorted;
|
|
4968
|
+
});
|
|
4969
|
+
}
|
|
4970
|
+
|
|
4735
4971
|
const loadingContainerStyle = {
|
|
4736
4972
|
display: 'flex',
|
|
4737
4973
|
justifyContent: 'center',
|
|
@@ -4785,11 +5021,19 @@ class RuleCMSWidgetComponent {
|
|
|
4785
5021
|
constructor(context, errorHandler) {
|
|
4786
5022
|
this.context = context;
|
|
4787
5023
|
this.errorHandler = errorHandler;
|
|
5024
|
+
/**
|
|
5025
|
+
* Staging/production: published key (`{environmentId}---{widgetKey}`).
|
|
5026
|
+
* Development (`dev.` token): the live widget key itself (`widget-...`).
|
|
5027
|
+
* Omit when `rulesetPublishedKey` is set — the ruleset picks the widget.
|
|
5028
|
+
*/
|
|
5029
|
+
this.publishedKey = '';
|
|
4788
5030
|
/**
|
|
4789
5031
|
* `'client-fetch'` (default) fetches in the browser.
|
|
4790
5032
|
* `'pre-fetched'` renders `initialData` with CSS breakpoint variants.
|
|
4791
5033
|
*/
|
|
4792
5034
|
this.mode = 'client-fetch';
|
|
5035
|
+
/** Fires when a ruleset resolve returns a selection. */
|
|
5036
|
+
this.selectionChange = new EventEmitter();
|
|
4793
5037
|
this.publishedKeyAttribute = RULECMS_PUBLISHED_KEY_ATTRIBUTE;
|
|
4794
5038
|
this.loadingContainerStyle = loadingContainerStyle;
|
|
4795
5039
|
this.spinnerContainerStyle = spinnerContainerStyle;
|
|
@@ -4797,18 +5041,26 @@ class RuleCMSWidgetComponent {
|
|
|
4797
5041
|
this.errorContainerStyle = errorContainerStyle;
|
|
4798
5042
|
this.errorTitleStyle = errorTitleStyle;
|
|
4799
5043
|
this.errorMessageStyle = errorMessageStyle;
|
|
4800
|
-
this.loading =
|
|
5044
|
+
this.loading = true;
|
|
4801
5045
|
this.error = null;
|
|
4802
5046
|
this.preparedData = null;
|
|
4803
5047
|
this.sourceComponentsPlugin = null;
|
|
4804
5048
|
this.useBreakpointVariants = false;
|
|
5049
|
+
this.selection = null;
|
|
5050
|
+
/** Published key of the widget a ruleset chose, when `publishedKey` was omitted. */
|
|
5051
|
+
this.resolvedPublishedKey = '';
|
|
4805
5052
|
this.abortController = null;
|
|
4806
5053
|
this.lastFetchKey = null;
|
|
4807
5054
|
this.stylesInjected = false;
|
|
5055
|
+
this.fetchGeneration = 0;
|
|
4808
5056
|
}
|
|
4809
5057
|
get plugins() {
|
|
4810
5058
|
return { sourceComponents: this.sourceComponentsPlugin ?? undefined };
|
|
4811
5059
|
}
|
|
5060
|
+
/** Ruleset mode has no publishedKey; the root then carries the chosen widget's key. */
|
|
5061
|
+
get renderPublishedKey() {
|
|
5062
|
+
return this.publishedKey || this.resolvedPublishedKey;
|
|
5063
|
+
}
|
|
4812
5064
|
ngOnInit() {
|
|
4813
5065
|
this.syncFromInputs();
|
|
4814
5066
|
}
|
|
@@ -4871,23 +5123,46 @@ class RuleCMSWidgetComponent {
|
|
|
4871
5123
|
componentProps: this.componentProps,
|
|
4872
5124
|
displayItemList: this.preparedData.displayItemList,
|
|
4873
5125
|
widgetCollections: this.preparedData.widgetCollections,
|
|
4874
|
-
publishedKey: this.
|
|
5126
|
+
publishedKey: this.renderPublishedKey,
|
|
4875
5127
|
});
|
|
4876
5128
|
}
|
|
4877
5129
|
fetchClient() {
|
|
4878
5130
|
const token = this.token ?? this.context?.token;
|
|
4879
5131
|
const endpoint = this.endpoint ?? this.context?.endpoint;
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
5132
|
+
const isDev = isDevClientToken(token);
|
|
5133
|
+
const rulesetKey = this.rulesetPublishedKey;
|
|
5134
|
+
if ((!this.publishedKey && !rulesetKey) || !token) {
|
|
5135
|
+
if (!this.publishedKey && !rulesetKey) {
|
|
5136
|
+
this.error =
|
|
5137
|
+
rulesetKey !== undefined
|
|
5138
|
+
? isDev
|
|
5139
|
+
? 'Ruleset key is required'
|
|
5140
|
+
: 'Ruleset published key is required'
|
|
5141
|
+
: isDev
|
|
5142
|
+
? 'Widget key is required'
|
|
5143
|
+
: 'Published key is required';
|
|
5144
|
+
}
|
|
5145
|
+
else {
|
|
5146
|
+
this.error =
|
|
5147
|
+
'Token is required. Provide it either directly as an input ([token]) or via rulecms-widget-provider.';
|
|
5148
|
+
}
|
|
4886
5149
|
this.preparedData = null;
|
|
5150
|
+
this.loading = false;
|
|
4887
5151
|
return;
|
|
4888
5152
|
}
|
|
4889
|
-
const
|
|
5153
|
+
const paramsKey = stableJsonStringify(this.params);
|
|
5154
|
+
const fetchKey = JSON.stringify({
|
|
5155
|
+
publishedKey: this.publishedKey,
|
|
5156
|
+
rulesetPublishedKey: rulesetKey,
|
|
5157
|
+
token,
|
|
5158
|
+
endpoint,
|
|
5159
|
+
paramsKey,
|
|
5160
|
+
anonymousId: this.anonymousId,
|
|
5161
|
+
fallbackPublishedKey: this.fallbackPublishedKey,
|
|
5162
|
+
contentType: this.contentType,
|
|
5163
|
+
});
|
|
4890
5164
|
if (this.lastFetchKey === fetchKey && this.preparedData) {
|
|
5165
|
+
this.loading = false;
|
|
4891
5166
|
this.resolveLibraries();
|
|
4892
5167
|
return;
|
|
4893
5168
|
}
|
|
@@ -4897,31 +5172,91 @@ class RuleCMSWidgetComponent {
|
|
|
4897
5172
|
this.lastFetchKey = fetchKey;
|
|
4898
5173
|
this.loading = true;
|
|
4899
5174
|
this.error = null;
|
|
4900
|
-
const
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
5175
|
+
const requestId = ++this.fetchGeneration;
|
|
5176
|
+
const readErrorMessage = async (response) => {
|
|
5177
|
+
const errorData = await response.json().catch(() => ({ error: 'Unknown error' }));
|
|
5178
|
+
return errorData.error || `Request failed with status ${response.status}`;
|
|
5179
|
+
};
|
|
5180
|
+
const getPublishedWidget = async (key) => {
|
|
5181
|
+
const url = buildWidgetFetchUrl({ publishedKey: key, token, endpoint });
|
|
5182
|
+
const response = await fetch(url, {
|
|
5183
|
+
method: 'GET',
|
|
5184
|
+
...(isDev ? { cache: 'no-store' } : {}),
|
|
5185
|
+
signal,
|
|
5186
|
+
});
|
|
5187
|
+
if (!response.ok) {
|
|
5188
|
+
throw new FetchWidgetMessage(await readErrorMessage(response));
|
|
5189
|
+
}
|
|
5190
|
+
const data = await response.json();
|
|
5191
|
+
if (!data.success) {
|
|
5192
|
+
throw new FetchWidgetMessage('Failed to fetch widget data');
|
|
5193
|
+
}
|
|
5194
|
+
return data.data;
|
|
5195
|
+
};
|
|
5196
|
+
const resolveWidget = async () => {
|
|
5197
|
+
const requestParams = paramsKey ? JSON.parse(paramsKey) : {};
|
|
5198
|
+
if (this.anonymousId === false) {
|
|
5199
|
+
// Host opted out of an anonymous id.
|
|
5200
|
+
}
|
|
5201
|
+
else if (typeof this.anonymousId === 'string') {
|
|
5202
|
+
requestParams.anonId = requestParams.anonId ?? this.anonymousId;
|
|
5203
|
+
}
|
|
5204
|
+
else if (requestParams.anonId == null) {
|
|
5205
|
+
const minted = getOrCreateAnonymousId();
|
|
5206
|
+
if (minted) {
|
|
5207
|
+
requestParams.anonId = minted;
|
|
4915
5208
|
}
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
5209
|
+
}
|
|
5210
|
+
let response;
|
|
5211
|
+
try {
|
|
5212
|
+
response = await fetch(buildWidgetResolveUrl({ token, endpoint }), {
|
|
5213
|
+
...buildWidgetResolveRequestInit({
|
|
5214
|
+
token,
|
|
5215
|
+
rulesetPublishedKey: rulesetKey,
|
|
5216
|
+
params: requestParams,
|
|
5217
|
+
contentType: this.contentType,
|
|
5218
|
+
}),
|
|
5219
|
+
signal,
|
|
5220
|
+
});
|
|
5221
|
+
}
|
|
5222
|
+
catch (err) {
|
|
5223
|
+
if (err instanceof DOMException && err.name === 'AbortError') {
|
|
5224
|
+
throw err;
|
|
5225
|
+
}
|
|
5226
|
+
if (this.fallbackPublishedKey) {
|
|
5227
|
+
return { raw: await getPublishedWidget(this.fallbackPublishedKey), selection: null };
|
|
4919
5228
|
}
|
|
5229
|
+
throw err;
|
|
4920
5230
|
}
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
5231
|
+
if (!response.ok) {
|
|
5232
|
+
if (this.fallbackPublishedKey && isWidgetResolveFallbackStatus(response.status)) {
|
|
5233
|
+
return { raw: await getPublishedWidget(this.fallbackPublishedKey), selection: null };
|
|
5234
|
+
}
|
|
5235
|
+
throw new FetchWidgetMessage(await readErrorMessage(response));
|
|
5236
|
+
}
|
|
5237
|
+
const normalized = normalizeWidgetResolveResponse({
|
|
5238
|
+
token,
|
|
5239
|
+
rulesetPublishedKey: rulesetKey,
|
|
5240
|
+
body: await response.json(),
|
|
5241
|
+
});
|
|
5242
|
+
if (!normalized) {
|
|
5243
|
+
throw new FetchWidgetMessage('Failed to fetch widget data');
|
|
5244
|
+
}
|
|
5245
|
+
return { raw: normalized.raw, selection: normalized.selection };
|
|
5246
|
+
};
|
|
5247
|
+
const run = rulesetKey
|
|
5248
|
+
? resolveWidget()
|
|
5249
|
+
: getPublishedWidget(this.publishedKey).then((raw) => ({ raw, selection: null }));
|
|
5250
|
+
run
|
|
5251
|
+
.then(({ raw, selection }) => {
|
|
5252
|
+
this.preparedData = prepareRuleCMSWidgetData(raw);
|
|
5253
|
+
this.resolvedPublishedKey = raw.widget?.publishedKey ?? '';
|
|
5254
|
+
this.selection = selection;
|
|
5255
|
+
this.error = null;
|
|
5256
|
+
this.resolveLibraries();
|
|
5257
|
+
this.warnUnmatched();
|
|
5258
|
+
if (selection) {
|
|
5259
|
+
this.selectionChange.emit(selection);
|
|
4925
5260
|
}
|
|
4926
5261
|
})
|
|
4927
5262
|
.catch((err) => {
|
|
@@ -4929,11 +5264,14 @@ class RuleCMSWidgetComponent {
|
|
|
4929
5264
|
return;
|
|
4930
5265
|
}
|
|
4931
5266
|
console.error('Error fetching widget:', err);
|
|
4932
|
-
this.error = 'Failed to fetch widget';
|
|
5267
|
+
this.error = err instanceof FetchWidgetMessage ? err.message : 'Failed to fetch widget';
|
|
4933
5268
|
this.preparedData = null;
|
|
5269
|
+
this.selection = null;
|
|
4934
5270
|
})
|
|
4935
5271
|
.finally(() => {
|
|
4936
|
-
this.
|
|
5272
|
+
if (this.fetchGeneration === requestId) {
|
|
5273
|
+
this.loading = false;
|
|
5274
|
+
}
|
|
4937
5275
|
});
|
|
4938
5276
|
}
|
|
4939
5277
|
ensureSpinnerStyles() {
|
|
@@ -4950,38 +5288,38 @@ class RuleCMSWidgetComponent {
|
|
|
4950
5288
|
this.stylesInjected = true;
|
|
4951
5289
|
}
|
|
4952
5290
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RuleCMSWidgetComponent, deps: [{ token: RuleCMSWidgetContextService, optional: true }, { token: ErrorHandler, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
4953
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: RuleCMSWidgetComponent, isStandalone: true, selector: "rulecms-widget", inputs: { publishedKey: "publishedKey", token: "token", endpoint: "endpoint", mode: "mode", initialData: "initialData", libraries: "libraries", componentProps: "componentProps", mounts: "mounts" }, host: { styleAttribute: "display: contents" }, usesOnChanges: true, ngImport: i0, template: `
|
|
4954
|
-
<span [attr.data-rulecms-published-key]="
|
|
5291
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: RuleCMSWidgetComponent, isStandalone: true, selector: "rulecms-widget", inputs: { publishedKey: "publishedKey", rulesetPublishedKey: "rulesetPublishedKey", params: "params", anonymousId: "anonymousId", fallbackPublishedKey: "fallbackPublishedKey", contentType: "contentType", token: "token", endpoint: "endpoint", mode: "mode", initialData: "initialData", libraries: "libraries", componentProps: "componentProps", mounts: "mounts", placeholderValues: "placeholderValues" }, outputs: { selectionChange: "selectionChange" }, host: { styleAttribute: "display: contents" }, usesOnChanges: true, ngImport: i0, template: `
|
|
5292
|
+
<span [attr.data-rulecms-published-key]="renderPublishedKey" style="display: contents">
|
|
4955
5293
|
<rulecms-project-css-fonts-stylesheet
|
|
4956
|
-
[publishedKey]="
|
|
5294
|
+
[publishedKey]="renderPublishedKey"
|
|
4957
5295
|
[fonts]="preparedData?.fontFaces"
|
|
4958
5296
|
/>
|
|
4959
5297
|
<rulecms-project-css-keyframes-stylesheet
|
|
4960
|
-
[publishedKey]="
|
|
5298
|
+
[publishedKey]="renderPublishedKey"
|
|
4961
5299
|
[keyframes]="preparedData?.keyframes"
|
|
4962
5300
|
/>
|
|
4963
5301
|
<rulecms-project-css-themes-stylesheet
|
|
4964
|
-
[publishedKey]="
|
|
5302
|
+
[publishedKey]="renderPublishedKey"
|
|
4965
5303
|
[themes]="preparedData?.themes"
|
|
4966
5304
|
/>
|
|
4967
5305
|
<rulecms-project-css-properties-stylesheet
|
|
4968
|
-
[publishedKey]="
|
|
5306
|
+
[publishedKey]="renderPublishedKey"
|
|
4969
5307
|
[cssProperties]="preparedData?.cssProperties"
|
|
4970
5308
|
/>
|
|
4971
5309
|
<rulecms-project-css-widget-chrome-stylesheet
|
|
4972
|
-
[publishedKey]="
|
|
5310
|
+
[publishedKey]="renderPublishedKey"
|
|
4973
5311
|
[widgetChrome]="preparedData?.widgetChrome"
|
|
4974
5312
|
/>
|
|
4975
5313
|
<rulecms-project-css-position-try-stylesheet
|
|
4976
|
-
[publishedKey]="
|
|
5314
|
+
[publishedKey]="renderPublishedKey"
|
|
4977
5315
|
[positionTry]="preparedData?.positionTry"
|
|
4978
5316
|
/>
|
|
4979
5317
|
<rulecms-project-css-variables-stylesheet
|
|
4980
|
-
[publishedKey]="
|
|
5318
|
+
[publishedKey]="renderPublishedKey"
|
|
4981
5319
|
[variables]="preparedData?.cssVariables"
|
|
4982
5320
|
/>
|
|
4983
5321
|
<rulecms-project-css-classes-stylesheet
|
|
4984
|
-
[publishedKey]="
|
|
5322
|
+
[publishedKey]="renderPublishedKey"
|
|
4985
5323
|
[classes]="preparedData?.classDefinitions"
|
|
4986
5324
|
[classLayer]="preparedData?.classLayer"
|
|
4987
5325
|
/>
|
|
@@ -5009,6 +5347,7 @@ class RuleCMSWidgetComponent {
|
|
|
5009
5347
|
[plugins]="plugins"
|
|
5010
5348
|
[componentProps]="componentProps"
|
|
5011
5349
|
[mounts]="mounts"
|
|
5350
|
+
[placeholderValues]="placeholderValues"
|
|
5012
5351
|
/>
|
|
5013
5352
|
} @else {
|
|
5014
5353
|
<rulecms-render-components
|
|
@@ -5021,11 +5360,12 @@ class RuleCMSWidgetComponent {
|
|
|
5021
5360
|
[plugins]="plugins"
|
|
5022
5361
|
[componentProps]="componentProps"
|
|
5023
5362
|
[mounts]="mounts"
|
|
5363
|
+
[placeholderValues]="placeholderValues"
|
|
5024
5364
|
/>
|
|
5025
5365
|
}
|
|
5026
5366
|
}
|
|
5027
5367
|
</span>
|
|
5028
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: BreakpointVariantRenderComponent, selector: "rulecms-breakpoint-variants", inputs: ["displayItemList", "widgetCollections", "plugins", "componentProps", "mounts", "scopeIdInput"] }, { kind: "component", type: RenderComponentsComponent, selector: "rulecms-render-components", inputs: ["displayItemList", "isComposeMode", "isWithinCollection", "widgetCollections", "showDropContainers", "reduxDeviceDisplayType", "plugins", "componentProps", "mounts"] }, { kind: "component", type: ProjectCssVariablesStylesheetComponent, selector: "rulecms-project-css-variables-stylesheet", inputs: ["publishedKey", "variables"] }, { kind: "component", type: ProjectCssClassesStylesheetComponent, selector: "rulecms-project-css-classes-stylesheet", inputs: ["publishedKey", "classes", "classLayer"] }, { kind: "component", type: ProjectCssFontsStylesheetComponent, selector: "rulecms-project-css-fonts-stylesheet", inputs: ["publishedKey", "fonts", "includeFontFaces"] }, { kind: "component", type: ProjectCssKeyframesStylesheetComponent, selector: "rulecms-project-css-keyframes-stylesheet", inputs: ["publishedKey", "keyframes"] }, { kind: "component", type: ProjectCssThemesStylesheetComponent, selector: "rulecms-project-css-themes-stylesheet", inputs: ["publishedKey", "themes"] }, { kind: "component", type: ProjectCssPropertiesStylesheetComponent, selector: "rulecms-project-css-properties-stylesheet", inputs: ["publishedKey", "cssProperties"] }, { kind: "component", type: ProjectCssWidgetChromeStylesheetComponent, selector: "rulecms-project-css-widget-chrome-stylesheet", inputs: ["publishedKey", "widgetChrome"] }, { kind: "component", type: ProjectCssPositionTryStylesheetComponent, selector: "rulecms-project-css-position-try-stylesheet", inputs: ["publishedKey", "positionTry"] }] }); }
|
|
5368
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: BreakpointVariantRenderComponent, selector: "rulecms-breakpoint-variants", inputs: ["displayItemList", "widgetCollections", "plugins", "componentProps", "mounts", "placeholderValues", "scopeIdInput"] }, { kind: "component", type: RenderComponentsComponent, selector: "rulecms-render-components", inputs: ["displayItemList", "isComposeMode", "isWithinCollection", "widgetCollections", "showDropContainers", "reduxDeviceDisplayType", "plugins", "componentProps", "mounts", "placeholderValues"] }, { kind: "component", type: ProjectCssVariablesStylesheetComponent, selector: "rulecms-project-css-variables-stylesheet", inputs: ["publishedKey", "variables"] }, { kind: "component", type: ProjectCssClassesStylesheetComponent, selector: "rulecms-project-css-classes-stylesheet", inputs: ["publishedKey", "classes", "classLayer"] }, { kind: "component", type: ProjectCssFontsStylesheetComponent, selector: "rulecms-project-css-fonts-stylesheet", inputs: ["publishedKey", "fonts", "includeFontFaces"] }, { kind: "component", type: ProjectCssKeyframesStylesheetComponent, selector: "rulecms-project-css-keyframes-stylesheet", inputs: ["publishedKey", "keyframes"] }, { kind: "component", type: ProjectCssThemesStylesheetComponent, selector: "rulecms-project-css-themes-stylesheet", inputs: ["publishedKey", "themes"] }, { kind: "component", type: ProjectCssPropertiesStylesheetComponent, selector: "rulecms-project-css-properties-stylesheet", inputs: ["publishedKey", "cssProperties"] }, { kind: "component", type: ProjectCssWidgetChromeStylesheetComponent, selector: "rulecms-project-css-widget-chrome-stylesheet", inputs: ["publishedKey", "widgetChrome"] }, { kind: "component", type: ProjectCssPositionTryStylesheetComponent, selector: "rulecms-project-css-position-try-stylesheet", inputs: ["publishedKey", "positionTry"] }] }); }
|
|
5029
5369
|
}
|
|
5030
5370
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RuleCMSWidgetComponent, decorators: [{
|
|
5031
5371
|
type: Component,
|
|
@@ -5046,37 +5386,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
5046
5386
|
ProjectCssPositionTryStylesheetComponent,
|
|
5047
5387
|
],
|
|
5048
5388
|
template: `
|
|
5049
|
-
<span [attr.data-rulecms-published-key]="
|
|
5389
|
+
<span [attr.data-rulecms-published-key]="renderPublishedKey" style="display: contents">
|
|
5050
5390
|
<rulecms-project-css-fonts-stylesheet
|
|
5051
|
-
[publishedKey]="
|
|
5391
|
+
[publishedKey]="renderPublishedKey"
|
|
5052
5392
|
[fonts]="preparedData?.fontFaces"
|
|
5053
5393
|
/>
|
|
5054
5394
|
<rulecms-project-css-keyframes-stylesheet
|
|
5055
|
-
[publishedKey]="
|
|
5395
|
+
[publishedKey]="renderPublishedKey"
|
|
5056
5396
|
[keyframes]="preparedData?.keyframes"
|
|
5057
5397
|
/>
|
|
5058
5398
|
<rulecms-project-css-themes-stylesheet
|
|
5059
|
-
[publishedKey]="
|
|
5399
|
+
[publishedKey]="renderPublishedKey"
|
|
5060
5400
|
[themes]="preparedData?.themes"
|
|
5061
5401
|
/>
|
|
5062
5402
|
<rulecms-project-css-properties-stylesheet
|
|
5063
|
-
[publishedKey]="
|
|
5403
|
+
[publishedKey]="renderPublishedKey"
|
|
5064
5404
|
[cssProperties]="preparedData?.cssProperties"
|
|
5065
5405
|
/>
|
|
5066
5406
|
<rulecms-project-css-widget-chrome-stylesheet
|
|
5067
|
-
[publishedKey]="
|
|
5407
|
+
[publishedKey]="renderPublishedKey"
|
|
5068
5408
|
[widgetChrome]="preparedData?.widgetChrome"
|
|
5069
5409
|
/>
|
|
5070
5410
|
<rulecms-project-css-position-try-stylesheet
|
|
5071
|
-
[publishedKey]="
|
|
5411
|
+
[publishedKey]="renderPublishedKey"
|
|
5072
5412
|
[positionTry]="preparedData?.positionTry"
|
|
5073
5413
|
/>
|
|
5074
5414
|
<rulecms-project-css-variables-stylesheet
|
|
5075
|
-
[publishedKey]="
|
|
5415
|
+
[publishedKey]="renderPublishedKey"
|
|
5076
5416
|
[variables]="preparedData?.cssVariables"
|
|
5077
5417
|
/>
|
|
5078
5418
|
<rulecms-project-css-classes-stylesheet
|
|
5079
|
-
[publishedKey]="
|
|
5419
|
+
[publishedKey]="renderPublishedKey"
|
|
5080
5420
|
[classes]="preparedData?.classDefinitions"
|
|
5081
5421
|
[classLayer]="preparedData?.classLayer"
|
|
5082
5422
|
/>
|
|
@@ -5104,6 +5444,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
5104
5444
|
[plugins]="plugins"
|
|
5105
5445
|
[componentProps]="componentProps"
|
|
5106
5446
|
[mounts]="mounts"
|
|
5447
|
+
[placeholderValues]="placeholderValues"
|
|
5107
5448
|
/>
|
|
5108
5449
|
} @else {
|
|
5109
5450
|
<rulecms-render-components
|
|
@@ -5116,6 +5457,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
5116
5457
|
[plugins]="plugins"
|
|
5117
5458
|
[componentProps]="componentProps"
|
|
5118
5459
|
[mounts]="mounts"
|
|
5460
|
+
[placeholderValues]="placeholderValues"
|
|
5119
5461
|
/>
|
|
5120
5462
|
}
|
|
5121
5463
|
}
|
|
@@ -5131,8 +5473,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
5131
5473
|
type: Inject,
|
|
5132
5474
|
args: [ErrorHandler]
|
|
5133
5475
|
}] }], propDecorators: { publishedKey: [{
|
|
5134
|
-
type: Input
|
|
5135
|
-
|
|
5476
|
+
type: Input
|
|
5477
|
+
}], rulesetPublishedKey: [{
|
|
5478
|
+
type: Input
|
|
5479
|
+
}], params: [{
|
|
5480
|
+
type: Input
|
|
5481
|
+
}], anonymousId: [{
|
|
5482
|
+
type: Input
|
|
5483
|
+
}], fallbackPublishedKey: [{
|
|
5484
|
+
type: Input
|
|
5485
|
+
}], contentType: [{
|
|
5486
|
+
type: Input
|
|
5136
5487
|
}], token: [{
|
|
5137
5488
|
type: Input
|
|
5138
5489
|
}], endpoint: [{
|
|
@@ -5147,8 +5498,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
5147
5498
|
type: Input
|
|
5148
5499
|
}], mounts: [{
|
|
5149
5500
|
type: Input
|
|
5501
|
+
}], placeholderValues: [{
|
|
5502
|
+
type: Input
|
|
5503
|
+
}], selectionChange: [{
|
|
5504
|
+
type: Output
|
|
5150
5505
|
}] } });
|
|
5506
|
+
class FetchWidgetMessage extends Error {
|
|
5507
|
+
constructor(message) {
|
|
5508
|
+
super(message);
|
|
5509
|
+
this.name = 'FetchWidgetMessage';
|
|
5510
|
+
}
|
|
5511
|
+
}
|
|
5151
5512
|
|
|
5513
|
+
/**
|
|
5514
|
+
* How long a published-token GET stays in the in-process cache when the caller
|
|
5515
|
+
* sets no cache policy. Angular has no Next.js `next.revalidate`; this is the
|
|
5516
|
+
* same 60-second default `@rulecms/widget-react` applies on the server.
|
|
5517
|
+
*/
|
|
5518
|
+
const DEFAULT_PUBLISHED_WIDGET_CACHE_MS = 60_000;
|
|
5152
5519
|
class FetchRuleCMSWidgetError extends Error {
|
|
5153
5520
|
constructor(message, status) {
|
|
5154
5521
|
super(message);
|
|
@@ -5156,31 +5523,124 @@ class FetchRuleCMSWidgetError extends Error {
|
|
|
5156
5523
|
this.status = status;
|
|
5157
5524
|
}
|
|
5158
5525
|
}
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5526
|
+
const publishedWidgetCache = new Map();
|
|
5527
|
+
/** Drops the in-process published-widget cache. Tests call this between cases. */
|
|
5528
|
+
function clearPublishedWidgetFetchCache() {
|
|
5529
|
+
publishedWidgetCache.clear();
|
|
5530
|
+
}
|
|
5531
|
+
function bypassesPublishedCache(fetchOptions) {
|
|
5532
|
+
const cache = fetchOptions?.cache;
|
|
5533
|
+
return cache === 'no-store' || cache === 'reload' || cache === 'no-cache';
|
|
5534
|
+
}
|
|
5535
|
+
function readPublishedCache(url, now) {
|
|
5536
|
+
const entry = publishedWidgetCache.get(url);
|
|
5537
|
+
if (!entry) {
|
|
5538
|
+
return undefined;
|
|
5164
5539
|
}
|
|
5165
|
-
if (
|
|
5166
|
-
|
|
5540
|
+
if (entry.expiresAt <= now) {
|
|
5541
|
+
publishedWidgetCache.delete(url);
|
|
5542
|
+
return undefined;
|
|
5167
5543
|
}
|
|
5544
|
+
return entry.data;
|
|
5545
|
+
}
|
|
5546
|
+
async function readErrorMessage(response) {
|
|
5547
|
+
const errorData = await response.json().catch(() => ({ error: 'Unknown error' }));
|
|
5548
|
+
return errorData.error || `Request failed with status ${response.status}`;
|
|
5549
|
+
}
|
|
5550
|
+
async function getPublishedWidget({ publishedKey, token, endpoint, fetchOptions, }) {
|
|
5168
5551
|
const url = buildWidgetFetchUrl({ publishedKey, token, endpoint });
|
|
5552
|
+
const dev = isDevClientToken(token);
|
|
5553
|
+
const now = Date.now();
|
|
5554
|
+
if (!dev && !bypassesPublishedCache(fetchOptions)) {
|
|
5555
|
+
const cached = readPublishedCache(url, now);
|
|
5556
|
+
if (cached) {
|
|
5557
|
+
return cached;
|
|
5558
|
+
}
|
|
5559
|
+
}
|
|
5169
5560
|
const response = await fetch(url, {
|
|
5170
5561
|
method: 'GET',
|
|
5171
|
-
|
|
5172
|
-
...(isDevClientToken(token) ? { cache: 'no-store' } : {}),
|
|
5562
|
+
...(dev ? { cache: 'no-store' } : {}),
|
|
5173
5563
|
...fetchOptions,
|
|
5174
5564
|
});
|
|
5175
5565
|
if (!response.ok) {
|
|
5176
|
-
|
|
5177
|
-
throw new FetchRuleCMSWidgetError(errorData.error || `Request failed with status ${response.status}`, response.status);
|
|
5566
|
+
throw new FetchRuleCMSWidgetError(await readErrorMessage(response), response.status);
|
|
5178
5567
|
}
|
|
5179
5568
|
const data = await response.json();
|
|
5180
5569
|
if (!data.success) {
|
|
5181
5570
|
throw new FetchRuleCMSWidgetError('Failed to fetch widget data');
|
|
5182
5571
|
}
|
|
5183
|
-
|
|
5572
|
+
const prepared = prepareRuleCMSWidgetData(data.data);
|
|
5573
|
+
if (!dev && !bypassesPublishedCache(fetchOptions)) {
|
|
5574
|
+
publishedWidgetCache.set(url, {
|
|
5575
|
+
expiresAt: now + DEFAULT_PUBLISHED_WIDGET_CACHE_MS,
|
|
5576
|
+
data: prepared,
|
|
5577
|
+
});
|
|
5578
|
+
}
|
|
5579
|
+
return prepared;
|
|
5580
|
+
}
|
|
5581
|
+
async function resolveWidgetViaRuleset(params) {
|
|
5582
|
+
const { rulesetPublishedKey, params: resolveParams, fallbackPublishedKey, contentType, token, endpoint, fetchOptions } = params;
|
|
5583
|
+
const fallback = () => getPublishedWidget({
|
|
5584
|
+
publishedKey: fallbackPublishedKey,
|
|
5585
|
+
token,
|
|
5586
|
+
endpoint,
|
|
5587
|
+
fetchOptions,
|
|
5588
|
+
});
|
|
5589
|
+
let response;
|
|
5590
|
+
try {
|
|
5591
|
+
response = await fetch(buildWidgetResolveUrl({ token, endpoint }), {
|
|
5592
|
+
...buildWidgetResolveRequestInit({
|
|
5593
|
+
token,
|
|
5594
|
+
rulesetPublishedKey,
|
|
5595
|
+
params: resolveParams,
|
|
5596
|
+
contentType,
|
|
5597
|
+
}),
|
|
5598
|
+
...fetchOptions,
|
|
5599
|
+
});
|
|
5600
|
+
}
|
|
5601
|
+
catch (err) {
|
|
5602
|
+
if (fallbackPublishedKey) {
|
|
5603
|
+
return fallback();
|
|
5604
|
+
}
|
|
5605
|
+
throw err;
|
|
5606
|
+
}
|
|
5607
|
+
if (!response.ok) {
|
|
5608
|
+
if (fallbackPublishedKey && isWidgetResolveFallbackStatus(response.status)) {
|
|
5609
|
+
return fallback();
|
|
5610
|
+
}
|
|
5611
|
+
throw new FetchRuleCMSWidgetError(await readErrorMessage(response), response.status);
|
|
5612
|
+
}
|
|
5613
|
+
const normalized = normalizeWidgetResolveResponse({
|
|
5614
|
+
token,
|
|
5615
|
+
rulesetPublishedKey,
|
|
5616
|
+
body: await response.json(),
|
|
5617
|
+
});
|
|
5618
|
+
if (!normalized) {
|
|
5619
|
+
throw new FetchRuleCMSWidgetError('Failed to fetch widget data');
|
|
5620
|
+
}
|
|
5621
|
+
return { ...prepareRuleCMSWidgetData(normalized.raw), selection: normalized.selection };
|
|
5622
|
+
}
|
|
5623
|
+
/**
|
|
5624
|
+
* Fetch widget JSON on the server (or at build time) and return render-ready
|
|
5625
|
+
* data. Pass `publishedKey` for one widget, or `rulesetPublishedKey` + `params`
|
|
5626
|
+
* to let a ruleset choose (the result then carries `selection`).
|
|
5627
|
+
*/
|
|
5628
|
+
async function fetchRuleCMSWidget(params) {
|
|
5629
|
+
const { publishedKey, rulesetPublishedKey, token } = params;
|
|
5630
|
+
if (!publishedKey && !rulesetPublishedKey) {
|
|
5631
|
+
const isDev = isDevClientToken(token);
|
|
5632
|
+
if (rulesetPublishedKey !== undefined) {
|
|
5633
|
+
throw new FetchRuleCMSWidgetError(isDev ? 'Ruleset key is required' : 'Ruleset published key is required');
|
|
5634
|
+
}
|
|
5635
|
+
throw new FetchRuleCMSWidgetError(isDev ? 'Widget key is required' : 'Published key is required');
|
|
5636
|
+
}
|
|
5637
|
+
if (!token) {
|
|
5638
|
+
throw new FetchRuleCMSWidgetError('Token is required');
|
|
5639
|
+
}
|
|
5640
|
+
if (params.rulesetPublishedKey) {
|
|
5641
|
+
return resolveWidgetViaRuleset(params);
|
|
5642
|
+
}
|
|
5643
|
+
return getPublishedWidget(params);
|
|
5184
5644
|
}
|
|
5185
5645
|
|
|
5186
5646
|
/**
|
|
@@ -5205,5 +5665,5 @@ async function resolveWidgetLibraries(params) {
|
|
|
5205
5665
|
* Generated bundle index. Do not edit.
|
|
5206
5666
|
*/
|
|
5207
5667
|
|
|
5208
|
-
export { AlignContentTypes, BreakpointVariantRenderComponent, COLLECTION_TYPE_PREFIX, COMPONENT_PROPS_PATH_SEPARATOR, CSS_CLASSES_ATTRIBUTE_NAME, CSS_VARIABLE_NAME_MAX_LENGTH, CSS_VARIABLE_NAME_PATTERN, DEFAULT_BASE_Z_INDEX, DEFAULT_CLOUDINARY_CLOUD_NAME, DEFAULT_LIBRARY_ID, DEFAULT_ROW_GAP, DEV_CLIENT_TOKEN_PREFIX, DEV_WIDGET_API_PATH, DeviceDisplayTypes, DisplayComponentComponent, DisplayItemTypes, DragItemIdPrefixTypes, EMBEDDED_KEY_SEPARATOR, FLEX_LAYOUT_STYLE_KEYS_THAT_DERIVE_DISPLAY, FetchRuleCMSWidgetError, HIDE_WIDGET_ATTRIBUTE_NAME, JustifyContentTypes, POINTER_EVENTS_ATTRIBUTE_NAME, PUBLISHED_KEY_SEPARATOR, PUBLISHED_WIDGET_API_PATH, PageViewTypes, RULECMS_API_ORIGIN, RULECMS_PUBLISHED_KEY_ATTRIBUTE, RenderComponentsComponent, RenderComponentsForDeviceComponent, RenderComponentsInnerComponent, RuleCMSWidgetComponent, RuleCMSWidgetContextService, RuleCMSWidgetProviderComponent, WIDGET_ATTRIBUTES_IGNORED_IN_COMPOSE_MODE, WIDGET_CACHE_API_ORIGIN, Z_INDEX_WIDGET_ATTRIBUTE_NAME, alignContentAllowlist, alignItemsAllowlist, backgroundPositionAllowlist, backgroundRepeatAllowlist, backgroundSizeAllowlist, borderStyleKeywords, boxSpacingSideKeys, boxSpacingStyleAttributeEntries, buildCloudinaryBackgroundUrl, buildOverlayLayerBoxStyles, buildOverlayStackStyles, buildWidgetFetchUrl, collectComponentInstancePaths, collectReferencedLibraryIds, composeSourceComponentsPlugin, createComponentLibraryRegistry, cssAttrArrayKey, defaultPageWidth, deriveDisplayFlexIfNeeded, desktopModeWidth, fetchRuleCMSWidget, findUnmatchedComponentPropsKeys, flexDirectionAllowlist, flexWrapAllowlist, fontFamilyAllowlist, fontStyleAllowlist, fontWeightAllowlist, formatBackgroundImageStyles, formatBorderStyles, formatBoxShadowStyles, formatBoxSpacingStyles, formatCssColorStyles, formatCssColorValue, formatCssEnumStyles, formatCssLengthStyles, formatCssVariable, formatCssVariableStyles, formatLineHeightStyles, formatObjectStyleAttribute, formatOpacityStyles, formatSpacingSideValue, generatePublishedKey, generatePublishedKeyForEmbedded, getCollectionIdForCollectionType, getColumnAttributes, getComponentAttributesAndStyles, getComponentsPluginFromPlugins, getCssVariableFromLeaf, getDefaultDimensionAttributes, getDeviceTypeBasedAttributes, getDragItemId, getDragItemPrefixAndId, getIdAndPrefix, getMergedAttributes, getNameAndInstanceIdFromWidgetKey, getNameFromWidgetKey, getOverlayLayerZIndex, getWidgetKeyForCollection, getWidgetKeyForCollectionWithPrefix, getWidgetKeyForPublishedCollection, getWidgetKeyForPublishedCollectionWithPrefix, hasBoxShadowLeaf, hasDeviceDivergentValues, hasInvalidCssVariable, hasItems, hasOverlayLayers, incrementVersion, isBackgroundImageValue, isBorderStyleValue, isBorderValue, isBoxShadowValue, isBoxSpacingValue, isCloudinaryCloudName, isCloudinaryPublicId, isCloudinaryTransformationString, isCssColorValue, isCssEnumValue, isCssVariableName, isDevClientToken, isLineHeightValue, isOpacityValue, isOverlayLayerEmptyForDevice, isRowHiddenForDevice, isSafeImageUrl, isSpacingSideValue, isWidgetHiddenForDevice, justifyContentAllowlist, normalizeCssClasses, objectStyleAttributeRegistry, overflowAllowlist, phoneModeWidth, pointerEventsAllowlist, prepareRuleCMSWidgetData, resolveBaseZIndex, resolveKey, resolveOverlayLayerPointerEvents, resolveRowStyles, resolveWidgetApiOrigin, resolveWidgetContainerStyles, resolveWidgetInstanceProps, resolveWidgetLibraries, rowBasedPropertiesAreAssigned, spacingKeywords, spacingLengthUnits, tabletModeWidth, textAlignAllowlist, textDecorationAllowlist, textTransformAllowlist, typeHasPrefix, warnUnmatchedComponentProps, widgetBasedPropertiesAreAssigned, widgetDeclaresOwnHeight };
|
|
5668
|
+
export { AlignContentTypes, BreakpointVariantRenderComponent, COLLECTION_TYPE_PREFIX, COMPONENT_PROPS_PATH_SEPARATOR, CSS_CLASSES_ATTRIBUTE_NAME, CSS_VARIABLE_NAME_MAX_LENGTH, CSS_VARIABLE_NAME_PATTERN, DEFAULT_BASE_Z_INDEX, DEFAULT_CLOUDINARY_CLOUD_NAME, DEFAULT_LIBRARY_ID, DEFAULT_PUBLISHED_WIDGET_CACHE_MS, DEFAULT_ROW_GAP, DEV_CLIENT_TOKEN_PREFIX, DEV_WIDGET_API_PATH, DEV_WIDGET_RESOLVE_API_PATH, DeviceDisplayTypes, DisplayComponentComponent, DisplayItemTypes, DragItemIdPrefixTypes, EMBEDDED_KEY_SEPARATOR, FLEX_LAYOUT_STYLE_KEYS_THAT_DERIVE_DISPLAY, FetchRuleCMSWidgetError, HIDE_WIDGET_ATTRIBUTE_NAME, JustifyContentTypes, POINTER_EVENTS_ATTRIBUTE_NAME, PUBLISHED_KEY_SEPARATOR, PUBLISHED_WIDGET_API_PATH, PUBLISHED_WIDGET_RESOLVE_API_PATH, PageViewTypes, RULECMS_ANONYMOUS_ID_STORAGE_KEY, RULECMS_API_ORIGIN, RULECMS_PUBLISHED_KEY_ATTRIBUTE, RenderComponentsComponent, RenderComponentsForDeviceComponent, RenderComponentsInnerComponent, RuleCMSWidgetComponent, RuleCMSWidgetContextService, RuleCMSWidgetProviderComponent, WIDGET_ATTRIBUTES_IGNORED_IN_COMPOSE_MODE, WIDGET_CACHE_API_ORIGIN, WIDGET_PLACEHOLDER_VALUES_KEY, Z_INDEX_WIDGET_ATTRIBUTE_NAME, alignContentAllowlist, alignItemsAllowlist, backgroundPositionAllowlist, backgroundRepeatAllowlist, backgroundSizeAllowlist, borderStyleKeywords, boxSpacingSideKeys, boxSpacingStyleAttributeEntries, buildCloudinaryBackgroundUrl, buildOverlayLayerBoxStyles, buildOverlayStackStyles, buildWidgetFetchUrl, buildWidgetResolveUrl, clearPublishedWidgetFetchCache, collectComponentInstancePaths, collectReferencedLibraryIds, composeSourceComponentsPlugin, createComponentLibraryRegistry, cssAttrArrayKey, defaultPageWidth, deriveDisplayFlexIfNeeded, desktopModeWidth, fetchRuleCMSWidget, findUnmatchedComponentPropsKeys, flexDirectionAllowlist, flexWrapAllowlist, fontFamilyAllowlist, fontStyleAllowlist, fontWeightAllowlist, formatBackgroundImageStyles, formatBorderStyles, formatBoxShadowStyles, formatBoxSpacingStyles, formatCssColorStyles, formatCssColorValue, formatCssEnumStyles, formatCssLengthStyles, formatCssVariable, formatCssVariableStyles, formatLineHeightStyles, formatObjectStyleAttribute, formatOpacityStyles, formatSpacingSideValue, generatePublishedKey, generatePublishedKeyForEmbedded, getCollectionIdForCollectionType, getColumnAttributes, getComponentAttributesAndStyles, getComponentsPluginFromPlugins, getCssVariableFromLeaf, getDefaultDimensionAttributes, getDeviceTypeBasedAttributes, getDragItemId, getDragItemPrefixAndId, getIdAndPrefix, getMergedAttributes, getNameAndInstanceIdFromWidgetKey, getNameFromWidgetKey, getOrCreateAnonymousId, getOverlayLayerZIndex, getWidgetKeyForCollection, getWidgetKeyForCollectionWithPrefix, getWidgetKeyForPublishedCollection, getWidgetKeyForPublishedCollectionWithPrefix, hasBoxShadowLeaf, hasDeviceDivergentValues, hasInvalidCssVariable, hasItems, hasOverlayLayers, incrementVersion, isBackgroundImageValue, isBorderStyleValue, isBorderValue, isBoxShadowValue, isBoxSpacingValue, isCloudinaryCloudName, isCloudinaryPublicId, isCloudinaryTransformationString, isCssColorValue, isCssEnumValue, isCssVariableName, isDevClientToken, isLineHeightValue, isOpacityValue, isOverlayLayerEmptyForDevice, isRowHiddenForDevice, isSafeImageUrl, isSpacingSideValue, isWidgetHiddenForDevice, justifyContentAllowlist, normalizeCssClasses, objectStyleAttributeRegistry, overflowAllowlist, phoneModeWidth, pointerEventsAllowlist, prepareRuleCMSWidgetData, resolveBaseZIndex, resolveKey, resolveOverlayLayerPointerEvents, resolveRowStyles, resolveWidgetApiOrigin, resolveWidgetContainerStyles, resolveWidgetInstanceProps, resolveWidgetLibraries, rowBasedPropertiesAreAssigned, spacingKeywords, spacingLengthUnits, stableJsonStringify, tabletModeWidth, textAlignAllowlist, textDecorationAllowlist, textTransformAllowlist, typeHasPrefix, warnUnmatchedComponentProps, widgetBasedPropertiesAreAssigned, widgetDeclaresOwnHeight, withWidgetPlaceholderValues };
|
|
5209
5669
|
//# sourceMappingURL=rulecms-widget-angular.mjs.map
|