@ninetailed/experience.js-plugin-preview 4.0.0-beta.13 → 4.0.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.cjs +11 -7
  2. package/index.js +11 -7
  3. package/package.json +9 -8
package/index.cjs CHANGED
@@ -3048,30 +3048,34 @@ const PreviewRenderPlugin = ctx => {
3048
3048
  react.useEffect(() => {
3049
3049
  const experienceIds = Object.keys(pluginApi.experienceVariantIndexes);
3050
3050
  const experience = experiences.find(experience => {
3051
- return experienceIds.includes(experience.id);
3051
+ const hasActiveAudience = pluginApi.activeAudiences.some(activeAudienceId => {
3052
+ var _a;
3053
+ return ((_a = experience.audience) === null || _a === void 0 ? void 0 : _a.id) === activeAudienceId;
3054
+ });
3055
+ return hasActiveAudience && experienceIds.includes(experience.id);
3052
3056
  });
3053
3057
  if (!experience) {
3054
- setComponentProps({});
3058
+ setComponentProps(baseline);
3055
3059
  return;
3056
3060
  }
3057
3061
  const baselineComponent = experience.components.find(component => component.baseline.id === baseline.id);
3058
3062
  if (!baselineComponent) {
3059
- setComponentProps({});
3063
+ setComponentProps(baseline);
3060
3064
  return;
3061
3065
  }
3062
3066
  const allVariants = [baseline, ...baselineComponent.variants];
3063
3067
  const variantIndex = pluginApi.experienceVariantIndexes[experience.id];
3064
3068
  if (allVariants.length <= variantIndex) {
3065
- setComponentProps({});
3069
+ setComponentProps(baseline);
3066
3070
  return;
3067
3071
  }
3068
3072
  const variant = allVariants[variantIndex];
3069
3073
  if (!variant) {
3070
- setComponentProps({});
3074
+ setComponentProps(baseline);
3071
3075
  return;
3072
3076
  }
3073
- setComponentProps(Object.assign({}, variant));
3074
- }, [experiences, baseline, setComponentProps, pluginApi.experienceVariantIndexes]);
3077
+ setComponentProps(variant);
3078
+ }, [experiences, baseline, setComponentProps, pluginApi.experienceVariantIndexes, pluginApi.activeAudiences]);
3075
3079
  return jsxRuntime.jsx(jsxRuntime.Fragment, {
3076
3080
  children: children
3077
3081
  });
package/index.js CHANGED
@@ -3022,30 +3022,34 @@ const PreviewRenderPlugin = ctx => {
3022
3022
  useEffect(() => {
3023
3023
  const experienceIds = Object.keys(pluginApi.experienceVariantIndexes);
3024
3024
  const experience = experiences.find(experience => {
3025
- return experienceIds.includes(experience.id);
3025
+ const hasActiveAudience = pluginApi.activeAudiences.some(activeAudienceId => {
3026
+ var _a;
3027
+ return ((_a = experience.audience) === null || _a === void 0 ? void 0 : _a.id) === activeAudienceId;
3028
+ });
3029
+ return hasActiveAudience && experienceIds.includes(experience.id);
3026
3030
  });
3027
3031
  if (!experience) {
3028
- setComponentProps({});
3032
+ setComponentProps(baseline);
3029
3033
  return;
3030
3034
  }
3031
3035
  const baselineComponent = experience.components.find(component => component.baseline.id === baseline.id);
3032
3036
  if (!baselineComponent) {
3033
- setComponentProps({});
3037
+ setComponentProps(baseline);
3034
3038
  return;
3035
3039
  }
3036
3040
  const allVariants = [baseline, ...baselineComponent.variants];
3037
3041
  const variantIndex = pluginApi.experienceVariantIndexes[experience.id];
3038
3042
  if (allVariants.length <= variantIndex) {
3039
- setComponentProps({});
3043
+ setComponentProps(baseline);
3040
3044
  return;
3041
3045
  }
3042
3046
  const variant = allVariants[variantIndex];
3043
3047
  if (!variant) {
3044
- setComponentProps({});
3048
+ setComponentProps(baseline);
3045
3049
  return;
3046
3050
  }
3047
- setComponentProps(Object.assign({}, variant));
3048
- }, [experiences, baseline, setComponentProps, pluginApi.experienceVariantIndexes]);
3051
+ setComponentProps(variant);
3052
+ }, [experiences, baseline, setComponentProps, pluginApi.experienceVariantIndexes, pluginApi.activeAudiences]);
3049
3053
  return jsx(Fragment, {
3050
3054
  children: children
3051
3055
  });
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-plugin-preview",
3
- "version": "4.0.0-beta.13",
3
+ "version": "4.0.0-beta.14",
4
4
  "module": "./index.js",
5
5
  "main": "./index.cjs",
6
6
  "type": "module",
7
7
  "types": "./index.d.ts",
8
8
  "dependencies": {
9
9
  "lodash": "4.17.21",
10
- "@ninetailed/experience.js-shared": "4.0.0-beta.13",
11
- "@ninetailed/experience.js": "4.0.0-beta.13",
12
- "@ninetailed/experience.js-plugin-analytics": "4.0.0-beta.13",
13
- "@ninetailed/experience.js-utils": "4.0.0-beta.11",
14
- "@ninetailed/experience.js-react": "4.0.0-beta.13",
15
- "@ninetailed/experience.js-preview-bridge": "4.0.0-beta.13",
10
+ "@ninetailed/experience.js-shared": "4.0.0-beta.14",
11
+ "@ninetailed/experience.js": "4.0.0-beta.14",
12
+ "@ninetailed/experience.js-plugin-analytics": "4.0.0-beta.14",
13
+ "@ninetailed/experience.js-utils": "4.0.0-beta.13",
14
+ "@ninetailed/experience.js-react": "4.0.0-beta.14",
15
+ "@ninetailed/experience.js-preview-bridge": "4.0.0-beta.14",
16
16
  "react": "18.2.0",
17
- "uuid": "9.0.0"
17
+ "uuid": "9.0.0",
18
+ "ts-toolbelt": "9.6.0"
18
19
  },
19
20
  "peerDependencies": {}
20
21
  }