@rulecms/widget-angular 0.6.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 +1741 -148
- 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/get-component-attributes-and-styles.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/project-css-classes/format-project-css-classes-stylesheet.d.ts +10 -1
- package/lib/project-css-classes/format-project-css-classes-stylesheet.d.ts.map +1 -1
- package/lib/project-css-classes/include-project-css-layers-on-published-widget.d.ts +6 -0
- package/lib/project-css-classes/include-project-css-layers-on-published-widget.d.ts.map +1 -0
- package/lib/project-css-classes/project-css-classes-stylesheet.component.d.ts +3 -2
- package/lib/project-css-classes/project-css-classes-stylesheet.component.d.ts.map +1 -1
- package/lib/project-css-fonts/format-project-css-fonts-stylesheet.d.ts +34 -0
- package/lib/project-css-fonts/format-project-css-fonts-stylesheet.d.ts.map +1 -0
- package/lib/project-css-fonts/include-project-css-fonts-on-published-widget.d.ts +6 -0
- package/lib/project-css-fonts/include-project-css-fonts-on-published-widget.d.ts.map +1 -0
- package/lib/project-css-fonts/project-css-fonts-stylesheet.component.d.ts +16 -0
- package/lib/project-css-fonts/project-css-fonts-stylesheet.component.d.ts.map +1 -0
- package/lib/project-css-keyframes/format-project-css-keyframes-stylesheet.d.ts +11 -0
- package/lib/project-css-keyframes/format-project-css-keyframes-stylesheet.d.ts.map +1 -0
- package/lib/project-css-keyframes/include-project-css-keyframes-on-published-widget.d.ts +6 -0
- package/lib/project-css-keyframes/include-project-css-keyframes-on-published-widget.d.ts.map +1 -0
- package/lib/project-css-keyframes/project-css-keyframes-stylesheet.component.d.ts +14 -0
- package/lib/project-css-keyframes/project-css-keyframes-stylesheet.component.d.ts.map +1 -0
- package/lib/project-css-position-try/format-project-css-position-try-stylesheet.d.ts +11 -0
- package/lib/project-css-position-try/format-project-css-position-try-stylesheet.d.ts.map +1 -0
- package/lib/project-css-position-try/include-project-css-position-try-on-published-widget.d.ts +6 -0
- package/lib/project-css-position-try/include-project-css-position-try-on-published-widget.d.ts.map +1 -0
- package/lib/project-css-position-try/project-css-position-try-stylesheet.component.d.ts +14 -0
- package/lib/project-css-position-try/project-css-position-try-stylesheet.component.d.ts.map +1 -0
- package/lib/project-css-properties/format-project-css-properties-stylesheet.d.ts +15 -0
- package/lib/project-css-properties/format-project-css-properties-stylesheet.d.ts.map +1 -0
- package/lib/project-css-properties/include-project-css-properties-on-published-widget.d.ts +6 -0
- package/lib/project-css-properties/include-project-css-properties-on-published-widget.d.ts.map +1 -0
- package/lib/project-css-properties/project-css-properties-stylesheet.component.d.ts +14 -0
- package/lib/project-css-properties/project-css-properties-stylesheet.component.d.ts.map +1 -0
- package/lib/project-css-themes/format-project-css-themes-stylesheet.d.ts +24 -0
- package/lib/project-css-themes/format-project-css-themes-stylesheet.d.ts.map +1 -0
- package/lib/project-css-themes/include-project-css-themes-on-published-widget.d.ts +6 -0
- package/lib/project-css-themes/include-project-css-themes-on-published-widget.d.ts.map +1 -0
- package/lib/project-css-themes/project-css-themes-stylesheet.component.d.ts +14 -0
- package/lib/project-css-themes/project-css-themes-stylesheet.component.d.ts.map +1 -0
- package/lib/project-css-variables/format-project-css-variables-stylesheet.d.ts +1 -1
- package/lib/project-css-variables/format-project-css-variables-stylesheet.d.ts.map +1 -1
- package/lib/project-css-variables/include-project-css-variables-on-published-widget.d.ts +4 -9
- package/lib/project-css-variables/include-project-css-variables-on-published-widget.d.ts.map +1 -1
- package/lib/project-css-widget-chrome/format-project-css-widget-chrome-stylesheet.d.ts +19 -0
- package/lib/project-css-widget-chrome/format-project-css-widget-chrome-stylesheet.d.ts.map +1 -0
- package/lib/project-css-widget-chrome/include-project-css-widget-chrome-on-published-widget.d.ts +6 -0
- package/lib/project-css-widget-chrome/include-project-css-widget-chrome-on-published-widget.d.ts.map +1 -0
- package/lib/project-css-widget-chrome/project-css-widget-chrome-stylesheet.component.d.ts +14 -0
- package/lib/project-css-widget-chrome/project-css-widget-chrome-stylesheet.component.d.ts.map +1 -0
- 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/prepare-rule-cms-widget-data.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 +104 -16
- 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}`;
|
|
@@ -1707,9 +1722,20 @@ function getComponentAttributesAndStyles({ col, deviceDisplayType, isComposeMode
|
|
|
1707
1722
|
break;
|
|
1708
1723
|
}
|
|
1709
1724
|
}
|
|
1725
|
+
const stylesForDevice = deriveDisplayFlexIfNeeded(componentStyles);
|
|
1726
|
+
// `pointer-events: none` would leave the author unable to click the column
|
|
1727
|
+
// to select it. Preview and published renders apply the authored value.
|
|
1728
|
+
if (isComposeMode && stylesForDevice.pointerEvents !== undefined) {
|
|
1729
|
+
const rest = { ...stylesForDevice };
|
|
1730
|
+
delete rest.pointerEvents;
|
|
1731
|
+
return {
|
|
1732
|
+
componentAttributesBasedOnDevice,
|
|
1733
|
+
componentStyles: rest,
|
|
1734
|
+
};
|
|
1735
|
+
}
|
|
1710
1736
|
return {
|
|
1711
1737
|
componentAttributesBasedOnDevice,
|
|
1712
|
-
componentStyles:
|
|
1738
|
+
componentStyles: stylesForDevice,
|
|
1713
1739
|
};
|
|
1714
1740
|
}
|
|
1715
1741
|
|
|
@@ -2089,6 +2115,39 @@ function resolveWidgetInstanceProps({ componentProps, ancestorColumnIds, columnI
|
|
|
2089
2115
|
return undefined;
|
|
2090
2116
|
}
|
|
2091
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
|
+
|
|
2092
2151
|
/**
|
|
2093
2152
|
* Every component instance in a config, as the `/`-joined column-id path that
|
|
2094
2153
|
* `componentProps` keys are matched against. Collections contribute their
|
|
@@ -2667,11 +2726,13 @@ class DisplayComponentComponent {
|
|
|
2667
2726
|
styleProps: componentStyleProps,
|
|
2668
2727
|
className: cardClassName,
|
|
2669
2728
|
widgetInstanceProps: this.widgetInstanceProps,
|
|
2729
|
+
pageViewType: this.pageViewType,
|
|
2730
|
+
columnPath: this.columnPath,
|
|
2670
2731
|
mounts: this.mounts,
|
|
2671
2732
|
};
|
|
2672
2733
|
}
|
|
2673
2734
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: DisplayComponentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2674
|
-
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: `
|
|
2675
2736
|
@if (card) {
|
|
2676
2737
|
@if (needsWrapper) {
|
|
2677
2738
|
<div [class]="wrapperClass || undefined" [ngStyle]="wrapperStyle">
|
|
@@ -2724,6 +2785,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
2724
2785
|
type: Input
|
|
2725
2786
|
}], widgetInstanceProps: [{
|
|
2726
2787
|
type: Input
|
|
2788
|
+
}], pageViewType: [{
|
|
2789
|
+
type: Input
|
|
2790
|
+
}], columnPath: [{
|
|
2791
|
+
type: Input
|
|
2727
2792
|
}], mounts: [{
|
|
2728
2793
|
type: Input
|
|
2729
2794
|
}] } });
|
|
@@ -2832,18 +2897,30 @@ class RenderComponentsInnerComponent {
|
|
|
2832
2897
|
}
|
|
2833
2898
|
return collection.collectionRows;
|
|
2834
2899
|
}
|
|
2900
|
+
get pageViewType() {
|
|
2901
|
+
return this.isComposeMode ? PageViewTypes.Compose : PageViewTypes.RenderedPage;
|
|
2902
|
+
}
|
|
2835
2903
|
childAncestorIds(columnId) {
|
|
2836
2904
|
return [...(this.ancestorColumnIds ?? []), columnId];
|
|
2837
2905
|
}
|
|
2906
|
+
columnPathFor(columnId) {
|
|
2907
|
+
if (this.isComposeMode || !columnId) {
|
|
2908
|
+
return undefined;
|
|
2909
|
+
}
|
|
2910
|
+
return [...(this.ancestorColumnIds ?? []), columnId].join(COMPONENT_PROPS_PATH_SEPARATOR);
|
|
2911
|
+
}
|
|
2838
2912
|
instanceProps(columnId) {
|
|
2839
|
-
return
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2913
|
+
return withWidgetPlaceholderValues({
|
|
2914
|
+
widgetInstanceProps: resolveWidgetInstanceProps({
|
|
2915
|
+
componentProps: this.componentProps,
|
|
2916
|
+
ancestorColumnIds: this.ancestorColumnIds,
|
|
2917
|
+
columnId,
|
|
2918
|
+
}),
|
|
2919
|
+
placeholderValues: this.isComposeMode ? undefined : this.placeholderValues,
|
|
2843
2920
|
});
|
|
2844
2921
|
}
|
|
2845
2922
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RenderComponentsInnerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2846
|
-
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: `
|
|
2847
2924
|
<ng-template #baseTree>
|
|
2848
2925
|
<rulecms-embed-vertical
|
|
2849
2926
|
[displayItemList]="displayItemList"
|
|
@@ -2874,6 +2951,7 @@ class RenderComponentsInnerComponent {
|
|
|
2874
2951
|
[deviceDisplayType]="deviceDisplayType"
|
|
2875
2952
|
[componentProps]="componentProps"
|
|
2876
2953
|
[mounts]="mounts"
|
|
2954
|
+
[placeholderValues]="placeholderValues"
|
|
2877
2955
|
[ancestorColumnIds]="childAncestorIds(col.id)"
|
|
2878
2956
|
/>
|
|
2879
2957
|
} @else {
|
|
@@ -2884,6 +2962,8 @@ class RenderComponentsInnerComponent {
|
|
|
2884
2962
|
[components]="components"
|
|
2885
2963
|
[styleProps]="columnView(col).styleProps"
|
|
2886
2964
|
[widgetInstanceProps]="instanceProps(col.id)"
|
|
2965
|
+
[pageViewType]="pageViewType"
|
|
2966
|
+
[columnPath]="columnPathFor(col.id)"
|
|
2887
2967
|
[mounts]="mounts"
|
|
2888
2968
|
/>
|
|
2889
2969
|
}
|
|
@@ -2913,6 +2993,7 @@ class RenderComponentsInnerComponent {
|
|
|
2913
2993
|
[deviceDisplayType]="deviceDisplayType"
|
|
2914
2994
|
[componentProps]="componentProps"
|
|
2915
2995
|
[mounts]="mounts"
|
|
2996
|
+
[placeholderValues]="placeholderValues"
|
|
2916
2997
|
[ancestorColumnIds]="ancestorColumnIds"
|
|
2917
2998
|
/>
|
|
2918
2999
|
</div>
|
|
@@ -2921,7 +3002,7 @@ class RenderComponentsInnerComponent {
|
|
|
2921
3002
|
} @else {
|
|
2922
3003
|
<ng-container *ngTemplateOutlet="baseTree" />
|
|
2923
3004
|
}
|
|
2924
|
-
`, 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"] }] }); }
|
|
2925
3006
|
}
|
|
2926
3007
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RenderComponentsInnerComponent, decorators: [{
|
|
2927
3008
|
type: Component,
|
|
@@ -2965,6 +3046,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
2965
3046
|
[deviceDisplayType]="deviceDisplayType"
|
|
2966
3047
|
[componentProps]="componentProps"
|
|
2967
3048
|
[mounts]="mounts"
|
|
3049
|
+
[placeholderValues]="placeholderValues"
|
|
2968
3050
|
[ancestorColumnIds]="childAncestorIds(col.id)"
|
|
2969
3051
|
/>
|
|
2970
3052
|
} @else {
|
|
@@ -2975,6 +3057,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
2975
3057
|
[components]="components"
|
|
2976
3058
|
[styleProps]="columnView(col).styleProps"
|
|
2977
3059
|
[widgetInstanceProps]="instanceProps(col.id)"
|
|
3060
|
+
[pageViewType]="pageViewType"
|
|
3061
|
+
[columnPath]="columnPathFor(col.id)"
|
|
2978
3062
|
[mounts]="mounts"
|
|
2979
3063
|
/>
|
|
2980
3064
|
}
|
|
@@ -3004,6 +3088,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3004
3088
|
[deviceDisplayType]="deviceDisplayType"
|
|
3005
3089
|
[componentProps]="componentProps"
|
|
3006
3090
|
[mounts]="mounts"
|
|
3091
|
+
[placeholderValues]="placeholderValues"
|
|
3007
3092
|
[ancestorColumnIds]="ancestorColumnIds"
|
|
3008
3093
|
/>
|
|
3009
3094
|
</div>
|
|
@@ -3039,6 +3124,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3039
3124
|
type: Input
|
|
3040
3125
|
}], mounts: [{
|
|
3041
3126
|
type: Input
|
|
3127
|
+
}], placeholderValues: [{
|
|
3128
|
+
type: Input
|
|
3042
3129
|
}], ancestorColumnIds: [{
|
|
3043
3130
|
type: Input
|
|
3044
3131
|
}] } });
|
|
@@ -3050,7 +3137,7 @@ class RenderComponentsForDeviceComponent {
|
|
|
3050
3137
|
this.showDropContainers = false;
|
|
3051
3138
|
}
|
|
3052
3139
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RenderComponentsForDeviceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3053
|
-
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: `
|
|
3054
3141
|
@if (displayItemList?.rows?.length) {
|
|
3055
3142
|
<rulecms-render-inner
|
|
3056
3143
|
[displayItemList]="displayItemList"
|
|
@@ -3063,10 +3150,11 @@ class RenderComponentsForDeviceComponent {
|
|
|
3063
3150
|
[deviceDisplayType]="deviceDisplayType"
|
|
3064
3151
|
[componentProps]="componentProps"
|
|
3065
3152
|
[mounts]="mounts"
|
|
3153
|
+
[placeholderValues]="placeholderValues"
|
|
3066
3154
|
[ancestorColumnIds]="ancestorColumnIds"
|
|
3067
3155
|
/>
|
|
3068
3156
|
}
|
|
3069
|
-
`, 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"] }] }); }
|
|
3070
3158
|
}
|
|
3071
3159
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RenderComponentsForDeviceComponent, decorators: [{
|
|
3072
3160
|
type: Component,
|
|
@@ -3087,6 +3175,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3087
3175
|
[deviceDisplayType]="deviceDisplayType"
|
|
3088
3176
|
[componentProps]="componentProps"
|
|
3089
3177
|
[mounts]="mounts"
|
|
3178
|
+
[placeholderValues]="placeholderValues"
|
|
3090
3179
|
[ancestorColumnIds]="ancestorColumnIds"
|
|
3091
3180
|
/>
|
|
3092
3181
|
}
|
|
@@ -3117,6 +3206,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3117
3206
|
type: Input
|
|
3118
3207
|
}], mounts: [{
|
|
3119
3208
|
type: Input
|
|
3209
|
+
}], placeholderValues: [{
|
|
3210
|
+
type: Input
|
|
3120
3211
|
}], ancestorColumnIds: [{
|
|
3121
3212
|
type: Input
|
|
3122
3213
|
}] } });
|
|
@@ -3131,7 +3222,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3131
3222
|
class LibraryStylesheetsComponent {
|
|
3132
3223
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LibraryStylesheetsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3133
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: `
|
|
3134
|
-
@for (css of stylesheets ?? []; track
|
|
3225
|
+
@for (css of stylesheets ?? []; track $index) {
|
|
3135
3226
|
<style data-rulecms-library-stylesheet="" [innerText]="css"></style>
|
|
3136
3227
|
}
|
|
3137
3228
|
`, isInline: true }); }
|
|
@@ -3142,7 +3233,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3142
3233
|
selector: 'rulecms-library-stylesheets',
|
|
3143
3234
|
standalone: true,
|
|
3144
3235
|
template: `
|
|
3145
|
-
@for (css of stylesheets ?? []; track
|
|
3236
|
+
@for (css of stylesheets ?? []; track $index) {
|
|
3146
3237
|
<style data-rulecms-library-stylesheet="" [innerText]="css"></style>
|
|
3147
3238
|
}
|
|
3148
3239
|
`,
|
|
@@ -3167,7 +3258,7 @@ class BreakpointVariantRenderComponent {
|
|
|
3167
3258
|
this.variantStyles = buildBreakpointVariantStyles(this.resolvedScopeId);
|
|
3168
3259
|
}
|
|
3169
3260
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: BreakpointVariantRenderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3170
|
-
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: `
|
|
3171
3262
|
<rulecms-library-stylesheets [stylesheets]="plugins.sourceComponents?.stylesheets" />
|
|
3172
3263
|
@if (!divergent) {
|
|
3173
3264
|
<rulecms-render-for-device
|
|
@@ -3181,6 +3272,7 @@ class BreakpointVariantRenderComponent {
|
|
|
3181
3272
|
[plugins]="plugins"
|
|
3182
3273
|
[componentProps]="componentProps"
|
|
3183
3274
|
[mounts]="mounts"
|
|
3275
|
+
[placeholderValues]="placeholderValues"
|
|
3184
3276
|
/>
|
|
3185
3277
|
} @else {
|
|
3186
3278
|
<style [innerText]="variantStyles"></style>
|
|
@@ -3197,11 +3289,12 @@ class BreakpointVariantRenderComponent {
|
|
|
3197
3289
|
[plugins]="plugins"
|
|
3198
3290
|
[componentProps]="componentProps"
|
|
3199
3291
|
[mounts]="mounts"
|
|
3292
|
+
[placeholderValues]="placeholderValues"
|
|
3200
3293
|
/>
|
|
3201
3294
|
</div>
|
|
3202
3295
|
}
|
|
3203
3296
|
}
|
|
3204
|
-
`, 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"] }] }); }
|
|
3205
3298
|
}
|
|
3206
3299
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: BreakpointVariantRenderComponent, decorators: [{
|
|
3207
3300
|
type: Component,
|
|
@@ -3223,6 +3316,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3223
3316
|
[plugins]="plugins"
|
|
3224
3317
|
[componentProps]="componentProps"
|
|
3225
3318
|
[mounts]="mounts"
|
|
3319
|
+
[placeholderValues]="placeholderValues"
|
|
3226
3320
|
/>
|
|
3227
3321
|
} @else {
|
|
3228
3322
|
<style [innerText]="variantStyles"></style>
|
|
@@ -3239,6 +3333,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3239
3333
|
[plugins]="plugins"
|
|
3240
3334
|
[componentProps]="componentProps"
|
|
3241
3335
|
[mounts]="mounts"
|
|
3336
|
+
[placeholderValues]="placeholderValues"
|
|
3242
3337
|
/>
|
|
3243
3338
|
</div>
|
|
3244
3339
|
}
|
|
@@ -3259,6 +3354,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3259
3354
|
type: Input
|
|
3260
3355
|
}], mounts: [{
|
|
3261
3356
|
type: Input
|
|
3357
|
+
}], placeholderValues: [{
|
|
3358
|
+
type: Input
|
|
3262
3359
|
}], scopeIdInput: [{
|
|
3263
3360
|
type: Input
|
|
3264
3361
|
}] } });
|
|
@@ -3307,7 +3404,7 @@ class RenderComponentsComponent {
|
|
|
3307
3404
|
this.deviceDisplayType = resolveDisplayDeviceType(this.phoneQuery?.matches ?? false, this.tabletQuery?.matches ?? false, this.reduxDeviceDisplayType);
|
|
3308
3405
|
}
|
|
3309
3406
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RenderComponentsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3310
|
-
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: `
|
|
3311
3408
|
@if (!isWithinCollection) {
|
|
3312
3409
|
<rulecms-library-stylesheets [stylesheets]="plugins.sourceComponents?.stylesheets" />
|
|
3313
3410
|
}
|
|
@@ -3322,8 +3419,9 @@ class RenderComponentsComponent {
|
|
|
3322
3419
|
[plugins]="plugins"
|
|
3323
3420
|
[componentProps]="componentProps"
|
|
3324
3421
|
[mounts]="mounts"
|
|
3422
|
+
[placeholderValues]="placeholderValues"
|
|
3325
3423
|
/>
|
|
3326
|
-
`, 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"] }] }); }
|
|
3327
3425
|
}
|
|
3328
3426
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RenderComponentsComponent, decorators: [{
|
|
3329
3427
|
type: Component,
|
|
@@ -3346,6 +3444,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3346
3444
|
[plugins]="plugins"
|
|
3347
3445
|
[componentProps]="componentProps"
|
|
3348
3446
|
[mounts]="mounts"
|
|
3447
|
+
[placeholderValues]="placeholderValues"
|
|
3349
3448
|
/>
|
|
3350
3449
|
`,
|
|
3351
3450
|
host: { style: 'display: contents' },
|
|
@@ -3371,6 +3470,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3371
3470
|
type: Input
|
|
3372
3471
|
}], mounts: [{
|
|
3373
3472
|
type: Input
|
|
3473
|
+
}], placeholderValues: [{
|
|
3474
|
+
type: Input
|
|
3374
3475
|
}] } });
|
|
3375
3476
|
|
|
3376
3477
|
/**
|
|
@@ -3382,19 +3483,39 @@ function shouldIncludeClassDefinitionsOnPublishedWidget(includeClassDefinitions)
|
|
|
3382
3483
|
return includeClassDefinitions !== false;
|
|
3383
3484
|
}
|
|
3384
3485
|
|
|
3486
|
+
const PROJECT_CSS_CLASS_LAYERS = ['utilities', 'components'];
|
|
3487
|
+
const CLASS_LAYER_SET = new Set(PROJECT_CSS_CLASS_LAYERS);
|
|
3488
|
+
const isProjectCssClassLayer = (value) => typeof value === 'string' && CLASS_LAYER_SET.has(value);
|
|
3489
|
+
const indentCssBlock = (css) => css
|
|
3490
|
+
.split('\n')
|
|
3491
|
+
.map(line => (line.length > 0 ? ` ${line}` : line))
|
|
3492
|
+
.join('\n');
|
|
3493
|
+
/**
|
|
3494
|
+
* Wrap an already-formatted class stylesheet. Null in stays null. Unknown or
|
|
3495
|
+
* omitted layer names leave the stylesheet unlayered.
|
|
3496
|
+
*/
|
|
3497
|
+
const wrapProjectCssClassesStylesheetInLayer = (css, classLayer) => {
|
|
3498
|
+
if (!css) {
|
|
3499
|
+
return null;
|
|
3500
|
+
}
|
|
3501
|
+
if (!isProjectCssClassLayer(classLayer)) {
|
|
3502
|
+
return css;
|
|
3503
|
+
}
|
|
3504
|
+
return `@layer ${classLayer} {\n${indentCssBlock(css)}\n}`;
|
|
3505
|
+
};
|
|
3385
3506
|
/**
|
|
3386
3507
|
* Attribute-selector escape so a published key cannot break out of
|
|
3387
3508
|
* `[data-rulecms-published-key="…"]`. `CSS.escape` is not assumed (SSR / Node).
|
|
3388
3509
|
*/
|
|
3389
|
-
const escapeCssAttributeValue$
|
|
3510
|
+
const escapeCssAttributeValue$2 = (value) => value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
3390
3511
|
/** Escape a class name for use after `.` (`/` → `\/`). */
|
|
3391
|
-
const escapeCssClassName = (name) => name.replace(/[^A-Za-z0-9_-]/g,
|
|
3512
|
+
const escapeCssClassName = (name) => name.replace(/[^A-Za-z0-9_-]/g, char => `\\${char}`);
|
|
3392
3513
|
const REJECTED_IN_BODY = ['</', '<script', '@import', 'javascript:', 'vbscript:', 'expression('];
|
|
3393
3514
|
// eslint-disable-next-line no-control-regex -- control characters are what this matches
|
|
3394
|
-
const REJECTED_CONTROL_CHARACTERS = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/;
|
|
3515
|
+
const REJECTED_CONTROL_CHARACTERS$2 = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/;
|
|
3395
3516
|
const DISALLOWED_IN_NAME = /[\s{};"]/;
|
|
3396
|
-
const ALLOWED_NAME = /^[A-Za-z0-9_:%./[\]%-]+$/;
|
|
3397
|
-
const isBraceBalanced = (value) => {
|
|
3517
|
+
const ALLOWED_NAME$2 = /^[A-Za-z0-9_:%./[\]%-]+$/;
|
|
3518
|
+
const isBraceBalanced$1 = (value) => {
|
|
3398
3519
|
let depth = 0;
|
|
3399
3520
|
for (const char of value) {
|
|
3400
3521
|
if (char === '{') {
|
|
@@ -3414,18 +3535,18 @@ const isCssClassName = (value) => {
|
|
|
3414
3535
|
if (!name || name.length > 200 || name.startsWith('.') || DISALLOWED_IN_NAME.test(name)) {
|
|
3415
3536
|
return false;
|
|
3416
3537
|
}
|
|
3417
|
-
return ALLOWED_NAME.test(name);
|
|
3538
|
+
return ALLOWED_NAME$2.test(name);
|
|
3418
3539
|
};
|
|
3419
3540
|
const isCssClassDeclarationBody = (value) => {
|
|
3420
3541
|
const trimmed = value.trim();
|
|
3421
3542
|
if (!trimmed || trimmed.length > 4000) {
|
|
3422
3543
|
return false;
|
|
3423
3544
|
}
|
|
3424
|
-
if (REJECTED_CONTROL_CHARACTERS.test(trimmed) || !isBraceBalanced(trimmed)) {
|
|
3545
|
+
if (REJECTED_CONTROL_CHARACTERS$2.test(trimmed) || !isBraceBalanced$1(trimmed)) {
|
|
3425
3546
|
return false;
|
|
3426
3547
|
}
|
|
3427
3548
|
const lowered = trimmed.toLowerCase();
|
|
3428
|
-
return !REJECTED_IN_BODY.some(
|
|
3549
|
+
return !REJECTED_IN_BODY.some(rejected => lowered.includes(rejected));
|
|
3429
3550
|
};
|
|
3430
3551
|
const sanitizeForStylesheet$1 = (classes) => {
|
|
3431
3552
|
if (!classes) {
|
|
@@ -3445,15 +3566,15 @@ const sanitizeForStylesheet$1 = (classes) => {
|
|
|
3445
3566
|
}
|
|
3446
3567
|
return sanitized;
|
|
3447
3568
|
};
|
|
3448
|
-
const indentDeclarationBody = (body) => body
|
|
3569
|
+
const indentDeclarationBody$1 = (body) => body
|
|
3449
3570
|
.split('\n')
|
|
3450
|
-
.map(
|
|
3571
|
+
.map(line => ` ${line}`)
|
|
3451
3572
|
.join('\n');
|
|
3452
3573
|
/**
|
|
3453
3574
|
* Descendant class rules under this widget’s published-key span.
|
|
3454
3575
|
* Empty / flag-off / unsanitary catalogs return null so the caller omits `<style>`.
|
|
3455
3576
|
*/
|
|
3456
|
-
const formatProjectCssClassesStylesheet = (publishedKey, classes, includeClassDefinitions) => {
|
|
3577
|
+
const formatProjectCssClassesStylesheet = (publishedKey, classes, includeClassDefinitions, classLayer) => {
|
|
3457
3578
|
if (!shouldIncludeClassDefinitionsOnPublishedWidget(includeClassDefinitions)) {
|
|
3458
3579
|
return null;
|
|
3459
3580
|
}
|
|
@@ -3462,12 +3583,14 @@ const formatProjectCssClassesStylesheet = (publishedKey, classes, includeClassDe
|
|
|
3462
3583
|
if (names.length === 0 || !publishedKey) {
|
|
3463
3584
|
return null;
|
|
3464
3585
|
}
|
|
3465
|
-
const ancestor = `[data-rulecms-published-key="${escapeCssAttributeValue$
|
|
3466
|
-
|
|
3586
|
+
const ancestor = `[data-rulecms-published-key="${escapeCssAttributeValue$2(publishedKey)}"]`;
|
|
3587
|
+
const css = names
|
|
3467
3588
|
.sort((left, right) => left.localeCompare(right))
|
|
3468
|
-
.map(
|
|
3589
|
+
.map(name => `${ancestor} .${escapeCssClassName(name)} {\n${indentDeclarationBody$1(sanitized[name])}\n}`)
|
|
3469
3590
|
.join('\n');
|
|
3591
|
+
return wrapProjectCssClassesStylesheetInLayer(css, classLayer);
|
|
3470
3592
|
};
|
|
3593
|
+
const formatProjectCssClassesStylesheetInLayer = (publishedKey, classes, classLayer, includeClassDefinitions) => formatProjectCssClassesStylesheet(publishedKey, classes, includeClassDefinitions, classLayer);
|
|
3471
3594
|
|
|
3472
3595
|
/**
|
|
3473
3596
|
* Emits one scoped `<style data-rulecms-project-class-definitions>` from the
|
|
@@ -3475,10 +3598,10 @@ const formatProjectCssClassesStylesheet = (publishedKey, classes, includeClassDe
|
|
|
3475
3598
|
*/
|
|
3476
3599
|
class ProjectCssClassesStylesheetComponent {
|
|
3477
3600
|
get css() {
|
|
3478
|
-
return formatProjectCssClassesStylesheet(this.publishedKey, this.classes);
|
|
3601
|
+
return formatProjectCssClassesStylesheet(this.publishedKey, this.classes, undefined, this.classLayer);
|
|
3479
3602
|
}
|
|
3480
3603
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssClassesStylesheetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3481
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: ProjectCssClassesStylesheetComponent, isStandalone: true, selector: "rulecms-project-css-classes-stylesheet", inputs: { publishedKey: "publishedKey", classes: "classes" }, ngImport: i0, template: `
|
|
3604
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: ProjectCssClassesStylesheetComponent, isStandalone: true, selector: "rulecms-project-css-classes-stylesheet", inputs: { publishedKey: "publishedKey", classes: "classes", classLayer: "classLayer" }, ngImport: i0, template: `
|
|
3482
3605
|
@if (css) {
|
|
3483
3606
|
<style data-rulecms-project-class-definitions="" [innerText]="css"></style>
|
|
3484
3607
|
}
|
|
@@ -3500,113 +3623,1123 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3500
3623
|
args: [{ required: true }]
|
|
3501
3624
|
}], classes: [{
|
|
3502
3625
|
type: Input
|
|
3626
|
+
}], classLayer: [{
|
|
3627
|
+
type: Input
|
|
3503
3628
|
}] } });
|
|
3504
3629
|
|
|
3505
3630
|
/**
|
|
3506
|
-
*
|
|
3507
|
-
*
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3631
|
+
* Missing/undefined on a widget GET payload means include. Only an explicit
|
|
3632
|
+
* `false` turns emission off, even if `fontFaces` is still present.
|
|
3633
|
+
*/
|
|
3634
|
+
function shouldIncludeFontFacesOnPublishedWidget(includeFontFaces) {
|
|
3635
|
+
return includeFontFaces !== false;
|
|
3636
|
+
}
|
|
3637
|
+
|
|
3638
|
+
const escapeCssAttributeValue$1 = (value) => value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
3639
|
+
const GENERIC_FAMILIES = new Set([
|
|
3640
|
+
'serif',
|
|
3641
|
+
'sans-serif',
|
|
3642
|
+
'monospace',
|
|
3643
|
+
'cursive',
|
|
3644
|
+
'fantasy',
|
|
3645
|
+
'system-ui',
|
|
3646
|
+
'ui-sans-serif',
|
|
3647
|
+
'ui-serif',
|
|
3648
|
+
'ui-monospace',
|
|
3649
|
+
'ui-rounded',
|
|
3650
|
+
'emoji',
|
|
3651
|
+
'math',
|
|
3652
|
+
'fangsong',
|
|
3653
|
+
]);
|
|
3654
|
+
const IDENT = /^[a-zA-Z_\u00A0-\uFFFF-][a-zA-Z0-9_\u00A0-\uFFFF-]*$/;
|
|
3655
|
+
const REJECTED = /url\(|@|[{};\\<>]|javascript:/i;
|
|
3656
|
+
const REJECTED_COLOR = /url\(|@|[{};\\<>]|javascript:|expression\(/i;
|
|
3657
|
+
const PALETTE_NAME = /^--[A-Za-z_][\w-]*$/;
|
|
3658
|
+
const GOOGLE_FAMILY = /^[A-Za-z0-9 ]+$/;
|
|
3659
|
+
const GOOGLE_WEIGHTS = new Set([100, 200, 300, 400, 500, 600, 700, 800, 900]);
|
|
3660
|
+
const MAX_PALETTES_PER_FACE = 4;
|
|
3661
|
+
const MAX_PALETTE_OVERRIDE_COLORS = 8;
|
|
3662
|
+
const MAX_PALETTE_COLOR_INDEX = 255;
|
|
3663
|
+
const quoteCssFontFamily = (name) => {
|
|
3664
|
+
if (GENERIC_FAMILIES.has(name.toLowerCase()) || IDENT.test(name)) {
|
|
3665
|
+
return name;
|
|
3666
|
+
}
|
|
3667
|
+
return `"${name.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
3668
|
+
};
|
|
3669
|
+
const isSafeFamily = (value) => typeof value === 'string' &&
|
|
3670
|
+
value.trim() !== '' &&
|
|
3671
|
+
value.trim().length <= 80 &&
|
|
3672
|
+
!value.includes(',') &&
|
|
3673
|
+
!REJECTED.test(value);
|
|
3674
|
+
const isSafePaletteName = (value) => typeof value === 'string' &&
|
|
3675
|
+
PALETTE_NAME.test(value.trim()) &&
|
|
3676
|
+
value.trim().length <= 80;
|
|
3677
|
+
const isSafePaletteColor = (value) => typeof value === 'string' &&
|
|
3678
|
+
value.trim() !== '' &&
|
|
3679
|
+
value.trim().length <= 400 &&
|
|
3680
|
+
!REJECTED_COLOR.test(value);
|
|
3681
|
+
const parsePaletteColorIndex = (value) => {
|
|
3682
|
+
if (typeof value !== 'number' || !Number.isInteger(value) || value < 0 || value > MAX_PALETTE_COLOR_INDEX) {
|
|
3683
|
+
return null;
|
|
3684
|
+
}
|
|
3685
|
+
return value;
|
|
3686
|
+
};
|
|
3687
|
+
const sanitizePalettes = (raw, seenNames, hasDefaultPalette) => {
|
|
3688
|
+
if (!Array.isArray(raw)) {
|
|
3689
|
+
return [];
|
|
3690
|
+
}
|
|
3691
|
+
const palettes = [];
|
|
3692
|
+
for (const item of raw) {
|
|
3693
|
+
if (!item || typeof item !== 'object' || palettes.length >= MAX_PALETTES_PER_FACE) {
|
|
3694
|
+
continue;
|
|
3695
|
+
}
|
|
3696
|
+
const record = item;
|
|
3697
|
+
if (!isSafePaletteName(record.name)) {
|
|
3698
|
+
continue;
|
|
3699
|
+
}
|
|
3700
|
+
const name = record.name.trim();
|
|
3701
|
+
if (seenNames.has(name)) {
|
|
3702
|
+
continue;
|
|
3703
|
+
}
|
|
3704
|
+
const overrideColors = [];
|
|
3705
|
+
const seenIndexes = new Set();
|
|
3706
|
+
for (const color of record.overrideColors ?? []) {
|
|
3707
|
+
if (overrideColors.length >= MAX_PALETTE_OVERRIDE_COLORS) {
|
|
3708
|
+
break;
|
|
3709
|
+
}
|
|
3710
|
+
const index = parsePaletteColorIndex(color?.index);
|
|
3711
|
+
if (index === null || seenIndexes.has(index) || !isSafePaletteColor(color?.color)) {
|
|
3712
|
+
continue;
|
|
3713
|
+
}
|
|
3714
|
+
seenIndexes.add(index);
|
|
3715
|
+
overrideColors.push({ index, color: color.color.trim() });
|
|
3716
|
+
}
|
|
3717
|
+
overrideColors.sort((left, right) => left.index - right.index);
|
|
3718
|
+
const applyToWidget = record.applyToWidget === true && !hasDefaultPalette.current;
|
|
3719
|
+
if (applyToWidget) {
|
|
3720
|
+
hasDefaultPalette.current = true;
|
|
3721
|
+
}
|
|
3722
|
+
seenNames.add(name);
|
|
3723
|
+
palettes.push({
|
|
3724
|
+
name,
|
|
3725
|
+
...(overrideColors.length > 0 ? { overrideColors } : {}),
|
|
3726
|
+
...(applyToWidget ? { applyToWidget: true } : {}),
|
|
3727
|
+
});
|
|
3728
|
+
}
|
|
3729
|
+
return palettes;
|
|
3730
|
+
};
|
|
3731
|
+
const sanitizeProjectFontFaces = (fonts) => {
|
|
3732
|
+
if (!Array.isArray(fonts)) {
|
|
3733
|
+
return [];
|
|
3734
|
+
}
|
|
3735
|
+
const sanitized = [];
|
|
3736
|
+
const seen = new Set();
|
|
3737
|
+
const seenPaletteNames = new Set();
|
|
3738
|
+
const hasDefaultPalette = { current: false };
|
|
3739
|
+
let hasDefault = false;
|
|
3740
|
+
for (const raw of fonts) {
|
|
3741
|
+
if (!raw || !isSafeFamily(raw.family)) {
|
|
3742
|
+
continue;
|
|
3743
|
+
}
|
|
3744
|
+
const family = raw.family.trim();
|
|
3745
|
+
const key = family.toLowerCase();
|
|
3746
|
+
if (seen.has(key) || sanitized.length >= 12) {
|
|
3747
|
+
continue;
|
|
3748
|
+
}
|
|
3749
|
+
const fallbacks = (raw.fallbacks ?? []).filter(isSafeFamily).slice(0, 8);
|
|
3750
|
+
const cssVariable = typeof raw.cssVariable === 'string' && isCssVariableName(raw.cssVariable.trim())
|
|
3751
|
+
? raw.cssVariable.trim()
|
|
3752
|
+
: undefined;
|
|
3753
|
+
let source = { kind: 'stack-only' };
|
|
3754
|
+
if (raw.source?.kind === 'google') {
|
|
3755
|
+
if (!GOOGLE_FAMILY.test(family)) {
|
|
3756
|
+
continue;
|
|
3757
|
+
}
|
|
3758
|
+
const rawWeights = Array.isArray(raw.source.weights)
|
|
3759
|
+
? raw.source.weights
|
|
3760
|
+
: [];
|
|
3761
|
+
const weights = rawWeights
|
|
3762
|
+
.filter((weight) => typeof weight === 'number' && GOOGLE_WEIGHTS.has(weight))
|
|
3763
|
+
.filter((weight, index, list) => list.indexOf(weight) === index)
|
|
3764
|
+
.sort((left, right) => left - right);
|
|
3765
|
+
if (weights.length === 0) {
|
|
3766
|
+
continue;
|
|
3767
|
+
}
|
|
3768
|
+
source = { kind: 'google', weights };
|
|
3769
|
+
}
|
|
3770
|
+
seen.add(key);
|
|
3771
|
+
const applyToWidget = raw.applyToWidget === true && !hasDefault;
|
|
3772
|
+
if (applyToWidget) {
|
|
3773
|
+
hasDefault = true;
|
|
3774
|
+
}
|
|
3775
|
+
const palettes = sanitizePalettes(raw.palettes, seenPaletteNames, hasDefaultPalette);
|
|
3776
|
+
sanitized.push({
|
|
3777
|
+
family,
|
|
3778
|
+
...(cssVariable ? { cssVariable } : {}),
|
|
3779
|
+
fallbacks,
|
|
3780
|
+
applyToWidget,
|
|
3781
|
+
source,
|
|
3782
|
+
...(palettes.length > 0 ? { palettes } : {}),
|
|
3783
|
+
});
|
|
3784
|
+
}
|
|
3785
|
+
return sanitized;
|
|
3786
|
+
};
|
|
3787
|
+
const buildGoogleFontsCssHref = (fonts) => {
|
|
3788
|
+
const families = sanitizeProjectFontFaces(fonts)
|
|
3789
|
+
.filter(font => font.source.kind === 'google')
|
|
3790
|
+
.map(font => {
|
|
3791
|
+
const weights = font.source.kind === 'google' ? font.source.weights.join(';') : '400';
|
|
3792
|
+
return `family=${font.family.replace(/ /g, '+')}:wght@${weights}`;
|
|
3793
|
+
});
|
|
3794
|
+
if (families.length === 0) {
|
|
3795
|
+
return null;
|
|
3796
|
+
}
|
|
3797
|
+
return `https://fonts.googleapis.com/css2?${families.join('&')}&display=swap`;
|
|
3798
|
+
};
|
|
3799
|
+
const buildStack = (font) => [quoteCssFontFamily(font.family), ...(font.fallbacks ?? []).map(quoteCssFontFamily)].join(', ');
|
|
3800
|
+
const formatPaletteValuesRules = (fonts) => {
|
|
3801
|
+
const blocks = [];
|
|
3802
|
+
for (const font of fonts) {
|
|
3803
|
+
for (const palette of font.palettes ?? []) {
|
|
3804
|
+
const lines = [` font-family: ${quoteCssFontFamily(font.family)};`];
|
|
3805
|
+
if (palette.overrideColors && palette.overrideColors.length > 0) {
|
|
3806
|
+
const overrides = palette.overrideColors
|
|
3807
|
+
.map(item => `${item.index} ${item.color}`)
|
|
3808
|
+
.join(', ');
|
|
3809
|
+
lines.push(` override-colors: ${overrides};`);
|
|
3810
|
+
}
|
|
3811
|
+
blocks.push(`@font-palette-values ${palette.name} {\n${lines.join('\n')}\n}`);
|
|
3812
|
+
}
|
|
3813
|
+
}
|
|
3814
|
+
return blocks.length > 0 ? blocks.join('\n\n') : null;
|
|
3815
|
+
};
|
|
3816
|
+
const appliedPaletteName = (fonts) => {
|
|
3817
|
+
for (const font of fonts) {
|
|
3818
|
+
for (const palette of font.palettes ?? []) {
|
|
3819
|
+
if (palette.applyToWidget) {
|
|
3820
|
+
return palette.name;
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
return undefined;
|
|
3825
|
+
};
|
|
3826
|
+
/**
|
|
3827
|
+
* Palette at-rules plus the token / optional `font-family` / optional
|
|
3828
|
+
* `font-palette` on the widget’s first boxed children. Google faces are a
|
|
3829
|
+
* separate `<link>`. Returns null when there is nothing to declare or
|
|
3830
|
+
* inclusion is off — palettes ride with `includeFontFaces`.
|
|
3514
3831
|
*/
|
|
3515
|
-
const
|
|
3832
|
+
const formatProjectCssFontsStylesheet = (publishedKey, fonts, includeFontFaces) => {
|
|
3833
|
+
if (!shouldIncludeFontFacesOnPublishedWidget(includeFontFaces) || !publishedKey) {
|
|
3834
|
+
return null;
|
|
3835
|
+
}
|
|
3836
|
+
const sanitized = sanitizeProjectFontFaces(fonts);
|
|
3837
|
+
const declarations = [];
|
|
3838
|
+
for (const font of sanitized) {
|
|
3839
|
+
const stack = buildStack(font);
|
|
3840
|
+
if (font.cssVariable) {
|
|
3841
|
+
declarations.push(` ${font.cssVariable}: ${stack};`);
|
|
3842
|
+
}
|
|
3843
|
+
if (font.applyToWidget) {
|
|
3844
|
+
declarations.push(` font-family: ${font.cssVariable ? `var(${font.cssVariable})` : stack};`);
|
|
3845
|
+
}
|
|
3846
|
+
}
|
|
3847
|
+
const paletteName = appliedPaletteName(sanitized);
|
|
3848
|
+
if (paletteName) {
|
|
3849
|
+
declarations.push(` font-palette: ${paletteName};`);
|
|
3850
|
+
}
|
|
3851
|
+
const palettes = formatPaletteValuesRules(sanitized);
|
|
3852
|
+
const selector = `[data-rulecms-published-key="${escapeCssAttributeValue$1(publishedKey)}"] > *`;
|
|
3853
|
+
const surface = declarations.length > 0 ? `${selector} {\n${declarations.join('\n')}\n}` : null;
|
|
3854
|
+
if (!palettes && !surface) {
|
|
3855
|
+
return null;
|
|
3856
|
+
}
|
|
3857
|
+
if (!palettes) {
|
|
3858
|
+
return surface;
|
|
3859
|
+
}
|
|
3860
|
+
if (!surface) {
|
|
3861
|
+
return palettes;
|
|
3862
|
+
}
|
|
3863
|
+
return `${palettes}\n\n${surface}`;
|
|
3864
|
+
};
|
|
3516
3865
|
|
|
3517
3866
|
/**
|
|
3518
|
-
*
|
|
3519
|
-
*
|
|
3867
|
+
* Emits a Google Fonts `<link>` and/or one `<style data-rulecms-project-fonts>`
|
|
3868
|
+
* from the project catalog, or nothing when inclusion is off / unsanitary.
|
|
3520
3869
|
*/
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3870
|
+
class ProjectCssFontsStylesheetComponent {
|
|
3871
|
+
get href() {
|
|
3872
|
+
if (!shouldIncludeFontFacesOnPublishedWidget(this.includeFontFaces)) {
|
|
3873
|
+
return null;
|
|
3874
|
+
}
|
|
3875
|
+
return buildGoogleFontsCssHref(sanitizeProjectFontFaces(this.fonts));
|
|
3876
|
+
}
|
|
3877
|
+
get css() {
|
|
3878
|
+
return formatProjectCssFontsStylesheet(this.publishedKey, sanitizeProjectFontFaces(this.fonts), this.includeFontFaces);
|
|
3879
|
+
}
|
|
3880
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssFontsStylesheetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3881
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: ProjectCssFontsStylesheetComponent, isStandalone: true, selector: "rulecms-project-css-fonts-stylesheet", inputs: { publishedKey: "publishedKey", fonts: "fonts", includeFontFaces: "includeFontFaces" }, ngImport: i0, template: `
|
|
3882
|
+
@if (href) {
|
|
3883
|
+
<link rel="stylesheet" [attr.href]="href" data-rulecms-project-fonts="" />
|
|
3884
|
+
}
|
|
3885
|
+
@if (css) {
|
|
3886
|
+
<style data-rulecms-project-fonts="" [innerText]="css"></style>
|
|
3887
|
+
}
|
|
3888
|
+
`, isInline: true }); }
|
|
3889
|
+
}
|
|
3890
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssFontsStylesheetComponent, decorators: [{
|
|
3891
|
+
type: Component,
|
|
3892
|
+
args: [{
|
|
3893
|
+
selector: 'rulecms-project-css-fonts-stylesheet',
|
|
3894
|
+
standalone: true,
|
|
3895
|
+
template: `
|
|
3896
|
+
@if (href) {
|
|
3897
|
+
<link rel="stylesheet" [attr.href]="href" data-rulecms-project-fonts="" />
|
|
3898
|
+
}
|
|
3899
|
+
@if (css) {
|
|
3900
|
+
<style data-rulecms-project-fonts="" [innerText]="css"></style>
|
|
3901
|
+
}
|
|
3902
|
+
`,
|
|
3903
|
+
}]
|
|
3904
|
+
}], propDecorators: { publishedKey: [{
|
|
3905
|
+
type: Input,
|
|
3906
|
+
args: [{ required: true }]
|
|
3907
|
+
}], fonts: [{
|
|
3908
|
+
type: Input
|
|
3909
|
+
}], includeFontFaces: [{
|
|
3910
|
+
type: Input
|
|
3911
|
+
}] } });
|
|
3912
|
+
|
|
3913
|
+
/**
|
|
3914
|
+
* Missing/undefined on a widget GET payload means include. Only an explicit
|
|
3915
|
+
* `false` turns emission off, even if `keyframes` is still present.
|
|
3916
|
+
*/
|
|
3917
|
+
function shouldIncludeKeyframesOnPublishedWidget(includeKeyframes) {
|
|
3918
|
+
return includeKeyframes !== false;
|
|
3919
|
+
}
|
|
3920
|
+
|
|
3921
|
+
const KEYFRAME_NAME_MAX_LENGTH = 80;
|
|
3922
|
+
const KEYFRAME_BODY_MAX_LENGTH = 4000;
|
|
3923
|
+
const MAX_PROJECT_KEYFRAMES = 32;
|
|
3924
|
+
const REJECTED_IN_NAME_OR_BODY$1 = [
|
|
3925
|
+
'url(',
|
|
3926
|
+
'@import',
|
|
3927
|
+
'@font-face',
|
|
3928
|
+
'@media',
|
|
3929
|
+
'@keyframes',
|
|
3930
|
+
'</',
|
|
3931
|
+
'<script',
|
|
3932
|
+
'javascript:',
|
|
3933
|
+
'expression(',
|
|
3934
|
+
'behavior:',
|
|
3935
|
+
];
|
|
3936
|
+
// eslint-disable-next-line no-control-regex -- control characters are what this matches
|
|
3937
|
+
const REJECTED_CONTROL_CHARACTERS$1 = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/;
|
|
3938
|
+
const ALLOWED_NAME$1 = /^[A-Za-z_][\w-]*$/;
|
|
3939
|
+
const isBraceBalanced = (value) => {
|
|
3940
|
+
let depth = 0;
|
|
3941
|
+
for (const char of value) {
|
|
3942
|
+
if (char === '{') {
|
|
3943
|
+
depth += 1;
|
|
3944
|
+
}
|
|
3945
|
+
else if (char === '}') {
|
|
3946
|
+
depth -= 1;
|
|
3947
|
+
if (depth < 0) {
|
|
3948
|
+
return false;
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3952
|
+
return depth === 0;
|
|
3953
|
+
};
|
|
3954
|
+
const isKeyframeName = (value) => {
|
|
3955
|
+
if (!value || value.length > KEYFRAME_NAME_MAX_LENGTH) {
|
|
3956
|
+
return false;
|
|
3957
|
+
}
|
|
3958
|
+
if (value.includes('@') || value.includes('.') || /\s/.test(value)) {
|
|
3959
|
+
return false;
|
|
3960
|
+
}
|
|
3961
|
+
const lowered = value.toLowerCase();
|
|
3962
|
+
if (REJECTED_IN_NAME_OR_BODY$1.some(rejected => lowered.includes(rejected))) {
|
|
3963
|
+
return false;
|
|
3964
|
+
}
|
|
3965
|
+
return ALLOWED_NAME$1.test(value);
|
|
3966
|
+
};
|
|
3967
|
+
const isKeyframeSelector = (value) => {
|
|
3968
|
+
const selector = value.trim();
|
|
3969
|
+
if (selector === '') {
|
|
3970
|
+
return false;
|
|
3971
|
+
}
|
|
3972
|
+
const lowered = selector.toLowerCase();
|
|
3973
|
+
if (lowered === 'from' || lowered === 'to') {
|
|
3974
|
+
return true;
|
|
3975
|
+
}
|
|
3976
|
+
const match = selector.match(/^(\d{1,3}(?:\.\d+)?)%$/);
|
|
3977
|
+
if (!match) {
|
|
3978
|
+
return false;
|
|
3979
|
+
}
|
|
3980
|
+
const percent = Number(match[1]);
|
|
3981
|
+
return percent >= 0 && percent <= 100;
|
|
3982
|
+
};
|
|
3983
|
+
const parseKeyframeBlocks = (input) => {
|
|
3984
|
+
let index = 0;
|
|
3985
|
+
const length = input.length;
|
|
3986
|
+
let found = 0;
|
|
3987
|
+
const skipWhitespace = () => {
|
|
3988
|
+
while (index < length && /\s/.test(input[index])) {
|
|
3989
|
+
index += 1;
|
|
3990
|
+
}
|
|
3991
|
+
};
|
|
3992
|
+
skipWhitespace();
|
|
3993
|
+
while (index < length) {
|
|
3994
|
+
const open = input.indexOf('{', index);
|
|
3995
|
+
if (open === -1) {
|
|
3996
|
+
return false;
|
|
3997
|
+
}
|
|
3998
|
+
const selectorPart = input.slice(index, open).trim();
|
|
3999
|
+
if (!selectorPart.split(',').every(part => isKeyframeSelector(part))) {
|
|
4000
|
+
return false;
|
|
4001
|
+
}
|
|
4002
|
+
index = open + 1;
|
|
4003
|
+
const close = input.indexOf('}', index);
|
|
4004
|
+
if (close === -1) {
|
|
4005
|
+
return false;
|
|
4006
|
+
}
|
|
4007
|
+
const declarations = input.slice(index, close);
|
|
4008
|
+
if (declarations.includes('{') || declarations.includes('}') || declarations.includes('@')) {
|
|
4009
|
+
return false;
|
|
4010
|
+
}
|
|
4011
|
+
index = close + 1;
|
|
4012
|
+
found += 1;
|
|
4013
|
+
skipWhitespace();
|
|
4014
|
+
}
|
|
4015
|
+
return found > 0;
|
|
4016
|
+
};
|
|
4017
|
+
const isCssKeyframeBody = (value) => {
|
|
4018
|
+
const trimmed = value.trim();
|
|
4019
|
+
if (!trimmed || trimmed.length > KEYFRAME_BODY_MAX_LENGTH) {
|
|
4020
|
+
return false;
|
|
4021
|
+
}
|
|
4022
|
+
if (REJECTED_CONTROL_CHARACTERS$1.test(trimmed) || !isBraceBalanced(trimmed)) {
|
|
4023
|
+
return false;
|
|
4024
|
+
}
|
|
4025
|
+
const lowered = trimmed.toLowerCase();
|
|
4026
|
+
if (REJECTED_IN_NAME_OR_BODY$1.some(rejected => lowered.includes(rejected))) {
|
|
4027
|
+
return false;
|
|
4028
|
+
}
|
|
4029
|
+
if (trimmed.includes('@')) {
|
|
4030
|
+
return false;
|
|
4031
|
+
}
|
|
4032
|
+
return parseKeyframeBlocks(trimmed);
|
|
4033
|
+
};
|
|
4034
|
+
const sanitizeProjectCssKeyframes = (keyframes) => {
|
|
4035
|
+
if (!keyframes) {
|
|
3525
4036
|
return {};
|
|
3526
4037
|
}
|
|
3527
4038
|
const sanitized = {};
|
|
3528
|
-
for (const [rawName, rawValue] of Object.entries(
|
|
3529
|
-
|
|
4039
|
+
for (const [rawName, rawValue] of Object.entries(keyframes)) {
|
|
4040
|
+
const name = rawName.trim();
|
|
4041
|
+
if (!isKeyframeName(name) || sanitized[name] !== undefined || typeof rawValue !== 'string') {
|
|
3530
4042
|
continue;
|
|
3531
4043
|
}
|
|
3532
4044
|
const value = rawValue.trim();
|
|
3533
|
-
if (
|
|
4045
|
+
if (!isCssKeyframeBody(value)) {
|
|
3534
4046
|
continue;
|
|
3535
4047
|
}
|
|
3536
|
-
sanitized[
|
|
4048
|
+
sanitized[name] = value;
|
|
4049
|
+
if (Object.keys(sanitized).length === MAX_PROJECT_KEYFRAMES) {
|
|
4050
|
+
break;
|
|
4051
|
+
}
|
|
3537
4052
|
}
|
|
3538
|
-
return sanitized;
|
|
4053
|
+
return Object.fromEntries(Object.entries(sanitized).sort(([left], [right]) => left.localeCompare(right)));
|
|
3539
4054
|
};
|
|
4055
|
+
const indentFrameBody = (body) => body
|
|
4056
|
+
.split('\n')
|
|
4057
|
+
.map(line => ` ${line}`)
|
|
4058
|
+
.join('\n');
|
|
3540
4059
|
/**
|
|
3541
|
-
*
|
|
3542
|
-
*
|
|
3543
|
-
* the caller omits the `<style>` tag.
|
|
4060
|
+
* Unscoped `@keyframes` blocks. `publishedKey` is unused (document-global
|
|
4061
|
+
* at-rule) and kept so the signature matches fonts/classes.
|
|
3544
4062
|
*/
|
|
3545
|
-
const
|
|
3546
|
-
if (!
|
|
4063
|
+
const formatProjectCssKeyframesStylesheet = (publishedKey, keyframes, includeKeyframes) => {
|
|
4064
|
+
if (!shouldIncludeKeyframesOnPublishedWidget(includeKeyframes)) {
|
|
3547
4065
|
return null;
|
|
3548
4066
|
}
|
|
3549
|
-
const sanitized =
|
|
4067
|
+
const sanitized = sanitizeProjectCssKeyframes(keyframes);
|
|
3550
4068
|
const names = Object.keys(sanitized);
|
|
3551
|
-
if (names.length === 0
|
|
4069
|
+
if (names.length === 0) {
|
|
3552
4070
|
return null;
|
|
3553
4071
|
}
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
.
|
|
3557
|
-
.
|
|
3558
|
-
.join('\n');
|
|
3559
|
-
return `${selector} {\n${declarations}\n}`;
|
|
4072
|
+
void publishedKey;
|
|
4073
|
+
return names
|
|
4074
|
+
.map(name => `@keyframes ${name} {\n${indentFrameBody(sanitized[name])}\n}`)
|
|
4075
|
+
.join('\n\n');
|
|
3560
4076
|
};
|
|
3561
4077
|
|
|
3562
4078
|
/**
|
|
3563
|
-
* Emits one
|
|
4079
|
+
* Emits one unscoped `<style data-rulecms-project-keyframes>` from the
|
|
3564
4080
|
* project catalog, or nothing when the catalog is empty / unsanitary.
|
|
3565
4081
|
*/
|
|
3566
|
-
class
|
|
4082
|
+
class ProjectCssKeyframesStylesheetComponent {
|
|
3567
4083
|
get css() {
|
|
3568
|
-
return
|
|
4084
|
+
return formatProjectCssKeyframesStylesheet(this.publishedKey, this.keyframes);
|
|
3569
4085
|
}
|
|
3570
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type:
|
|
3571
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type:
|
|
4086
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssKeyframesStylesheetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
4087
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: ProjectCssKeyframesStylesheetComponent, isStandalone: true, selector: "rulecms-project-css-keyframes-stylesheet", inputs: { publishedKey: "publishedKey", keyframes: "keyframes" }, ngImport: i0, template: `
|
|
3572
4088
|
@if (css) {
|
|
3573
|
-
<style data-rulecms-project-
|
|
4089
|
+
<style data-rulecms-project-keyframes="" [innerText]="css"></style>
|
|
3574
4090
|
}
|
|
3575
4091
|
`, isInline: true }); }
|
|
3576
4092
|
}
|
|
3577
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type:
|
|
4093
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssKeyframesStylesheetComponent, decorators: [{
|
|
3578
4094
|
type: Component,
|
|
3579
4095
|
args: [{
|
|
3580
|
-
selector: 'rulecms-project-css-
|
|
4096
|
+
selector: 'rulecms-project-css-keyframes-stylesheet',
|
|
3581
4097
|
standalone: true,
|
|
3582
4098
|
template: `
|
|
3583
4099
|
@if (css) {
|
|
3584
|
-
<style data-rulecms-project-
|
|
4100
|
+
<style data-rulecms-project-keyframes="" [innerText]="css"></style>
|
|
3585
4101
|
}
|
|
3586
4102
|
`,
|
|
3587
4103
|
}]
|
|
3588
4104
|
}], propDecorators: { publishedKey: [{
|
|
3589
4105
|
type: Input,
|
|
3590
4106
|
args: [{ required: true }]
|
|
3591
|
-
}],
|
|
4107
|
+
}], keyframes: [{
|
|
3592
4108
|
type: Input
|
|
3593
4109
|
}] } });
|
|
3594
4110
|
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
4111
|
+
/**
|
|
4112
|
+
* Missing / undefined means include (legacy payloads).
|
|
4113
|
+
* `false` turns emission off, even if `positionTry` is still present.
|
|
4114
|
+
*/
|
|
4115
|
+
const shouldIncludePositionTryOnPublishedWidget = (includePositionTry) => {
|
|
4116
|
+
return includePositionTry !== false;
|
|
4117
|
+
};
|
|
4118
|
+
|
|
4119
|
+
const POSITION_TRY_NAME_MAX_LENGTH = 80;
|
|
4120
|
+
const POSITION_TRY_BODY_MAX_LENGTH = 2000;
|
|
4121
|
+
const MAX_PROJECT_POSITION_TRY = 16;
|
|
4122
|
+
const REJECTED_IN_NAME_OR_BODY = ['url(', '@', '</', '<script', 'javascript:', 'expression('];
|
|
4123
|
+
// eslint-disable-next-line no-control-regex -- control characters are what this matches
|
|
4124
|
+
const REJECTED_CONTROL_CHARACTERS = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/;
|
|
4125
|
+
const ALLOWED_NAME = /^--[A-Za-z_][\w-]*$/;
|
|
4126
|
+
const isBraceBalancedAtZero = (value) => {
|
|
4127
|
+
for (const char of value) {
|
|
4128
|
+
if (char === '{' || char === '}') {
|
|
4129
|
+
return false;
|
|
4130
|
+
}
|
|
4131
|
+
}
|
|
4132
|
+
return true;
|
|
4133
|
+
};
|
|
4134
|
+
const isPositionTryName = (value) => {
|
|
4135
|
+
if (!value || value.length > POSITION_TRY_NAME_MAX_LENGTH) {
|
|
4136
|
+
return false;
|
|
4137
|
+
}
|
|
4138
|
+
if (value.includes('@') || value.includes('.') || /\s/.test(value)) {
|
|
4139
|
+
return false;
|
|
4140
|
+
}
|
|
4141
|
+
const lowered = value.toLowerCase();
|
|
4142
|
+
if (REJECTED_IN_NAME_OR_BODY.some(rejected => lowered.includes(rejected))) {
|
|
4143
|
+
return false;
|
|
4144
|
+
}
|
|
4145
|
+
return ALLOWED_NAME.test(value);
|
|
4146
|
+
};
|
|
4147
|
+
const isCssPositionTryBody = (value) => {
|
|
4148
|
+
const trimmed = value.trim();
|
|
4149
|
+
if (!trimmed || trimmed.length > POSITION_TRY_BODY_MAX_LENGTH) {
|
|
4150
|
+
return false;
|
|
4151
|
+
}
|
|
4152
|
+
if (REJECTED_CONTROL_CHARACTERS.test(trimmed) || !isBraceBalancedAtZero(trimmed)) {
|
|
4153
|
+
return false;
|
|
4154
|
+
}
|
|
4155
|
+
const lowered = trimmed.toLowerCase();
|
|
4156
|
+
return !REJECTED_IN_NAME_OR_BODY.some(rejected => lowered.includes(rejected));
|
|
4157
|
+
};
|
|
4158
|
+
const sanitizeProjectCssPositionTry = (positionTry) => {
|
|
4159
|
+
if (!positionTry) {
|
|
4160
|
+
return {};
|
|
4161
|
+
}
|
|
4162
|
+
const sanitized = {};
|
|
4163
|
+
for (const [rawName, rawValue] of Object.entries(positionTry)) {
|
|
4164
|
+
const name = rawName.trim();
|
|
4165
|
+
if (!isPositionTryName(name) || sanitized[name] !== undefined || typeof rawValue !== 'string') {
|
|
4166
|
+
continue;
|
|
4167
|
+
}
|
|
4168
|
+
const value = rawValue.trim();
|
|
4169
|
+
if (!isCssPositionTryBody(value)) {
|
|
4170
|
+
continue;
|
|
4171
|
+
}
|
|
4172
|
+
sanitized[name] = value;
|
|
4173
|
+
if (Object.keys(sanitized).length === MAX_PROJECT_POSITION_TRY) {
|
|
4174
|
+
break;
|
|
4175
|
+
}
|
|
4176
|
+
}
|
|
4177
|
+
return Object.fromEntries(Object.entries(sanitized).sort(([left], [right]) => left.localeCompare(right)));
|
|
4178
|
+
};
|
|
4179
|
+
const indentDeclarationBody = (body) => body
|
|
4180
|
+
.split('\n')
|
|
4181
|
+
.map(line => ` ${line}`)
|
|
4182
|
+
.join('\n');
|
|
4183
|
+
/**
|
|
4184
|
+
* Unscoped `@position-try` blocks. `publishedKey` is unused (document-global
|
|
4185
|
+
* at-rule) and kept so the signature matches fonts/keyframes.
|
|
4186
|
+
*/
|
|
4187
|
+
const formatProjectCssPositionTryStylesheet = (publishedKey, positionTry, includePositionTry) => {
|
|
4188
|
+
if (!shouldIncludePositionTryOnPublishedWidget(includePositionTry)) {
|
|
4189
|
+
return null;
|
|
4190
|
+
}
|
|
4191
|
+
const sanitized = sanitizeProjectCssPositionTry(positionTry);
|
|
4192
|
+
const names = Object.keys(sanitized);
|
|
4193
|
+
if (names.length === 0) {
|
|
4194
|
+
return null;
|
|
4195
|
+
}
|
|
4196
|
+
void publishedKey;
|
|
4197
|
+
return names
|
|
4198
|
+
.map(name => `@position-try ${name} {\n${indentDeclarationBody(sanitized[name])}\n}`)
|
|
4199
|
+
.join('\n\n');
|
|
4200
|
+
};
|
|
4201
|
+
|
|
4202
|
+
/**
|
|
4203
|
+
* Emits one unscoped `<style data-rulecms-project-position-try>` from the
|
|
4204
|
+
* project catalog, or nothing when the catalog is empty / unsanitary.
|
|
4205
|
+
*/
|
|
4206
|
+
class ProjectCssPositionTryStylesheetComponent {
|
|
4207
|
+
get css() {
|
|
4208
|
+
return formatProjectCssPositionTryStylesheet(this.publishedKey, this.positionTry);
|
|
4209
|
+
}
|
|
4210
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssPositionTryStylesheetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
4211
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: ProjectCssPositionTryStylesheetComponent, isStandalone: true, selector: "rulecms-project-css-position-try-stylesheet", inputs: { publishedKey: "publishedKey", positionTry: "positionTry" }, ngImport: i0, template: `
|
|
4212
|
+
@if (css) {
|
|
4213
|
+
<style data-rulecms-project-position-try="" [innerText]="css"></style>
|
|
4214
|
+
}
|
|
4215
|
+
`, isInline: true }); }
|
|
4216
|
+
}
|
|
4217
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssPositionTryStylesheetComponent, decorators: [{
|
|
4218
|
+
type: Component,
|
|
4219
|
+
args: [{
|
|
4220
|
+
selector: 'rulecms-project-css-position-try-stylesheet',
|
|
4221
|
+
standalone: true,
|
|
4222
|
+
template: `
|
|
4223
|
+
@if (css) {
|
|
4224
|
+
<style data-rulecms-project-position-try="" [innerText]="css"></style>
|
|
4225
|
+
}
|
|
4226
|
+
`,
|
|
4227
|
+
}]
|
|
4228
|
+
}], propDecorators: { publishedKey: [{
|
|
4229
|
+
type: Input,
|
|
4230
|
+
args: [{ required: true }]
|
|
4231
|
+
}], positionTry: [{
|
|
4232
|
+
type: Input
|
|
4233
|
+
}] } });
|
|
4234
|
+
|
|
4235
|
+
/**
|
|
4236
|
+
* Missing/undefined on a widget GET payload means include. Only an explicit
|
|
4237
|
+
* `false` turns emission off, even if `cssProperties` is still present.
|
|
4238
|
+
*/
|
|
4239
|
+
function shouldIncludeCssPropertiesOnPublishedWidget(includeCssProperties) {
|
|
4240
|
+
return includeCssProperties !== false;
|
|
4241
|
+
}
|
|
4242
|
+
|
|
4243
|
+
const PROJECT_CSS_PROPERTY_SYNTAX_VALUES = [
|
|
4244
|
+
'*',
|
|
4245
|
+
'<number>',
|
|
4246
|
+
'<integer>',
|
|
4247
|
+
'<length>',
|
|
4248
|
+
'<percentage>',
|
|
4249
|
+
'<length-percentage>',
|
|
4250
|
+
'<color>',
|
|
4251
|
+
'<angle>',
|
|
4252
|
+
'<time>',
|
|
4253
|
+
'<transform-function>',
|
|
4254
|
+
'<transform-list>',
|
|
4255
|
+
];
|
|
4256
|
+
const PROPERTY_SYNTAX_SET = new Set(PROJECT_CSS_PROPERTY_SYNTAX_VALUES);
|
|
4257
|
+
const REJECTED_IN_EMITTED_VALUE$2 = /[{};]/;
|
|
4258
|
+
const MAX_PROJECT_CSS_PROPERTIES = 40;
|
|
4259
|
+
const PROPERTY_INITIAL_VALUE_MAX_LENGTH = 200;
|
|
4260
|
+
const isAllowlistedSyntax = (value) => typeof value === 'string' && PROPERTY_SYNTAX_SET.has(value);
|
|
4261
|
+
const isSafeInitialValue = (value, syntax) => {
|
|
4262
|
+
if (syntax !== '*' && value === '') {
|
|
4263
|
+
return false;
|
|
4264
|
+
}
|
|
4265
|
+
if (syntax === '*' && value === '') {
|
|
4266
|
+
return true;
|
|
4267
|
+
}
|
|
4268
|
+
if (value.length > PROPERTY_INITIAL_VALUE_MAX_LENGTH) {
|
|
4269
|
+
return false;
|
|
4270
|
+
}
|
|
4271
|
+
if (REJECTED_IN_EMITTED_VALUE$2.test(value) || value.includes('url(') || value.includes('@')) {
|
|
4272
|
+
return false;
|
|
4273
|
+
}
|
|
4274
|
+
return true;
|
|
4275
|
+
};
|
|
4276
|
+
const sanitizeProjectCssProperties = (cssProperties) => {
|
|
4277
|
+
if (!Array.isArray(cssProperties)) {
|
|
4278
|
+
return [];
|
|
4279
|
+
}
|
|
4280
|
+
const sanitized = [];
|
|
4281
|
+
const seen = new Set();
|
|
4282
|
+
for (const raw of cssProperties) {
|
|
4283
|
+
if (!raw || typeof raw.name !== 'string' || !isCssVariableName(raw.name.trim())) {
|
|
4284
|
+
continue;
|
|
4285
|
+
}
|
|
4286
|
+
const name = raw.name.trim();
|
|
4287
|
+
if (seen.has(name) || sanitized.length >= MAX_PROJECT_CSS_PROPERTIES) {
|
|
4288
|
+
continue;
|
|
4289
|
+
}
|
|
4290
|
+
if (!isAllowlistedSyntax(raw.syntax)) {
|
|
4291
|
+
continue;
|
|
4292
|
+
}
|
|
4293
|
+
if (typeof raw.inherits !== 'boolean') {
|
|
4294
|
+
continue;
|
|
4295
|
+
}
|
|
4296
|
+
const initialValue = typeof raw.initialValue === 'string' ? raw.initialValue.trim() : '';
|
|
4297
|
+
if (!isSafeInitialValue(initialValue, raw.syntax)) {
|
|
4298
|
+
continue;
|
|
4299
|
+
}
|
|
4300
|
+
seen.add(name);
|
|
4301
|
+
sanitized.push({
|
|
4302
|
+
name,
|
|
4303
|
+
syntax: raw.syntax,
|
|
4304
|
+
inherits: raw.inherits,
|
|
4305
|
+
initialValue,
|
|
4306
|
+
});
|
|
4307
|
+
}
|
|
4308
|
+
return sanitized;
|
|
4309
|
+
};
|
|
4310
|
+
const formatOneProperty = (property) => {
|
|
4311
|
+
const lines = [
|
|
4312
|
+
`@property ${property.name} {`,
|
|
4313
|
+
` syntax: "${property.syntax}";`,
|
|
4314
|
+
` inherits: ${property.inherits ? 'true' : 'false'};`,
|
|
4315
|
+
];
|
|
4316
|
+
if (property.initialValue !== '') {
|
|
4317
|
+
lines.push(` initial-value: ${property.initialValue};`);
|
|
4318
|
+
}
|
|
4319
|
+
lines.push('}');
|
|
4320
|
+
return lines.join('\n');
|
|
4321
|
+
};
|
|
4322
|
+
/**
|
|
4323
|
+
* Unscoped `@property` blocks. `publishedKey` is unused (document-global
|
|
4324
|
+
* at-rule) and kept so the signature matches fonts/keyframes.
|
|
4325
|
+
*/
|
|
4326
|
+
const formatProjectCssPropertiesStylesheet = (publishedKey, cssProperties, includeCssProperties) => {
|
|
4327
|
+
if (!shouldIncludeCssPropertiesOnPublishedWidget(includeCssProperties)) {
|
|
4328
|
+
return null;
|
|
4329
|
+
}
|
|
4330
|
+
const sanitized = sanitizeProjectCssProperties(cssProperties);
|
|
4331
|
+
if (sanitized.length === 0) {
|
|
4332
|
+
return null;
|
|
4333
|
+
}
|
|
4334
|
+
void publishedKey;
|
|
4335
|
+
return sanitized.map(formatOneProperty).join('\n\n');
|
|
4336
|
+
};
|
|
4337
|
+
|
|
4338
|
+
/**
|
|
4339
|
+
* Emits one unscoped `<style data-rulecms-project-css-properties>` from the
|
|
4340
|
+
* project catalog, or nothing when the catalog is empty / unsanitary.
|
|
4341
|
+
*/
|
|
4342
|
+
class ProjectCssPropertiesStylesheetComponent {
|
|
4343
|
+
get css() {
|
|
4344
|
+
return formatProjectCssPropertiesStylesheet(this.publishedKey, this.cssProperties);
|
|
4345
|
+
}
|
|
4346
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssPropertiesStylesheetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
4347
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: ProjectCssPropertiesStylesheetComponent, isStandalone: true, selector: "rulecms-project-css-properties-stylesheet", inputs: { publishedKey: "publishedKey", cssProperties: "cssProperties" }, ngImport: i0, template: `
|
|
4348
|
+
@if (css) {
|
|
4349
|
+
<style data-rulecms-project-css-properties="" [innerText]="css"></style>
|
|
4350
|
+
}
|
|
4351
|
+
`, isInline: true }); }
|
|
4352
|
+
}
|
|
4353
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssPropertiesStylesheetComponent, decorators: [{
|
|
4354
|
+
type: Component,
|
|
4355
|
+
args: [{
|
|
4356
|
+
selector: 'rulecms-project-css-properties-stylesheet',
|
|
4357
|
+
standalone: true,
|
|
4358
|
+
template: `
|
|
4359
|
+
@if (css) {
|
|
4360
|
+
<style data-rulecms-project-css-properties="" [innerText]="css"></style>
|
|
4361
|
+
}
|
|
4362
|
+
`,
|
|
4363
|
+
}]
|
|
4364
|
+
}], propDecorators: { publishedKey: [{
|
|
4365
|
+
type: Input,
|
|
4366
|
+
args: [{ required: true }]
|
|
4367
|
+
}], cssProperties: [{
|
|
4368
|
+
type: Input
|
|
4369
|
+
}] } });
|
|
4370
|
+
|
|
4371
|
+
/**
|
|
4372
|
+
* Missing/undefined on a widget GET payload means include — the default, and
|
|
4373
|
+
* the shape older clients already understand. Only an explicit `false` turns
|
|
4374
|
+
* emission off, even if `cssVariables` is still present on the payload.
|
|
4375
|
+
*/
|
|
4376
|
+
function shouldIncludeCssVariablesOnPublishedWidget(includeCssVariables) {
|
|
4377
|
+
return includeCssVariables !== false;
|
|
4378
|
+
}
|
|
4379
|
+
|
|
4380
|
+
/**
|
|
4381
|
+
* Attribute-selector escape so a published key cannot break out of
|
|
4382
|
+
* `[data-rulecms-published-key="…"]`. `CSS.escape` is not assumed (SSR / Node).
|
|
4383
|
+
*/
|
|
4384
|
+
const escapeCssAttributeValue = (value) => value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
4385
|
+
const REJECTED_IN_EMITTED_VALUE$1 = /[{};]/;
|
|
4386
|
+
const sanitizeForStylesheet = (variables) => {
|
|
4387
|
+
if (!variables) {
|
|
4388
|
+
return {};
|
|
4389
|
+
}
|
|
4390
|
+
const sanitized = {};
|
|
4391
|
+
for (const [rawName, rawValue] of Object.entries(variables)) {
|
|
4392
|
+
if (!isCssVariableName(rawName) || typeof rawValue !== 'string') {
|
|
4393
|
+
continue;
|
|
4394
|
+
}
|
|
4395
|
+
const value = rawValue.trim();
|
|
4396
|
+
if (value === '' || REJECTED_IN_EMITTED_VALUE$1.test(value)) {
|
|
4397
|
+
continue;
|
|
4398
|
+
}
|
|
4399
|
+
sanitized[rawName.trim()] = value;
|
|
4400
|
+
}
|
|
4401
|
+
return sanitized;
|
|
4402
|
+
};
|
|
4403
|
+
/**
|
|
4404
|
+
* One rule: custom properties on the first boxed children of this widget’s
|
|
4405
|
+
* published-key span. Empty / flag-off / unsanitary catalogs return null so
|
|
4406
|
+
* the caller omits the `<style>` tag.
|
|
4407
|
+
*/
|
|
4408
|
+
const formatProjectCssVariablesStylesheet = (publishedKey, variables, includeCssVariables) => {
|
|
4409
|
+
if (!shouldIncludeCssVariablesOnPublishedWidget(includeCssVariables)) {
|
|
4410
|
+
return null;
|
|
4411
|
+
}
|
|
4412
|
+
const sanitized = sanitizeForStylesheet(variables);
|
|
4413
|
+
const names = Object.keys(sanitized);
|
|
4414
|
+
if (names.length === 0 || !publishedKey) {
|
|
4415
|
+
return null;
|
|
4416
|
+
}
|
|
4417
|
+
const selector = `[data-rulecms-published-key="${escapeCssAttributeValue(publishedKey)}"] > *`;
|
|
4418
|
+
const declarations = names
|
|
4419
|
+
.sort((left, right) => left.localeCompare(right))
|
|
4420
|
+
.map((name) => ` ${name}: ${sanitized[name]};`)
|
|
4421
|
+
.join('\n');
|
|
4422
|
+
return `${selector} {\n${declarations}\n}`;
|
|
4423
|
+
};
|
|
4424
|
+
|
|
4425
|
+
/**
|
|
4426
|
+
* Missing/undefined on a widget GET payload means include. Only an explicit
|
|
4427
|
+
* `false` turns emission off, even if `themes` is still present.
|
|
4428
|
+
*/
|
|
4429
|
+
function shouldIncludeThemesOnPublishedWidget(includeThemes) {
|
|
4430
|
+
return includeThemes !== false;
|
|
4431
|
+
}
|
|
4432
|
+
|
|
4433
|
+
const MAX_PROJECT_THEMES = 5;
|
|
4434
|
+
const MAX_THEME_VARIABLES = 200;
|
|
4435
|
+
const ALLOWED_CONDITIONS = [
|
|
4436
|
+
{ kind: 'prefers-color-scheme', value: 'dark' },
|
|
4437
|
+
{ kind: 'prefers-color-scheme', value: 'light' },
|
|
4438
|
+
{ kind: 'html-class', value: 'dark' },
|
|
4439
|
+
{ kind: 'data-theme', value: 'dark' },
|
|
4440
|
+
{ kind: 'data-theme', value: 'light' },
|
|
4441
|
+
];
|
|
4442
|
+
const REJECTED_IN_EMITTED_VALUE = /[{};]/;
|
|
4443
|
+
const isAllowedCondition = (value) => {
|
|
4444
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
4445
|
+
return false;
|
|
4446
|
+
}
|
|
4447
|
+
const raw = value;
|
|
4448
|
+
return ALLOWED_CONDITIONS.some(option => option.kind === raw.kind && option.value === raw.value);
|
|
4449
|
+
};
|
|
4450
|
+
const sanitizeVariables = (variables) => {
|
|
4451
|
+
if (!variables || typeof variables !== 'object' || Array.isArray(variables)) {
|
|
4452
|
+
return {};
|
|
4453
|
+
}
|
|
4454
|
+
const sanitized = {};
|
|
4455
|
+
for (const [rawName, rawValue] of Object.entries(variables)) {
|
|
4456
|
+
if (!isCssVariableName(rawName) || typeof rawValue !== 'string') {
|
|
4457
|
+
continue;
|
|
4458
|
+
}
|
|
4459
|
+
const value = rawValue.trim();
|
|
4460
|
+
if (value === '' || REJECTED_IN_EMITTED_VALUE.test(value) || value.includes('url(') || value.includes('@')) {
|
|
4461
|
+
continue;
|
|
4462
|
+
}
|
|
4463
|
+
sanitized[rawName.trim()] = value;
|
|
4464
|
+
}
|
|
4465
|
+
return Object.fromEntries(Object.entries(sanitized).sort(([left], [right]) => left.localeCompare(right)));
|
|
4466
|
+
};
|
|
4467
|
+
const sanitizeProjectCssThemes = (themes) => {
|
|
4468
|
+
if (!Array.isArray(themes)) {
|
|
4469
|
+
return [];
|
|
4470
|
+
}
|
|
4471
|
+
const sanitized = [];
|
|
4472
|
+
const seen = new Set();
|
|
4473
|
+
let variableCount = 0;
|
|
4474
|
+
for (const raw of themes) {
|
|
4475
|
+
if (!raw || !isAllowedCondition(raw.condition)) {
|
|
4476
|
+
continue;
|
|
4477
|
+
}
|
|
4478
|
+
const id = `${raw.condition.kind}:${raw.condition.value}`;
|
|
4479
|
+
if (seen.has(id)) {
|
|
4480
|
+
continue;
|
|
4481
|
+
}
|
|
4482
|
+
const variables = sanitizeVariables(raw.variables);
|
|
4483
|
+
const nextCount = variableCount + Object.keys(variables).length;
|
|
4484
|
+
if (Object.keys(variables).length === 0 || nextCount > MAX_THEME_VARIABLES) {
|
|
4485
|
+
continue;
|
|
4486
|
+
}
|
|
4487
|
+
seen.add(id);
|
|
4488
|
+
variableCount = nextCount;
|
|
4489
|
+
sanitized.push({ condition: raw.condition, variables });
|
|
4490
|
+
if (sanitized.length === MAX_PROJECT_THEMES) {
|
|
4491
|
+
break;
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
return sanitized;
|
|
4495
|
+
};
|
|
4496
|
+
const formatVariableBlock = (variables, tokenSelector) => {
|
|
4497
|
+
const lines = Object.entries(variables).map(([name, value]) => ` ${name}: ${value};`);
|
|
4498
|
+
return `${tokenSelector} {\n${lines.join('\n')}\n}`;
|
|
4499
|
+
};
|
|
4500
|
+
const indentBlock = (css) => css
|
|
4501
|
+
.split('\n')
|
|
4502
|
+
.map(line => ` ${line}`)
|
|
4503
|
+
.join('\n');
|
|
4504
|
+
const formatThemeRule = (theme, tokenSelector) => {
|
|
4505
|
+
const block = formatVariableBlock(theme.variables, tokenSelector);
|
|
4506
|
+
const { kind, value } = theme.condition;
|
|
4507
|
+
if (kind === 'prefers-color-scheme') {
|
|
4508
|
+
return `@media (prefers-color-scheme: ${value}) {\n${indentBlock(block)}\n}`;
|
|
4509
|
+
}
|
|
4510
|
+
if (kind === 'html-class') {
|
|
4511
|
+
return `html.${value} ${block}`;
|
|
4512
|
+
}
|
|
4513
|
+
return `[data-theme="${value}"] ${block}`;
|
|
4514
|
+
};
|
|
4515
|
+
/**
|
|
4516
|
+
* Host-condition token overrides on boxed children of this widget’s published-key
|
|
4517
|
+
* span. Never styles `html` / `:root` / `body`. Empty / flag-off / unsanitary
|
|
4518
|
+
* catalogs return null so the caller omits the `<style>` tag.
|
|
4519
|
+
*/
|
|
4520
|
+
const formatProjectCssThemesStylesheet = (publishedKey, themes, includeThemes) => {
|
|
4521
|
+
if (!shouldIncludeThemesOnPublishedWidget(includeThemes) || !publishedKey) {
|
|
4522
|
+
return null;
|
|
4523
|
+
}
|
|
4524
|
+
const sanitized = sanitizeProjectCssThemes(themes);
|
|
4525
|
+
if (sanitized.length === 0) {
|
|
4526
|
+
return null;
|
|
4527
|
+
}
|
|
4528
|
+
const tokenSelector = `[data-rulecms-published-key="${escapeCssAttributeValue(publishedKey)}"] > *`;
|
|
4529
|
+
return sanitized.map(theme => formatThemeRule(theme, tokenSelector)).join('\n\n');
|
|
4530
|
+
};
|
|
4531
|
+
|
|
4532
|
+
/**
|
|
4533
|
+
* Emits one `<style data-rulecms-project-themes>` from the project catalog,
|
|
4534
|
+
* or nothing when the catalog is empty / unsanitary.
|
|
4535
|
+
*/
|
|
4536
|
+
class ProjectCssThemesStylesheetComponent {
|
|
4537
|
+
get css() {
|
|
4538
|
+
return formatProjectCssThemesStylesheet(this.publishedKey, this.themes);
|
|
4539
|
+
}
|
|
4540
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssThemesStylesheetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
4541
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: ProjectCssThemesStylesheetComponent, isStandalone: true, selector: "rulecms-project-css-themes-stylesheet", inputs: { publishedKey: "publishedKey", themes: "themes" }, ngImport: i0, template: `
|
|
4542
|
+
@if (css) {
|
|
4543
|
+
<style data-rulecms-project-themes="" [innerText]="css"></style>
|
|
4544
|
+
}
|
|
4545
|
+
`, isInline: true }); }
|
|
4546
|
+
}
|
|
4547
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssThemesStylesheetComponent, decorators: [{
|
|
4548
|
+
type: Component,
|
|
4549
|
+
args: [{
|
|
4550
|
+
selector: 'rulecms-project-css-themes-stylesheet',
|
|
4551
|
+
standalone: true,
|
|
4552
|
+
template: `
|
|
4553
|
+
@if (css) {
|
|
4554
|
+
<style data-rulecms-project-themes="" [innerText]="css"></style>
|
|
4555
|
+
}
|
|
4556
|
+
`,
|
|
4557
|
+
}]
|
|
4558
|
+
}], propDecorators: { publishedKey: [{
|
|
4559
|
+
type: Input,
|
|
4560
|
+
args: [{ required: true }]
|
|
4561
|
+
}], themes: [{
|
|
4562
|
+
type: Input
|
|
4563
|
+
}] } });
|
|
4564
|
+
|
|
4565
|
+
/**
|
|
4566
|
+
* Emits one scoped `<style data-rulecms-project-css-variables>` from the
|
|
4567
|
+
* project catalog, or nothing when the catalog is empty / unsanitary.
|
|
4568
|
+
*/
|
|
4569
|
+
class ProjectCssVariablesStylesheetComponent {
|
|
4570
|
+
get css() {
|
|
4571
|
+
return formatProjectCssVariablesStylesheet(this.publishedKey, this.variables);
|
|
4572
|
+
}
|
|
4573
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssVariablesStylesheetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
4574
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: ProjectCssVariablesStylesheetComponent, isStandalone: true, selector: "rulecms-project-css-variables-stylesheet", inputs: { publishedKey: "publishedKey", variables: "variables" }, ngImport: i0, template: `
|
|
4575
|
+
@if (css) {
|
|
4576
|
+
<style data-rulecms-project-css-variables="" [innerText]="css"></style>
|
|
4577
|
+
}
|
|
4578
|
+
`, isInline: true }); }
|
|
4579
|
+
}
|
|
4580
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssVariablesStylesheetComponent, decorators: [{
|
|
4581
|
+
type: Component,
|
|
4582
|
+
args: [{
|
|
4583
|
+
selector: 'rulecms-project-css-variables-stylesheet',
|
|
4584
|
+
standalone: true,
|
|
4585
|
+
template: `
|
|
4586
|
+
@if (css) {
|
|
4587
|
+
<style data-rulecms-project-css-variables="" [innerText]="css"></style>
|
|
4588
|
+
}
|
|
4589
|
+
`,
|
|
4590
|
+
}]
|
|
4591
|
+
}], propDecorators: { publishedKey: [{
|
|
4592
|
+
type: Input,
|
|
4593
|
+
args: [{ required: true }]
|
|
4594
|
+
}], variables: [{
|
|
4595
|
+
type: Input
|
|
4596
|
+
}] } });
|
|
4597
|
+
|
|
4598
|
+
/**
|
|
4599
|
+
* Missing/undefined on a widget GET payload means include. Only an explicit
|
|
4600
|
+
* `false` turns emission off, even if `widgetChrome` is still present.
|
|
4601
|
+
*/
|
|
4602
|
+
function shouldIncludeWidgetChromeOnPublishedWidget(includeWidgetChrome) {
|
|
4603
|
+
return includeWidgetChrome !== false;
|
|
4604
|
+
}
|
|
4605
|
+
|
|
4606
|
+
const PROJECT_WIDGET_CHROME_COLOR_SCHEME_VALUES = [
|
|
4607
|
+
'light',
|
|
4608
|
+
'dark',
|
|
4609
|
+
'light dark',
|
|
4610
|
+
];
|
|
4611
|
+
const PROJECT_WIDGET_CHROME_SCROLLBAR_WIDTH_VALUES = ['auto', 'thin', 'none'];
|
|
4612
|
+
const COLOR_SCHEME_SET = new Set(PROJECT_WIDGET_CHROME_COLOR_SCHEME_VALUES);
|
|
4613
|
+
const SCROLLBAR_WIDTH_SET = new Set(PROJECT_WIDGET_CHROME_SCROLLBAR_WIDTH_VALUES);
|
|
4614
|
+
const REJECTED_IN_VALUE = /[{};]|url\(|@/i;
|
|
4615
|
+
const isSafeColorValue = (value) => typeof value === 'string' &&
|
|
4616
|
+
value.trim() !== '' &&
|
|
4617
|
+
value.trim().length <= 400 &&
|
|
4618
|
+
!REJECTED_IN_VALUE.test(value);
|
|
4619
|
+
const optionalColor = (value) => isSafeColorValue(value) ? value.trim() : undefined;
|
|
4620
|
+
const sanitizeProjectWidgetChrome = (widgetChrome) => {
|
|
4621
|
+
if (!widgetChrome || typeof widgetChrome !== 'object' || Array.isArray(widgetChrome)) {
|
|
4622
|
+
return null;
|
|
4623
|
+
}
|
|
4624
|
+
const selectionBackground = optionalColor(widgetChrome.selectionBackground);
|
|
4625
|
+
const selectionColor = optionalColor(widgetChrome.selectionColor);
|
|
4626
|
+
const caretColor = optionalColor(widgetChrome.caretColor);
|
|
4627
|
+
const scrollbarColor = optionalColor(widgetChrome.scrollbarColor);
|
|
4628
|
+
const sanitized = {
|
|
4629
|
+
...(typeof widgetChrome.colorScheme === 'string' &&
|
|
4630
|
+
COLOR_SCHEME_SET.has(widgetChrome.colorScheme)
|
|
4631
|
+
? { colorScheme: widgetChrome.colorScheme }
|
|
4632
|
+
: {}),
|
|
4633
|
+
...(selectionBackground ? { selectionBackground } : {}),
|
|
4634
|
+
...(selectionColor ? { selectionColor } : {}),
|
|
4635
|
+
...(caretColor ? { caretColor } : {}),
|
|
4636
|
+
...(scrollbarColor ? { scrollbarColor } : {}),
|
|
4637
|
+
...(typeof widgetChrome.scrollbarWidth === 'string' &&
|
|
4638
|
+
SCROLLBAR_WIDTH_SET.has(widgetChrome.scrollbarWidth)
|
|
4639
|
+
? { scrollbarWidth: widgetChrome.scrollbarWidth }
|
|
4640
|
+
: {}),
|
|
4641
|
+
};
|
|
4642
|
+
return Object.keys(sanitized).length > 0 ? sanitized : null;
|
|
4643
|
+
};
|
|
4644
|
+
/**
|
|
4645
|
+
* Color-scheme, caret, and scrollbars on boxed children of the published-key
|
|
4646
|
+
* wrapper; selection on that subtree. Never `:root` / `html` / `body`.
|
|
4647
|
+
*/
|
|
4648
|
+
const formatProjectCssWidgetChromeStylesheet = (publishedKey, widgetChrome, includeWidgetChrome) => {
|
|
4649
|
+
if (!shouldIncludeWidgetChromeOnPublishedWidget(includeWidgetChrome) || !publishedKey) {
|
|
4650
|
+
return null;
|
|
4651
|
+
}
|
|
4652
|
+
const sanitized = sanitizeProjectWidgetChrome(widgetChrome);
|
|
4653
|
+
if (!sanitized) {
|
|
4654
|
+
return null;
|
|
4655
|
+
}
|
|
4656
|
+
const ancestor = `[data-rulecms-published-key="${escapeCssAttributeValue$1(publishedKey)}"]`;
|
|
4657
|
+
const surfaceDeclarations = [];
|
|
4658
|
+
if (sanitized.colorScheme) {
|
|
4659
|
+
surfaceDeclarations.push(` color-scheme: ${sanitized.colorScheme};`);
|
|
4660
|
+
}
|
|
4661
|
+
if (sanitized.caretColor) {
|
|
4662
|
+
surfaceDeclarations.push(` caret-color: ${sanitized.caretColor};`);
|
|
4663
|
+
}
|
|
4664
|
+
if (sanitized.scrollbarWidth) {
|
|
4665
|
+
surfaceDeclarations.push(` scrollbar-width: ${sanitized.scrollbarWidth};`);
|
|
4666
|
+
}
|
|
4667
|
+
if (sanitized.scrollbarColor) {
|
|
4668
|
+
surfaceDeclarations.push(` scrollbar-color: ${sanitized.scrollbarColor};`);
|
|
4669
|
+
}
|
|
4670
|
+
const selectionDeclarations = [];
|
|
4671
|
+
if (sanitized.selectionBackground) {
|
|
4672
|
+
selectionDeclarations.push(` background: ${sanitized.selectionBackground};`);
|
|
4673
|
+
}
|
|
4674
|
+
if (sanitized.selectionColor) {
|
|
4675
|
+
selectionDeclarations.push(` color: ${sanitized.selectionColor};`);
|
|
4676
|
+
}
|
|
4677
|
+
const blocks = [];
|
|
4678
|
+
if (surfaceDeclarations.length > 0) {
|
|
4679
|
+
blocks.push(`${ancestor} > * {\n${surfaceDeclarations.join('\n')}\n}`);
|
|
4680
|
+
}
|
|
4681
|
+
if (selectionDeclarations.length > 0) {
|
|
4682
|
+
blocks.push(`${ancestor} > * ::selection {\n${selectionDeclarations.join('\n')}\n}`);
|
|
4683
|
+
}
|
|
4684
|
+
return blocks.length > 0 ? blocks.join('\n') : null;
|
|
4685
|
+
};
|
|
4686
|
+
|
|
4687
|
+
/**
|
|
4688
|
+
* Emits one `<style data-rulecms-project-widget-chrome>` from the project
|
|
4689
|
+
* catalog, or nothing when the catalog is empty / unsanitary.
|
|
4690
|
+
*/
|
|
4691
|
+
class ProjectCssWidgetChromeStylesheetComponent {
|
|
4692
|
+
get css() {
|
|
4693
|
+
return formatProjectCssWidgetChromeStylesheet(this.publishedKey, this.widgetChrome);
|
|
4694
|
+
}
|
|
4695
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssWidgetChromeStylesheetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
4696
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: ProjectCssWidgetChromeStylesheetComponent, isStandalone: true, selector: "rulecms-project-css-widget-chrome-stylesheet", inputs: { publishedKey: "publishedKey", widgetChrome: "widgetChrome" }, ngImport: i0, template: `
|
|
4697
|
+
@if (css) {
|
|
4698
|
+
<style data-rulecms-project-widget-chrome="" [innerText]="css"></style>
|
|
4699
|
+
}
|
|
4700
|
+
`, isInline: true }); }
|
|
4701
|
+
}
|
|
4702
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: ProjectCssWidgetChromeStylesheetComponent, decorators: [{
|
|
4703
|
+
type: Component,
|
|
4704
|
+
args: [{
|
|
4705
|
+
selector: 'rulecms-project-css-widget-chrome-stylesheet',
|
|
4706
|
+
standalone: true,
|
|
4707
|
+
template: `
|
|
4708
|
+
@if (css) {
|
|
4709
|
+
<style data-rulecms-project-widget-chrome="" [innerText]="css"></style>
|
|
4710
|
+
}
|
|
4711
|
+
`,
|
|
4712
|
+
}]
|
|
4713
|
+
}], propDecorators: { publishedKey: [{
|
|
4714
|
+
type: Input,
|
|
4715
|
+
args: [{ required: true }]
|
|
4716
|
+
}], widgetChrome: [{
|
|
4717
|
+
type: Input
|
|
4718
|
+
}] } });
|
|
4719
|
+
|
|
4720
|
+
/**
|
|
4721
|
+
* Missing/undefined on a widget GET payload means wrap when `classLayer` is
|
|
4722
|
+
* set. Only an explicit `false` keeps class emit unlayered.
|
|
4723
|
+
*/
|
|
4724
|
+
function shouldIncludeClassLayerOnPublishedWidget(includeClassLayer) {
|
|
4725
|
+
return includeClassLayer !== false;
|
|
4726
|
+
}
|
|
4727
|
+
|
|
4728
|
+
function transformChildCollections(childCollections) {
|
|
4729
|
+
const transformed = {};
|
|
4730
|
+
Object.entries(childCollections).forEach(([key, collection]) => {
|
|
4731
|
+
const collectionToUse = { ...collection };
|
|
4732
|
+
if (collectionToUse.itemList) {
|
|
4733
|
+
try {
|
|
4734
|
+
collectionToUse.collectionRows =
|
|
4735
|
+
typeof collectionToUse.itemList === 'string'
|
|
4736
|
+
? JSON.parse(collectionToUse.itemList)
|
|
4737
|
+
: collectionToUse.itemList;
|
|
4738
|
+
}
|
|
4739
|
+
catch (error) {
|
|
4740
|
+
console.error(`Failed to parse itemList for collection ${key}:`, error);
|
|
4741
|
+
collectionToUse.collectionRows = { rows: [] };
|
|
4742
|
+
}
|
|
3610
4743
|
}
|
|
3611
4744
|
let collectionKey = `${collectionToUse.name}$${key}`;
|
|
3612
4745
|
if (collectionToUse.parentId) {
|
|
@@ -3623,11 +4756,23 @@ function parseDisplayItemList(widget) {
|
|
|
3623
4756
|
}
|
|
3624
4757
|
/** Transform raw widget API data into render-ready displayItemList + collections. */
|
|
3625
4758
|
function prepareRuleCMSWidgetData(raw) {
|
|
4759
|
+
const fontFaces = sanitizeProjectFontFaces(raw.fontFaces);
|
|
4760
|
+
const keyframes = sanitizeProjectCssKeyframes(raw.keyframes);
|
|
4761
|
+
const themes = sanitizeProjectCssThemes(raw.themes);
|
|
4762
|
+
const cssProperties = sanitizeProjectCssProperties(raw.cssProperties);
|
|
4763
|
+
const widgetChrome = sanitizeProjectWidgetChrome(raw.widgetChrome);
|
|
4764
|
+
const positionTry = sanitizeProjectCssPositionTry(raw.positionTry);
|
|
4765
|
+
const classLayer = shouldIncludeClassLayerOnPublishedWidget(raw.includeClassLayer) &&
|
|
4766
|
+
isProjectCssClassLayer(raw.classLayer)
|
|
4767
|
+
? raw.classLayer
|
|
4768
|
+
: undefined;
|
|
3626
4769
|
return {
|
|
3627
4770
|
displayItemList: parseDisplayItemList(raw.widget),
|
|
3628
4771
|
widgetCollections: transformChildCollections(raw.childCollections),
|
|
3629
4772
|
...(raw.libraries ? { libraries: raw.libraries } : {}),
|
|
3630
|
-
...(
|
|
4773
|
+
...(shouldIncludeCssVariablesOnPublishedWidget(raw.includeCssVariables) &&
|
|
4774
|
+
raw.cssVariables &&
|
|
4775
|
+
Object.keys(raw.cssVariables).length > 0
|
|
3631
4776
|
? { cssVariables: raw.cssVariables }
|
|
3632
4777
|
: {}),
|
|
3633
4778
|
...(shouldIncludeClassDefinitionsOnPublishedWidget(raw.includeClassDefinitions) &&
|
|
@@ -3635,6 +4780,28 @@ function prepareRuleCMSWidgetData(raw) {
|
|
|
3635
4780
|
Object.keys(raw.classDefinitions).length > 0
|
|
3636
4781
|
? { classDefinitions: raw.classDefinitions }
|
|
3637
4782
|
: {}),
|
|
4783
|
+
...(shouldIncludeFontFacesOnPublishedWidget(raw.includeFontFaces) && fontFaces.length > 0
|
|
4784
|
+
? { fontFaces }
|
|
4785
|
+
: {}),
|
|
4786
|
+
...(shouldIncludeKeyframesOnPublishedWidget(raw.includeKeyframes) &&
|
|
4787
|
+
Object.keys(keyframes).length > 0
|
|
4788
|
+
? { keyframes }
|
|
4789
|
+
: {}),
|
|
4790
|
+
...(shouldIncludeThemesOnPublishedWidget(raw.includeThemes) && themes.length > 0
|
|
4791
|
+
? { themes }
|
|
4792
|
+
: {}),
|
|
4793
|
+
...(shouldIncludeCssPropertiesOnPublishedWidget(raw.includeCssProperties) &&
|
|
4794
|
+
cssProperties.length > 0
|
|
4795
|
+
? { cssProperties }
|
|
4796
|
+
: {}),
|
|
4797
|
+
...(shouldIncludeWidgetChromeOnPublishedWidget(raw.includeWidgetChrome) && widgetChrome
|
|
4798
|
+
? { widgetChrome }
|
|
4799
|
+
: {}),
|
|
4800
|
+
...(classLayer ? { classLayer } : {}),
|
|
4801
|
+
...(shouldIncludePositionTryOnPublishedWidget(raw.includePositionTry) &&
|
|
4802
|
+
Object.keys(positionTry).length > 0
|
|
4803
|
+
? { positionTry }
|
|
4804
|
+
: {}),
|
|
3638
4805
|
};
|
|
3639
4806
|
}
|
|
3640
4807
|
|
|
@@ -3655,6 +4822,152 @@ function resolveSourceComponentsPlugin(params) {
|
|
|
3655
4822
|
return registry.resolve({ registrations: params.libraries, referenced });
|
|
3656
4823
|
}
|
|
3657
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
|
+
|
|
3658
4971
|
const loadingContainerStyle = {
|
|
3659
4972
|
display: 'flex',
|
|
3660
4973
|
justifyContent: 'center',
|
|
@@ -3708,11 +5021,19 @@ class RuleCMSWidgetComponent {
|
|
|
3708
5021
|
constructor(context, errorHandler) {
|
|
3709
5022
|
this.context = context;
|
|
3710
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 = '';
|
|
3711
5030
|
/**
|
|
3712
5031
|
* `'client-fetch'` (default) fetches in the browser.
|
|
3713
5032
|
* `'pre-fetched'` renders `initialData` with CSS breakpoint variants.
|
|
3714
5033
|
*/
|
|
3715
5034
|
this.mode = 'client-fetch';
|
|
5035
|
+
/** Fires when a ruleset resolve returns a selection. */
|
|
5036
|
+
this.selectionChange = new EventEmitter();
|
|
3716
5037
|
this.publishedKeyAttribute = RULECMS_PUBLISHED_KEY_ATTRIBUTE;
|
|
3717
5038
|
this.loadingContainerStyle = loadingContainerStyle;
|
|
3718
5039
|
this.spinnerContainerStyle = spinnerContainerStyle;
|
|
@@ -3720,18 +5041,26 @@ class RuleCMSWidgetComponent {
|
|
|
3720
5041
|
this.errorContainerStyle = errorContainerStyle;
|
|
3721
5042
|
this.errorTitleStyle = errorTitleStyle;
|
|
3722
5043
|
this.errorMessageStyle = errorMessageStyle;
|
|
3723
|
-
this.loading =
|
|
5044
|
+
this.loading = true;
|
|
3724
5045
|
this.error = null;
|
|
3725
5046
|
this.preparedData = null;
|
|
3726
5047
|
this.sourceComponentsPlugin = null;
|
|
3727
5048
|
this.useBreakpointVariants = false;
|
|
5049
|
+
this.selection = null;
|
|
5050
|
+
/** Published key of the widget a ruleset chose, when `publishedKey` was omitted. */
|
|
5051
|
+
this.resolvedPublishedKey = '';
|
|
3728
5052
|
this.abortController = null;
|
|
3729
5053
|
this.lastFetchKey = null;
|
|
3730
5054
|
this.stylesInjected = false;
|
|
5055
|
+
this.fetchGeneration = 0;
|
|
3731
5056
|
}
|
|
3732
5057
|
get plugins() {
|
|
3733
5058
|
return { sourceComponents: this.sourceComponentsPlugin ?? undefined };
|
|
3734
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
|
+
}
|
|
3735
5064
|
ngOnInit() {
|
|
3736
5065
|
this.syncFromInputs();
|
|
3737
5066
|
}
|
|
@@ -3794,23 +5123,46 @@ class RuleCMSWidgetComponent {
|
|
|
3794
5123
|
componentProps: this.componentProps,
|
|
3795
5124
|
displayItemList: this.preparedData.displayItemList,
|
|
3796
5125
|
widgetCollections: this.preparedData.widgetCollections,
|
|
3797
|
-
publishedKey: this.
|
|
5126
|
+
publishedKey: this.renderPublishedKey,
|
|
3798
5127
|
});
|
|
3799
5128
|
}
|
|
3800
5129
|
fetchClient() {
|
|
3801
5130
|
const token = this.token ?? this.context?.token;
|
|
3802
5131
|
const endpoint = this.endpoint ?? this.context?.endpoint;
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
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
|
+
}
|
|
3809
5149
|
this.preparedData = null;
|
|
5150
|
+
this.loading = false;
|
|
3810
5151
|
return;
|
|
3811
5152
|
}
|
|
3812
|
-
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
|
+
});
|
|
3813
5164
|
if (this.lastFetchKey === fetchKey && this.preparedData) {
|
|
5165
|
+
this.loading = false;
|
|
3814
5166
|
this.resolveLibraries();
|
|
3815
5167
|
return;
|
|
3816
5168
|
}
|
|
@@ -3820,31 +5172,91 @@ class RuleCMSWidgetComponent {
|
|
|
3820
5172
|
this.lastFetchKey = fetchKey;
|
|
3821
5173
|
this.loading = true;
|
|
3822
5174
|
this.error = null;
|
|
3823
|
-
const
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
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;
|
|
3838
5208
|
}
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
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;
|
|
3842
5225
|
}
|
|
5226
|
+
if (this.fallbackPublishedKey) {
|
|
5227
|
+
return { raw: await getPublishedWidget(this.fallbackPublishedKey), selection: null };
|
|
5228
|
+
}
|
|
5229
|
+
throw err;
|
|
3843
5230
|
}
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
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);
|
|
3848
5260
|
}
|
|
3849
5261
|
})
|
|
3850
5262
|
.catch((err) => {
|
|
@@ -3852,11 +5264,14 @@ class RuleCMSWidgetComponent {
|
|
|
3852
5264
|
return;
|
|
3853
5265
|
}
|
|
3854
5266
|
console.error('Error fetching widget:', err);
|
|
3855
|
-
this.error = 'Failed to fetch widget';
|
|
5267
|
+
this.error = err instanceof FetchWidgetMessage ? err.message : 'Failed to fetch widget';
|
|
3856
5268
|
this.preparedData = null;
|
|
5269
|
+
this.selection = null;
|
|
3857
5270
|
})
|
|
3858
5271
|
.finally(() => {
|
|
3859
|
-
this.
|
|
5272
|
+
if (this.fetchGeneration === requestId) {
|
|
5273
|
+
this.loading = false;
|
|
5274
|
+
}
|
|
3860
5275
|
});
|
|
3861
5276
|
}
|
|
3862
5277
|
ensureSpinnerStyles() {
|
|
@@ -3873,15 +5288,40 @@ class RuleCMSWidgetComponent {
|
|
|
3873
5288
|
this.stylesInjected = true;
|
|
3874
5289
|
}
|
|
3875
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 }); }
|
|
3876
|
-
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: `
|
|
3877
|
-
<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">
|
|
5293
|
+
<rulecms-project-css-fonts-stylesheet
|
|
5294
|
+
[publishedKey]="renderPublishedKey"
|
|
5295
|
+
[fonts]="preparedData?.fontFaces"
|
|
5296
|
+
/>
|
|
5297
|
+
<rulecms-project-css-keyframes-stylesheet
|
|
5298
|
+
[publishedKey]="renderPublishedKey"
|
|
5299
|
+
[keyframes]="preparedData?.keyframes"
|
|
5300
|
+
/>
|
|
5301
|
+
<rulecms-project-css-themes-stylesheet
|
|
5302
|
+
[publishedKey]="renderPublishedKey"
|
|
5303
|
+
[themes]="preparedData?.themes"
|
|
5304
|
+
/>
|
|
5305
|
+
<rulecms-project-css-properties-stylesheet
|
|
5306
|
+
[publishedKey]="renderPublishedKey"
|
|
5307
|
+
[cssProperties]="preparedData?.cssProperties"
|
|
5308
|
+
/>
|
|
5309
|
+
<rulecms-project-css-widget-chrome-stylesheet
|
|
5310
|
+
[publishedKey]="renderPublishedKey"
|
|
5311
|
+
[widgetChrome]="preparedData?.widgetChrome"
|
|
5312
|
+
/>
|
|
5313
|
+
<rulecms-project-css-position-try-stylesheet
|
|
5314
|
+
[publishedKey]="renderPublishedKey"
|
|
5315
|
+
[positionTry]="preparedData?.positionTry"
|
|
5316
|
+
/>
|
|
3878
5317
|
<rulecms-project-css-variables-stylesheet
|
|
3879
|
-
[publishedKey]="
|
|
5318
|
+
[publishedKey]="renderPublishedKey"
|
|
3880
5319
|
[variables]="preparedData?.cssVariables"
|
|
3881
5320
|
/>
|
|
3882
5321
|
<rulecms-project-css-classes-stylesheet
|
|
3883
|
-
[publishedKey]="
|
|
5322
|
+
[publishedKey]="renderPublishedKey"
|
|
3884
5323
|
[classes]="preparedData?.classDefinitions"
|
|
5324
|
+
[classLayer]="preparedData?.classLayer"
|
|
3885
5325
|
/>
|
|
3886
5326
|
@if (mode !== 'pre-fetched' && loading) {
|
|
3887
5327
|
<div [ngStyle]="loadingContainerStyle">
|
|
@@ -3907,6 +5347,7 @@ class RuleCMSWidgetComponent {
|
|
|
3907
5347
|
[plugins]="plugins"
|
|
3908
5348
|
[componentProps]="componentProps"
|
|
3909
5349
|
[mounts]="mounts"
|
|
5350
|
+
[placeholderValues]="placeholderValues"
|
|
3910
5351
|
/>
|
|
3911
5352
|
} @else {
|
|
3912
5353
|
<rulecms-render-components
|
|
@@ -3919,11 +5360,12 @@ class RuleCMSWidgetComponent {
|
|
|
3919
5360
|
[plugins]="plugins"
|
|
3920
5361
|
[componentProps]="componentProps"
|
|
3921
5362
|
[mounts]="mounts"
|
|
5363
|
+
[placeholderValues]="placeholderValues"
|
|
3922
5364
|
/>
|
|
3923
5365
|
}
|
|
3924
5366
|
}
|
|
3925
5367
|
</span>
|
|
3926
|
-
`, 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"] }] }); }
|
|
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"] }] }); }
|
|
3927
5369
|
}
|
|
3928
5370
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: RuleCMSWidgetComponent, decorators: [{
|
|
3929
5371
|
type: Component,
|
|
@@ -3936,16 +5378,47 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3936
5378
|
RenderComponentsComponent,
|
|
3937
5379
|
ProjectCssVariablesStylesheetComponent,
|
|
3938
5380
|
ProjectCssClassesStylesheetComponent,
|
|
5381
|
+
ProjectCssFontsStylesheetComponent,
|
|
5382
|
+
ProjectCssKeyframesStylesheetComponent,
|
|
5383
|
+
ProjectCssThemesStylesheetComponent,
|
|
5384
|
+
ProjectCssPropertiesStylesheetComponent,
|
|
5385
|
+
ProjectCssWidgetChromeStylesheetComponent,
|
|
5386
|
+
ProjectCssPositionTryStylesheetComponent,
|
|
3939
5387
|
],
|
|
3940
5388
|
template: `
|
|
3941
|
-
<span [attr.data-rulecms-published-key]="
|
|
5389
|
+
<span [attr.data-rulecms-published-key]="renderPublishedKey" style="display: contents">
|
|
5390
|
+
<rulecms-project-css-fonts-stylesheet
|
|
5391
|
+
[publishedKey]="renderPublishedKey"
|
|
5392
|
+
[fonts]="preparedData?.fontFaces"
|
|
5393
|
+
/>
|
|
5394
|
+
<rulecms-project-css-keyframes-stylesheet
|
|
5395
|
+
[publishedKey]="renderPublishedKey"
|
|
5396
|
+
[keyframes]="preparedData?.keyframes"
|
|
5397
|
+
/>
|
|
5398
|
+
<rulecms-project-css-themes-stylesheet
|
|
5399
|
+
[publishedKey]="renderPublishedKey"
|
|
5400
|
+
[themes]="preparedData?.themes"
|
|
5401
|
+
/>
|
|
5402
|
+
<rulecms-project-css-properties-stylesheet
|
|
5403
|
+
[publishedKey]="renderPublishedKey"
|
|
5404
|
+
[cssProperties]="preparedData?.cssProperties"
|
|
5405
|
+
/>
|
|
5406
|
+
<rulecms-project-css-widget-chrome-stylesheet
|
|
5407
|
+
[publishedKey]="renderPublishedKey"
|
|
5408
|
+
[widgetChrome]="preparedData?.widgetChrome"
|
|
5409
|
+
/>
|
|
5410
|
+
<rulecms-project-css-position-try-stylesheet
|
|
5411
|
+
[publishedKey]="renderPublishedKey"
|
|
5412
|
+
[positionTry]="preparedData?.positionTry"
|
|
5413
|
+
/>
|
|
3942
5414
|
<rulecms-project-css-variables-stylesheet
|
|
3943
|
-
[publishedKey]="
|
|
5415
|
+
[publishedKey]="renderPublishedKey"
|
|
3944
5416
|
[variables]="preparedData?.cssVariables"
|
|
3945
5417
|
/>
|
|
3946
5418
|
<rulecms-project-css-classes-stylesheet
|
|
3947
|
-
[publishedKey]="
|
|
5419
|
+
[publishedKey]="renderPublishedKey"
|
|
3948
5420
|
[classes]="preparedData?.classDefinitions"
|
|
5421
|
+
[classLayer]="preparedData?.classLayer"
|
|
3949
5422
|
/>
|
|
3950
5423
|
@if (mode !== 'pre-fetched' && loading) {
|
|
3951
5424
|
<div [ngStyle]="loadingContainerStyle">
|
|
@@ -3971,6 +5444,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3971
5444
|
[plugins]="plugins"
|
|
3972
5445
|
[componentProps]="componentProps"
|
|
3973
5446
|
[mounts]="mounts"
|
|
5447
|
+
[placeholderValues]="placeholderValues"
|
|
3974
5448
|
/>
|
|
3975
5449
|
} @else {
|
|
3976
5450
|
<rulecms-render-components
|
|
@@ -3983,6 +5457,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3983
5457
|
[plugins]="plugins"
|
|
3984
5458
|
[componentProps]="componentProps"
|
|
3985
5459
|
[mounts]="mounts"
|
|
5460
|
+
[placeholderValues]="placeholderValues"
|
|
3986
5461
|
/>
|
|
3987
5462
|
}
|
|
3988
5463
|
}
|
|
@@ -3998,8 +5473,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
3998
5473
|
type: Inject,
|
|
3999
5474
|
args: [ErrorHandler]
|
|
4000
5475
|
}] }], propDecorators: { publishedKey: [{
|
|
4001
|
-
type: Input
|
|
4002
|
-
|
|
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
|
|
4003
5487
|
}], token: [{
|
|
4004
5488
|
type: Input
|
|
4005
5489
|
}], endpoint: [{
|
|
@@ -4014,8 +5498,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
4014
5498
|
type: Input
|
|
4015
5499
|
}], mounts: [{
|
|
4016
5500
|
type: Input
|
|
5501
|
+
}], placeholderValues: [{
|
|
5502
|
+
type: Input
|
|
5503
|
+
}], selectionChange: [{
|
|
5504
|
+
type: Output
|
|
4017
5505
|
}] } });
|
|
5506
|
+
class FetchWidgetMessage extends Error {
|
|
5507
|
+
constructor(message) {
|
|
5508
|
+
super(message);
|
|
5509
|
+
this.name = 'FetchWidgetMessage';
|
|
5510
|
+
}
|
|
5511
|
+
}
|
|
4018
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;
|
|
4019
5519
|
class FetchRuleCMSWidgetError extends Error {
|
|
4020
5520
|
constructor(message, status) {
|
|
4021
5521
|
super(message);
|
|
@@ -4023,31 +5523,124 @@ class FetchRuleCMSWidgetError extends Error {
|
|
|
4023
5523
|
this.status = status;
|
|
4024
5524
|
}
|
|
4025
5525
|
}
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
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;
|
|
4031
5539
|
}
|
|
4032
|
-
if (
|
|
4033
|
-
|
|
5540
|
+
if (entry.expiresAt <= now) {
|
|
5541
|
+
publishedWidgetCache.delete(url);
|
|
5542
|
+
return undefined;
|
|
4034
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, }) {
|
|
4035
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
|
+
}
|
|
4036
5560
|
const response = await fetch(url, {
|
|
4037
5561
|
method: 'GET',
|
|
4038
|
-
|
|
4039
|
-
...(isDevClientToken(token) ? { cache: 'no-store' } : {}),
|
|
5562
|
+
...(dev ? { cache: 'no-store' } : {}),
|
|
4040
5563
|
...fetchOptions,
|
|
4041
5564
|
});
|
|
4042
5565
|
if (!response.ok) {
|
|
4043
|
-
|
|
4044
|
-
throw new FetchRuleCMSWidgetError(errorData.error || `Request failed with status ${response.status}`, response.status);
|
|
5566
|
+
throw new FetchRuleCMSWidgetError(await readErrorMessage(response), response.status);
|
|
4045
5567
|
}
|
|
4046
5568
|
const data = await response.json();
|
|
4047
5569
|
if (!data.success) {
|
|
4048
5570
|
throw new FetchRuleCMSWidgetError('Failed to fetch widget data');
|
|
4049
5571
|
}
|
|
4050
|
-
|
|
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);
|
|
4051
5644
|
}
|
|
4052
5645
|
|
|
4053
5646
|
/**
|
|
@@ -4072,5 +5665,5 @@ async function resolveWidgetLibraries(params) {
|
|
|
4072
5665
|
* Generated bundle index. Do not edit.
|
|
4073
5666
|
*/
|
|
4074
5667
|
|
|
4075
|
-
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 };
|
|
4076
5669
|
//# sourceMappingURL=rulecms-widget-angular.mjs.map
|