@fragmentsx/render-react 1.1.1 → 1.1.3

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 (35) hide show
  1. package/dist/index.cjs.js +112 -56
  2. package/dist/index.es.js +113 -57
  3. package/package.json +2 -2
  4. package/dist/components/Area/index.d.ts +0 -3
  5. package/dist/components/Area/index.d.ts.map +0 -1
  6. package/dist/components/Collection/index.d.ts +0 -7
  7. package/dist/components/Collection/index.d.ts.map +0 -1
  8. package/dist/components/Fragment/index.d.ts +0 -2
  9. package/dist/components/Fragment/index.d.ts.map +0 -1
  10. package/dist/components/Frame/index.d.ts +0 -15
  11. package/dist/components/Frame/index.d.ts.map +0 -1
  12. package/dist/components/GlobalManager/index.d.ts +0 -2
  13. package/dist/components/GlobalManager/index.d.ts.map +0 -1
  14. package/dist/components/Instance/index.d.ts +0 -18
  15. package/dist/components/Instance/index.d.ts.map +0 -1
  16. package/dist/components/Text/index.d.ts +0 -10
  17. package/dist/components/Text/index.d.ts.map +0 -1
  18. package/dist/helpers/collectStyles.d.ts +0 -3
  19. package/dist/helpers/collectStyles.d.ts.map +0 -1
  20. package/dist/helpers/hydration.d.ts +0 -3
  21. package/dist/helpers/hydration.d.ts.map +0 -1
  22. package/dist/helpers/isBrowser.d.ts +0 -2
  23. package/dist/helpers/isBrowser.d.ts.map +0 -1
  24. package/dist/helpers/loadFragmentManager.d.ts +0 -3
  25. package/dist/helpers/loadFragmentManager.d.ts.map +0 -1
  26. package/dist/hocs/reactCSRAdapter.d.ts +0 -2
  27. package/dist/hocs/reactCSRAdapter.d.ts.map +0 -1
  28. package/dist/hocs/reactSSRAdapter.d.ts +0 -3
  29. package/dist/hocs/reactSSRAdapter.d.ts.map +0 -1
  30. package/dist/index.d.ts +0 -10
  31. package/dist/index.d.ts.map +0 -1
  32. package/dist/providers/Scope.d.ts +0 -10
  33. package/dist/providers/Scope.d.ts.map +0 -1
  34. package/dist/reactAdapter.d.ts +0 -2
  35. package/dist/reactAdapter.d.ts.map +0 -1
package/dist/index.cjs.js CHANGED
@@ -392,6 +392,7 @@ const renderMode = createConstants("viewport", "parent", "fixed");
392
392
  const interactions = createConstants("click", "mouseover", "appear");
393
393
  const eventMode = createConstants("goal", "callback", "tracker");
394
394
  const scopeTypes = createConstants(
395
+ "AreaScope",
395
396
  "InstanceScope",
396
397
  "FragmentScope",
397
398
  "CollectionScope",
@@ -1282,7 +1283,8 @@ const SceneSchema = /* @__PURE__ */ object({
1282
1283
  }),
1283
1284
  visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
1284
1285
  rotate: layerField(/* @__PURE__ */ number(), { fallback: null }),
1285
- zIndex: layerField(/* @__PURE__ */ number(), { fallback: -1 })
1286
+ zIndex: layerField(/* @__PURE__ */ number(), { fallback: null }),
1287
+ classnames: layerField(/* @__PURE__ */ array(/* @__PURE__ */ number()), { fallback: [] })
1286
1288
  });
1287
1289
  const FillSchema = /* @__PURE__ */ object({
1288
1290
  fillType: layerField(/* @__PURE__ */ picklist(Object.keys(paintMode)), {
@@ -2194,6 +2196,8 @@ function isFiniteNumber(value) {
2194
2196
  }
2195
2197
  var setKey$1 = (v2) => `$${v2}`;
2196
2198
  function hashGenerator(layerKey) {
2199
+ if (!(layerKey == null ? void 0 : layerKey.length))
2200
+ return layerKey;
2197
2201
  let hash = 0;
2198
2202
  for (let i2 = 0; i2 < layerKey.length; i2++) {
2199
2203
  hash = (hash << 5) - hash + layerKey.charCodeAt(i2);
@@ -2230,7 +2234,7 @@ const useGlobalManager = (globalManager) => {
2230
2234
  setRenderTarget
2231
2235
  };
2232
2236
  };
2233
- const useFragmentManager = (fragmentId, inputGlobalManager, aa) => {
2237
+ const useFragmentManager = (fragmentId, inputGlobalManager) => {
2234
2238
  var _a;
2235
2239
  const {
2236
2240
  fragmentsGraph,
@@ -2321,7 +2325,7 @@ const cloneLayer = (manager, layer, externalProps = {}, _parent) => {
2321
2325
  _type: layerGraph._type,
2322
2326
  overrideFrom: setKey(layerKey),
2323
2327
  parent: setKey(layerParent),
2324
- ...(layerGraph == null ? void 0 : layerGraph._type) === index.nodes.Instance ? pick(layerGraph, "fragment") : {},
2328
+ ...(layerGraph == null ? void 0 : layerGraph._type) === index.nodes.Instance ? pick(layerGraph, "fragment", "props") : {},
2325
2329
  ...externalProps
2326
2330
  },
2327
2331
  true
@@ -3010,7 +3014,11 @@ const useCalcLayerBorder = (layerKey) => {
3010
3014
  const useLayerBorder = (layerKey) => {
3011
3015
  const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
3012
3016
  const [borderWidth] = useLayerValue(layerKey, "borderWidth", fragmentManager);
3013
- const [borderColor] = useLayerValue(layerKey, "borderColor", fragmentManager);
3017
+ const [, , { cssVariableValue: borderColor }] = useLayerValue(
3018
+ layerKey,
3019
+ "borderColor",
3020
+ fragmentManager
3021
+ );
3014
3022
  const calcBorder = useCalcLayerBorder(layerKey);
3015
3023
  return require$$0.useMemo(
3016
3024
  () => calcBorder(borderWidth, borderColor),
@@ -3091,12 +3099,14 @@ const useLayerStyles = (layerKey) => {
3091
3099
  );
3092
3100
  const [whiteSpace2] = useLayerValue(layerKey, "whiteSpace", fragmentManager);
3093
3101
  const textStyles = useLayerTextStyles(layerKey);
3102
+ const [overflow2] = useLayerValue(layerKey, "overflow", fragmentManager);
3094
3103
  return {
3095
3104
  // ...(props ?? {}),
3096
3105
  ...border,
3097
3106
  ...background,
3098
3107
  ...position,
3099
3108
  opacity,
3109
+ overflow: overflow2,
3100
3110
  rotate: isValue(rotate) ? `${rotate}deg` : null,
3101
3111
  "border-radius": borderRadius,
3102
3112
  "white-space": whiteSpace2,
@@ -3121,12 +3131,6 @@ const useFragmentProperties = (fragmentId) => {
3121
3131
  manager
3122
3132
  };
3123
3133
  };
3124
- const useHash = (layerKey, manager) => {
3125
- if (!layerKey || !manager) return null;
3126
- const layer = manager.resolve(layerKey);
3127
- const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
3128
- return hashGenerator(overrideFrom ?? layerKey);
3129
- };
3130
3134
  const useInstanceProps = (instanceProps) => {
3131
3135
  const isTopInstance = !(instanceProps == null ? void 0 : instanceProps.layerKey);
3132
3136
  const { manager: loadedManager } = useFragmentManager(
@@ -3160,10 +3164,32 @@ const useInstanceProps = (instanceProps) => {
3160
3164
  cssProps: getCssVariables(mergedProps)
3161
3165
  };
3162
3166
  };
3167
+ const useLayerScopes = (fragmentManager, layerKey) => {
3168
+ var _a, _b, _c, _d;
3169
+ if (!fragmentManager || !layerKey) return [];
3170
+ const layerParents = getAllParents(fragmentManager, layerKey);
3171
+ const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
3172
+ layerParents.forEach((parent) => {
3173
+ var _a2, _b2, _c2, _d2;
3174
+ const parentLink = core.keyOfEntity(parent);
3175
+ if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
3176
+ resultScopes.push((_d2 = (_c2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c2.scopes) == null ? void 0 : _d2.get(parentLink));
3177
+ }
3178
+ });
3179
+ const areaScope = (_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get("Area");
3180
+ if (areaScope) {
3181
+ resultScopes.push(areaScope);
3182
+ }
3183
+ return resultScopes;
3184
+ };
3163
3185
  const useLayerInteractions = (layerKey, options2) => {
3164
3186
  const pause = (options2 == null ? void 0 : options2.pauseInteractions) ?? false;
3165
3187
  const { manager: globalManager } = useGlobalManager();
3166
3188
  const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
3189
+ const scopes = useLayerScopes(fragmentManager, layerKey);
3190
+ const areaScope = scopes.find(
3191
+ (scope) => (scope == null ? void 0 : scope.type) === index.scopeTypes.AreaScope
3192
+ );
3167
3193
  const [interactions2] = useLayerValue(
3168
3194
  layerKey,
3169
3195
  "interactions",
@@ -3173,10 +3199,14 @@ const useLayerInteractions = (layerKey, options2) => {
3173
3199
  const fireEvent = require$$0.useCallback(
3174
3200
  (eventLink) => {
3175
3201
  var _a, _b, _c, _d;
3202
+ if (!areaScope) return null;
3176
3203
  const event = fragmentManager.resolve(eventLink);
3177
3204
  const { value: eventValue } = readVariable(eventLink);
3178
- if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.code)) {
3179
- (_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, eventValue == null ? void 0 : eventValue.code);
3205
+ if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.goalId)) {
3206
+ (_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, {
3207
+ goalId: eventValue == null ? void 0 : eventValue.goalId,
3208
+ ...pick(areaScope, "variantId", "campaignId", "areaId")
3209
+ });
3180
3210
  }
3181
3211
  if ((event == null ? void 0 : event.mode) === index.eventMode.tracker && eventValue) {
3182
3212
  (_d = (_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.trackAdPixel) == null ? void 0 : _d.call(_c, eventValue);
@@ -3185,13 +3215,13 @@ const useLayerInteractions = (layerKey, options2) => {
3185
3215
  eventValue();
3186
3216
  }
3187
3217
  },
3188
- [globalManager, fragmentManager]
3218
+ [globalManager, fragmentManager, areaScope]
3189
3219
  );
3190
3220
  require$$0.useEffect(() => {
3191
3221
  if (!pause && Array.isArray(interactions2)) {
3192
3222
  interactions2 == null ? void 0 : interactions2.filter((el) => (el == null ? void 0 : el.on) === index.interactions.appear).map((el) => el.event).forEach(fireEvent);
3193
3223
  }
3194
- }, [pause]);
3224
+ }, [pause, areaScope]);
3195
3225
  return require$$0.useMemo(() => {
3196
3226
  if (!pause && !interactions2 || !Array.isArray(interactions2)) return {};
3197
3227
  if (pause) return {};
@@ -3203,6 +3233,22 @@ const useLayerInteractions = (layerKey, options2) => {
3203
3233
  };
3204
3234
  }, [interactions2, fireEvent, pause]);
3205
3235
  };
3236
+ const useHash = (layerKey, manager) => {
3237
+ if (!layerKey || !manager) return null;
3238
+ const layer = manager.resolve(layerKey);
3239
+ const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
3240
+ return hashGenerator(overrideFrom ?? layerKey);
3241
+ };
3242
+ const useClassnames = (layerKey, manager) => {
3243
+ const hash = useHash(layerKey, manager);
3244
+ const [classnames] = useLayerValue(layerKey, "classnames", { manager });
3245
+ if (!layerKey || !manager) return null;
3246
+ let base = [hash];
3247
+ if (classnames == null ? void 0 : classnames.length) {
3248
+ base = [...base, ...classnames];
3249
+ }
3250
+ return base.join(" ");
3251
+ };
3206
3252
  const useInstance = (instanceProps) => {
3207
3253
  const { manager: parentManager } = require$$0.useContext(FragmentContext);
3208
3254
  const [instanceLayer] = y(parentManager, instanceProps.layerKey);
@@ -3214,9 +3260,12 @@ const useInstance = (instanceProps) => {
3214
3260
  const resultFragmentId = (instanceProps == null ? void 0 : instanceProps.fragmentId) ?? (instanceLayer == null ? void 0 : instanceLayer.fragment);
3215
3261
  const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(resultFragmentId);
3216
3262
  const { props, cssProps } = useInstanceProps(instanceProps);
3217
- const hash = useHash(instanceProps.layerKey, innerFragmentManager);
3263
+ const classnames = useClassnames(
3264
+ instanceProps.layerKey,
3265
+ innerFragmentManager
3266
+ );
3218
3267
  return {
3219
- hash,
3268
+ classnames,
3220
3269
  styles: styles2,
3221
3270
  events,
3222
3271
  definitions,
@@ -3312,9 +3361,11 @@ const useFragment = (fragmentId, globalManager) => {
3312
3361
  (_a = fragmentContext.manager) == null ? void 0 : _a.resolve(fragmentContext.fragmentLayerKey),
3313
3362
  (_b = fragmentContext.manager) == null ? void 0 : _b.key
3314
3363
  );
3315
- mount();
3316
3364
  }
3317
3365
  require$$0.useEffect(() => {
3366
+ if (fragmentContext.manager) {
3367
+ mount();
3368
+ }
3318
3369
  return () => {
3319
3370
  unmount();
3320
3371
  };
@@ -3359,7 +3410,7 @@ const useFrame = (layerKey, options2) => {
3359
3410
  const layer = fragmentManager.entityOfKey(layerKey);
3360
3411
  const styles2 = useLayerStyles(layerKey);
3361
3412
  const children = useLayerChildren(layerKey);
3362
- const hash = useHash(layerKey, fragmentManager);
3413
+ const classnames = useClassnames(layerKey, fragmentManager);
3363
3414
  const { addLayerStyle } = useStyleSheet(fragmentManager);
3364
3415
  const events = useLayerInteractions(layerKey, options2);
3365
3416
  const link = useLayerLink(layerKey);
@@ -3369,7 +3420,7 @@ const useFrame = (layerKey, options2) => {
3369
3420
  return {
3370
3421
  Tag: (link == null ? void 0 : link.isLink) ? (options2 == null ? void 0 : options2.FrameTag) ?? "a" : (options2 == null ? void 0 : options2.FrameTag) ?? "div",
3371
3422
  type: layer == null ? void 0 : layer._type,
3372
- hash,
3423
+ classnames,
3373
3424
  styles: {},
3374
3425
  //isBrowser ? pick(styles, "background") : {},
3375
3426
  children,
@@ -3422,14 +3473,14 @@ const useTextAttributes = (layerKey, options2) => {
3422
3473
  const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
3423
3474
  const styles2 = useLayerStyles(layerKey);
3424
3475
  const content = useTextContent(layerKey);
3425
- const hash = useHash(layerKey, fragmentManager);
3476
+ const classnames = useClassnames(layerKey, fragmentManager);
3426
3477
  const { addLayerStyle } = useStyleSheet(fragmentManager);
3427
3478
  if (collectStyle) {
3428
3479
  addLayerStyle(layerKey, styles2, fragmentManager.resolve(layerKey));
3429
3480
  }
3430
3481
  return {
3431
3482
  styles: styles2,
3432
- hash,
3483
+ classnames,
3433
3484
  content
3434
3485
  };
3435
3486
  };
@@ -3515,19 +3566,6 @@ function useInjectedStyle() {
3515
3566
  injectStyle
3516
3567
  };
3517
3568
  }
3518
- const useLayerScopes = (fragmentManager, layerKey) => {
3519
- var _a, _b;
3520
- const layerParents = getAllParents(fragmentManager, layerKey);
3521
- const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
3522
- layerParents.forEach((parent) => {
3523
- var _a2, _b2, _c, _d;
3524
- const parentLink = core.keyOfEntity(parent);
3525
- if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
3526
- resultScopes.push((_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get(parentLink));
3527
- }
3528
- });
3529
- return resultScopes;
3530
- };
3531
3569
  function cssToJsStyle(cssKey) {
3532
3570
  return cssKey.replace(/-([a-z])/g, (_2, letter) => letter.toUpperCase());
3533
3571
  }
@@ -3555,6 +3593,14 @@ const useArea = (options2) => {
3555
3593
  options2 == null ? void 0 : options2.globalManager
3556
3594
  );
3557
3595
  const [areaData, setAreaData] = require$$0.useState(queryArea(options2.areaCode));
3596
+ const { manager: fragmentManager } = useFragmentManager(
3597
+ areaData.fragmentId,
3598
+ resultGlobalManager
3599
+ );
3600
+ const resultProps = require$$0.useMemo(
3601
+ () => ({ ...(areaData == null ? void 0 : areaData.props) ?? {}, ...(options2 == null ? void 0 : options2.props) ?? [] }),
3602
+ [areaData, options2]
3603
+ );
3558
3604
  require$$0.useEffect(() => {
3559
3605
  (async () => {
3560
3606
  const response = await queryArea(options2.areaCode);
@@ -3565,6 +3611,8 @@ const useArea = (options2) => {
3565
3611
  }, []);
3566
3612
  return {
3567
3613
  ...areaData,
3614
+ fragmentManager,
3615
+ props: resultProps,
3568
3616
  globalManager: resultGlobalManager
3569
3617
  };
3570
3618
  };
@@ -3598,8 +3646,8 @@ const Text = ({
3598
3646
  collectStyle,
3599
3647
  ...restProps
3600
3648
  }) => {
3601
- const { hash, content } = useTextAttributes(layerKey, { collectStyle });
3602
- return /* @__PURE__ */ jsxRuntime.jsx(Tag, { className: hash, "data-key": layerKey, ...restProps, children: /* @__PURE__ */ jsxRuntime.jsx(
3649
+ const { classnames, content } = useTextAttributes(layerKey, { collectStyle });
3650
+ return /* @__PURE__ */ jsxRuntime.jsx(Tag, { className: classnames, "data-key": layerKey, ...restProps, children: /* @__PURE__ */ jsxRuntime.jsx(
3603
3651
  "div",
3604
3652
  {
3605
3653
  className: styles.text,
@@ -3629,7 +3677,7 @@ const Collection = ({
3629
3677
  fragmentManager,
3630
3678
  styles: styles2,
3631
3679
  sourceDefinition,
3632
- hash,
3680
+ classnames,
3633
3681
  source,
3634
3682
  children,
3635
3683
  sourceValue
@@ -3650,7 +3698,7 @@ const Collection = ({
3650
3698
  children: /* @__PURE__ */ jsxRuntime.jsx(
3651
3699
  FrameTag,
3652
3700
  {
3653
- className: hash,
3701
+ className: classnames,
3654
3702
  "data-key": layerKey,
3655
3703
  style: resultStyles,
3656
3704
  ...restProps,
@@ -3688,16 +3736,13 @@ const Frame = ({
3688
3736
  layerKey,
3689
3737
  styles: inputStyles,
3690
3738
  hidden,
3691
- interactive,
3739
+ pauseInteractions,
3692
3740
  ...restProps
3693
3741
  }) => {
3694
- const { styles: styles2, hash, children, type, events, linkProps, Tag } = useFrame(
3695
- layerKey,
3696
- {
3697
- ...restProps,
3698
- pauseInteractions: !interactive
3699
- }
3700
- );
3742
+ const { styles: styles2, classnames, children, type, events, linkProps, Tag } = useFrame(layerKey, {
3743
+ ...restProps,
3744
+ pauseInteractions
3745
+ });
3701
3746
  const resultStyles = inputStyles ?? styles2;
3702
3747
  const isMounted = useMounted();
3703
3748
  if (isMounted && hidden) {
@@ -3719,7 +3764,7 @@ const Frame = ({
3719
3764
  return /* @__PURE__ */ jsxRuntime.jsx(
3720
3765
  Tag,
3721
3766
  {
3722
- className: hash,
3767
+ className: classnames,
3723
3768
  "data-key": layerKey,
3724
3769
  style: {
3725
3770
  ...resultStyles,
@@ -3735,7 +3780,7 @@ const Frame = ({
3735
3780
  const FragmentInternal = ({
3736
3781
  fragmentId,
3737
3782
  globalManager,
3738
- interactive,
3783
+ pauseInteractions,
3739
3784
  collectStyle,
3740
3785
  FrameElement = Frame
3741
3786
  }) => {
@@ -3767,7 +3812,7 @@ const FragmentInternal = ({
3767
3812
  FrameElement,
3768
3813
  {
3769
3814
  layerKey: childLink,
3770
- interactive,
3815
+ pauseInteractions,
3771
3816
  collectStyle,
3772
3817
  hidden: !isResize && !isPrimary && !isTopFragment,
3773
3818
  style: { display: isPrimary ? null : "none" }
@@ -3792,7 +3837,7 @@ const Fragment = (props) => {
3792
3837
  const InstanceInitial = ({
3793
3838
  Tag: inputTag,
3794
3839
  style = {},
3795
- interactive = true,
3840
+ pauseInteractions,
3796
3841
  FrameElement,
3797
3842
  ...instanceProps
3798
3843
  }) => {
@@ -3806,13 +3851,13 @@ const InstanceInitial = ({
3806
3851
  parentManager,
3807
3852
  events,
3808
3853
  props,
3809
- hash,
3854
+ classnames,
3810
3855
  innerManager,
3811
3856
  definitions,
3812
3857
  globalManager
3813
3858
  } = useInstance({
3814
3859
  ...instanceProps,
3815
- pauseInteractions: !interactive
3860
+ pauseInteractions
3816
3861
  });
3817
3862
  if (ssr) {
3818
3863
  (_c = (_b = globalManager == null ? void 0 : globalManager.$load) == null ? void 0 : _b.loadFragment) == null ? void 0 : _c.call(_b, fragmentId, { suspense: true });
@@ -3843,7 +3888,7 @@ const InstanceInitial = ({
3843
3888
  children: parentManager ? /* @__PURE__ */ jsxRuntime.jsx(
3844
3889
  Tag,
3845
3890
  {
3846
- className: hash,
3891
+ className: classnames,
3847
3892
  "data-key": instanceProps.layerKey,
3848
3893
  style: { ...style, ...cssProps },
3849
3894
  ...link.linkProps,
@@ -3854,7 +3899,7 @@ const InstanceInitial = ({
3854
3899
  fragmentId,
3855
3900
  globalManager,
3856
3901
  FrameElement,
3857
- interactive
3902
+ pauseInteractions
3858
3903
  }
3859
3904
  )
3860
3905
  }
@@ -3864,7 +3909,7 @@ const InstanceInitial = ({
3864
3909
  fragmentId,
3865
3910
  globalManager,
3866
3911
  FrameElement,
3867
- interactive
3912
+ pauseInteractions
3868
3913
  }
3869
3914
  ) })
3870
3915
  }
@@ -3887,7 +3932,18 @@ const AreaInitial = (areaProps) => {
3887
3932
  }
3888
3933
  const areaData = useArea(areaProps);
3889
3934
  if (!areaData) return null;
3890
- return /* @__PURE__ */ jsxRuntime.jsx(Instance, { fragmentId: areaData.fragmentId, props: areaData == null ? void 0 : areaData.props });
3935
+ return /* @__PURE__ */ jsxRuntime.jsx(
3936
+ Scope,
3937
+ {
3938
+ fragmentManager: areaData.fragmentManager,
3939
+ layerKey: "Area",
3940
+ value: {
3941
+ type: definition.definition.scopeTypes.AreaScope,
3942
+ ...areaData ?? {}
3943
+ },
3944
+ children: /* @__PURE__ */ jsxRuntime.jsx(Instance, { fragmentId: areaData.fragmentId, props: areaData == null ? void 0 : areaData.props })
3945
+ }
3946
+ );
3891
3947
  };
3892
3948
  const Area = (props) => {
3893
3949
  return "globalManager" in props ? /* @__PURE__ */ jsxRuntime.jsx(require$$0.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(GlobalManager, { value: props.globalManager, children: /* @__PURE__ */ jsxRuntime.jsx(AreaInitial, { ...props }) }) }) : /* @__PURE__ */ jsxRuntime.jsx(require$$0.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(AreaInitial, { ...props }) });
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import require$$0, { createContext, useState, useEffect, useContext, useRef, useCallback, useMemo, Suspense } from "react";
2
+ import require$$0, { createContext, useState, useMemo, useEffect, useContext, useRef, useCallback, Suspense } from "react";
3
3
  import { definition } from "@fragmentsx/definition";
4
4
  import { isPartialKey, keyOfEntity, entityOfKey, isLinkKey } from "@graph-state/core";
5
5
  const collectStyles = (globalManager) => {
@@ -390,6 +390,7 @@ const renderMode = createConstants("viewport", "parent", "fixed");
390
390
  const interactions = createConstants("click", "mouseover", "appear");
391
391
  const eventMode = createConstants("goal", "callback", "tracker");
392
392
  const scopeTypes = createConstants(
393
+ "AreaScope",
393
394
  "InstanceScope",
394
395
  "FragmentScope",
395
396
  "CollectionScope",
@@ -1280,7 +1281,8 @@ const SceneSchema = /* @__PURE__ */ object({
1280
1281
  }),
1281
1282
  visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
1282
1283
  rotate: layerField(/* @__PURE__ */ number(), { fallback: null }),
1283
- zIndex: layerField(/* @__PURE__ */ number(), { fallback: -1 })
1284
+ zIndex: layerField(/* @__PURE__ */ number(), { fallback: null }),
1285
+ classnames: layerField(/* @__PURE__ */ array(/* @__PURE__ */ number()), { fallback: [] })
1284
1286
  });
1285
1287
  const FillSchema = /* @__PURE__ */ object({
1286
1288
  fillType: layerField(/* @__PURE__ */ picklist(Object.keys(paintMode)), {
@@ -2192,6 +2194,8 @@ function isFiniteNumber(value) {
2192
2194
  }
2193
2195
  var setKey$1 = (v2) => `$${v2}`;
2194
2196
  function hashGenerator(layerKey) {
2197
+ if (!(layerKey == null ? void 0 : layerKey.length))
2198
+ return layerKey;
2195
2199
  let hash = 0;
2196
2200
  for (let i2 = 0; i2 < layerKey.length; i2++) {
2197
2201
  hash = (hash << 5) - hash + layerKey.charCodeAt(i2);
@@ -2228,7 +2232,7 @@ const useGlobalManager = (globalManager) => {
2228
2232
  setRenderTarget
2229
2233
  };
2230
2234
  };
2231
- const useFragmentManager = (fragmentId, inputGlobalManager, aa) => {
2235
+ const useFragmentManager = (fragmentId, inputGlobalManager) => {
2232
2236
  var _a;
2233
2237
  const {
2234
2238
  fragmentsGraph,
@@ -2319,7 +2323,7 @@ const cloneLayer = (manager, layer, externalProps = {}, _parent) => {
2319
2323
  _type: layerGraph._type,
2320
2324
  overrideFrom: setKey(layerKey),
2321
2325
  parent: setKey(layerParent),
2322
- ...(layerGraph == null ? void 0 : layerGraph._type) === index.nodes.Instance ? pick(layerGraph, "fragment") : {},
2326
+ ...(layerGraph == null ? void 0 : layerGraph._type) === index.nodes.Instance ? pick(layerGraph, "fragment", "props") : {},
2323
2327
  ...externalProps
2324
2328
  },
2325
2329
  true
@@ -3008,7 +3012,11 @@ const useCalcLayerBorder = (layerKey) => {
3008
3012
  const useLayerBorder = (layerKey) => {
3009
3013
  const { manager: fragmentManager } = useContext(FragmentContext);
3010
3014
  const [borderWidth] = useLayerValue(layerKey, "borderWidth", fragmentManager);
3011
- const [borderColor] = useLayerValue(layerKey, "borderColor", fragmentManager);
3015
+ const [, , { cssVariableValue: borderColor }] = useLayerValue(
3016
+ layerKey,
3017
+ "borderColor",
3018
+ fragmentManager
3019
+ );
3012
3020
  const calcBorder = useCalcLayerBorder(layerKey);
3013
3021
  return useMemo(
3014
3022
  () => calcBorder(borderWidth, borderColor),
@@ -3089,12 +3097,14 @@ const useLayerStyles = (layerKey) => {
3089
3097
  );
3090
3098
  const [whiteSpace2] = useLayerValue(layerKey, "whiteSpace", fragmentManager);
3091
3099
  const textStyles = useLayerTextStyles(layerKey);
3100
+ const [overflow2] = useLayerValue(layerKey, "overflow", fragmentManager);
3092
3101
  return {
3093
3102
  // ...(props ?? {}),
3094
3103
  ...border,
3095
3104
  ...background,
3096
3105
  ...position,
3097
3106
  opacity,
3107
+ overflow: overflow2,
3098
3108
  rotate: isValue(rotate) ? `${rotate}deg` : null,
3099
3109
  "border-radius": borderRadius,
3100
3110
  "white-space": whiteSpace2,
@@ -3119,12 +3129,6 @@ const useFragmentProperties = (fragmentId) => {
3119
3129
  manager
3120
3130
  };
3121
3131
  };
3122
- const useHash = (layerKey, manager) => {
3123
- if (!layerKey || !manager) return null;
3124
- const layer = manager.resolve(layerKey);
3125
- const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
3126
- return hashGenerator(overrideFrom ?? layerKey);
3127
- };
3128
3132
  const useInstanceProps = (instanceProps) => {
3129
3133
  const isTopInstance = !(instanceProps == null ? void 0 : instanceProps.layerKey);
3130
3134
  const { manager: loadedManager } = useFragmentManager(
@@ -3158,10 +3162,32 @@ const useInstanceProps = (instanceProps) => {
3158
3162
  cssProps: getCssVariables(mergedProps)
3159
3163
  };
3160
3164
  };
3165
+ const useLayerScopes = (fragmentManager, layerKey) => {
3166
+ var _a, _b, _c, _d;
3167
+ if (!fragmentManager || !layerKey) return [];
3168
+ const layerParents = getAllParents(fragmentManager, layerKey);
3169
+ const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
3170
+ layerParents.forEach((parent) => {
3171
+ var _a2, _b2, _c2, _d2;
3172
+ const parentLink = keyOfEntity(parent);
3173
+ if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
3174
+ resultScopes.push((_d2 = (_c2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c2.scopes) == null ? void 0 : _d2.get(parentLink));
3175
+ }
3176
+ });
3177
+ const areaScope = (_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get("Area");
3178
+ if (areaScope) {
3179
+ resultScopes.push(areaScope);
3180
+ }
3181
+ return resultScopes;
3182
+ };
3161
3183
  const useLayerInteractions = (layerKey, options2) => {
3162
3184
  const pause = (options2 == null ? void 0 : options2.pauseInteractions) ?? false;
3163
3185
  const { manager: globalManager } = useGlobalManager();
3164
3186
  const { manager: fragmentManager } = useContext(FragmentContext);
3187
+ const scopes = useLayerScopes(fragmentManager, layerKey);
3188
+ const areaScope = scopes.find(
3189
+ (scope) => (scope == null ? void 0 : scope.type) === index.scopeTypes.AreaScope
3190
+ );
3165
3191
  const [interactions2] = useLayerValue(
3166
3192
  layerKey,
3167
3193
  "interactions",
@@ -3171,10 +3197,14 @@ const useLayerInteractions = (layerKey, options2) => {
3171
3197
  const fireEvent = useCallback(
3172
3198
  (eventLink) => {
3173
3199
  var _a, _b, _c, _d;
3200
+ if (!areaScope) return null;
3174
3201
  const event = fragmentManager.resolve(eventLink);
3175
3202
  const { value: eventValue } = readVariable(eventLink);
3176
- if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.code)) {
3177
- (_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, eventValue == null ? void 0 : eventValue.code);
3203
+ if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.goalId)) {
3204
+ (_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, {
3205
+ goalId: eventValue == null ? void 0 : eventValue.goalId,
3206
+ ...pick(areaScope, "variantId", "campaignId", "areaId")
3207
+ });
3178
3208
  }
3179
3209
  if ((event == null ? void 0 : event.mode) === index.eventMode.tracker && eventValue) {
3180
3210
  (_d = (_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.trackAdPixel) == null ? void 0 : _d.call(_c, eventValue);
@@ -3183,13 +3213,13 @@ const useLayerInteractions = (layerKey, options2) => {
3183
3213
  eventValue();
3184
3214
  }
3185
3215
  },
3186
- [globalManager, fragmentManager]
3216
+ [globalManager, fragmentManager, areaScope]
3187
3217
  );
3188
3218
  useEffect(() => {
3189
3219
  if (!pause && Array.isArray(interactions2)) {
3190
3220
  interactions2 == null ? void 0 : interactions2.filter((el) => (el == null ? void 0 : el.on) === index.interactions.appear).map((el) => el.event).forEach(fireEvent);
3191
3221
  }
3192
- }, [pause]);
3222
+ }, [pause, areaScope]);
3193
3223
  return useMemo(() => {
3194
3224
  if (!pause && !interactions2 || !Array.isArray(interactions2)) return {};
3195
3225
  if (pause) return {};
@@ -3201,6 +3231,22 @@ const useLayerInteractions = (layerKey, options2) => {
3201
3231
  };
3202
3232
  }, [interactions2, fireEvent, pause]);
3203
3233
  };
3234
+ const useHash = (layerKey, manager) => {
3235
+ if (!layerKey || !manager) return null;
3236
+ const layer = manager.resolve(layerKey);
3237
+ const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
3238
+ return hashGenerator(overrideFrom ?? layerKey);
3239
+ };
3240
+ const useClassnames = (layerKey, manager) => {
3241
+ const hash = useHash(layerKey, manager);
3242
+ const [classnames] = useLayerValue(layerKey, "classnames", { manager });
3243
+ if (!layerKey || !manager) return null;
3244
+ let base = [hash];
3245
+ if (classnames == null ? void 0 : classnames.length) {
3246
+ base = [...base, ...classnames];
3247
+ }
3248
+ return base.join(" ");
3249
+ };
3204
3250
  const useInstance = (instanceProps) => {
3205
3251
  const { manager: parentManager } = useContext(FragmentContext);
3206
3252
  const [instanceLayer] = y(parentManager, instanceProps.layerKey);
@@ -3212,9 +3258,12 @@ const useInstance = (instanceProps) => {
3212
3258
  const resultFragmentId = (instanceProps == null ? void 0 : instanceProps.fragmentId) ?? (instanceLayer == null ? void 0 : instanceLayer.fragment);
3213
3259
  const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(resultFragmentId);
3214
3260
  const { props, cssProps } = useInstanceProps(instanceProps);
3215
- const hash = useHash(instanceProps.layerKey, innerFragmentManager);
3261
+ const classnames = useClassnames(
3262
+ instanceProps.layerKey,
3263
+ innerFragmentManager
3264
+ );
3216
3265
  return {
3217
- hash,
3266
+ classnames,
3218
3267
  styles: styles2,
3219
3268
  events,
3220
3269
  definitions,
@@ -3310,9 +3359,11 @@ const useFragment = (fragmentId, globalManager) => {
3310
3359
  (_a = fragmentContext.manager) == null ? void 0 : _a.resolve(fragmentContext.fragmentLayerKey),
3311
3360
  (_b = fragmentContext.manager) == null ? void 0 : _b.key
3312
3361
  );
3313
- mount();
3314
3362
  }
3315
3363
  useEffect(() => {
3364
+ if (fragmentContext.manager) {
3365
+ mount();
3366
+ }
3316
3367
  return () => {
3317
3368
  unmount();
3318
3369
  };
@@ -3357,7 +3408,7 @@ const useFrame = (layerKey, options2) => {
3357
3408
  const layer = fragmentManager.entityOfKey(layerKey);
3358
3409
  const styles2 = useLayerStyles(layerKey);
3359
3410
  const children = useLayerChildren(layerKey);
3360
- const hash = useHash(layerKey, fragmentManager);
3411
+ const classnames = useClassnames(layerKey, fragmentManager);
3361
3412
  const { addLayerStyle } = useStyleSheet(fragmentManager);
3362
3413
  const events = useLayerInteractions(layerKey, options2);
3363
3414
  const link = useLayerLink(layerKey);
@@ -3367,7 +3418,7 @@ const useFrame = (layerKey, options2) => {
3367
3418
  return {
3368
3419
  Tag: (link == null ? void 0 : link.isLink) ? (options2 == null ? void 0 : options2.FrameTag) ?? "a" : (options2 == null ? void 0 : options2.FrameTag) ?? "div",
3369
3420
  type: layer == null ? void 0 : layer._type,
3370
- hash,
3421
+ classnames,
3371
3422
  styles: {},
3372
3423
  //isBrowser ? pick(styles, "background") : {},
3373
3424
  children,
@@ -3420,14 +3471,14 @@ const useTextAttributes = (layerKey, options2) => {
3420
3471
  const { manager: fragmentManager } = useContext(FragmentContext);
3421
3472
  const styles2 = useLayerStyles(layerKey);
3422
3473
  const content = useTextContent(layerKey);
3423
- const hash = useHash(layerKey, fragmentManager);
3474
+ const classnames = useClassnames(layerKey, fragmentManager);
3424
3475
  const { addLayerStyle } = useStyleSheet(fragmentManager);
3425
3476
  if (collectStyle) {
3426
3477
  addLayerStyle(layerKey, styles2, fragmentManager.resolve(layerKey));
3427
3478
  }
3428
3479
  return {
3429
3480
  styles: styles2,
3430
- hash,
3481
+ classnames,
3431
3482
  content
3432
3483
  };
3433
3484
  };
@@ -3513,19 +3564,6 @@ function useInjectedStyle() {
3513
3564
  injectStyle
3514
3565
  };
3515
3566
  }
3516
- const useLayerScopes = (fragmentManager, layerKey) => {
3517
- var _a, _b;
3518
- const layerParents = getAllParents(fragmentManager, layerKey);
3519
- const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
3520
- layerParents.forEach((parent) => {
3521
- var _a2, _b2, _c, _d;
3522
- const parentLink = keyOfEntity(parent);
3523
- if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
3524
- resultScopes.push((_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get(parentLink));
3525
- }
3526
- });
3527
- return resultScopes;
3528
- };
3529
3567
  function cssToJsStyle(cssKey) {
3530
3568
  return cssKey.replace(/-([a-z])/g, (_2, letter) => letter.toUpperCase());
3531
3569
  }
@@ -3553,6 +3591,14 @@ const useArea = (options2) => {
3553
3591
  options2 == null ? void 0 : options2.globalManager
3554
3592
  );
3555
3593
  const [areaData, setAreaData] = useState(queryArea(options2.areaCode));
3594
+ const { manager: fragmentManager } = useFragmentManager(
3595
+ areaData.fragmentId,
3596
+ resultGlobalManager
3597
+ );
3598
+ const resultProps = useMemo(
3599
+ () => ({ ...(areaData == null ? void 0 : areaData.props) ?? {}, ...(options2 == null ? void 0 : options2.props) ?? [] }),
3600
+ [areaData, options2]
3601
+ );
3556
3602
  useEffect(() => {
3557
3603
  (async () => {
3558
3604
  const response = await queryArea(options2.areaCode);
@@ -3563,6 +3609,8 @@ const useArea = (options2) => {
3563
3609
  }, []);
3564
3610
  return {
3565
3611
  ...areaData,
3612
+ fragmentManager,
3613
+ props: resultProps,
3566
3614
  globalManager: resultGlobalManager
3567
3615
  };
3568
3616
  };
@@ -3596,8 +3644,8 @@ const Text = ({
3596
3644
  collectStyle,
3597
3645
  ...restProps
3598
3646
  }) => {
3599
- const { hash, content } = useTextAttributes(layerKey, { collectStyle });
3600
- return /* @__PURE__ */ jsx(Tag, { className: hash, "data-key": layerKey, ...restProps, children: /* @__PURE__ */ jsx(
3647
+ const { classnames, content } = useTextAttributes(layerKey, { collectStyle });
3648
+ return /* @__PURE__ */ jsx(Tag, { className: classnames, "data-key": layerKey, ...restProps, children: /* @__PURE__ */ jsx(
3601
3649
  "div",
3602
3650
  {
3603
3651
  className: styles.text,
@@ -3627,7 +3675,7 @@ const Collection = ({
3627
3675
  fragmentManager,
3628
3676
  styles: styles2,
3629
3677
  sourceDefinition,
3630
- hash,
3678
+ classnames,
3631
3679
  source,
3632
3680
  children,
3633
3681
  sourceValue
@@ -3648,7 +3696,7 @@ const Collection = ({
3648
3696
  children: /* @__PURE__ */ jsx(
3649
3697
  FrameTag,
3650
3698
  {
3651
- className: hash,
3699
+ className: classnames,
3652
3700
  "data-key": layerKey,
3653
3701
  style: resultStyles,
3654
3702
  ...restProps,
@@ -3686,16 +3734,13 @@ const Frame = ({
3686
3734
  layerKey,
3687
3735
  styles: inputStyles,
3688
3736
  hidden,
3689
- interactive,
3737
+ pauseInteractions,
3690
3738
  ...restProps
3691
3739
  }) => {
3692
- const { styles: styles2, hash, children, type, events, linkProps, Tag } = useFrame(
3693
- layerKey,
3694
- {
3695
- ...restProps,
3696
- pauseInteractions: !interactive
3697
- }
3698
- );
3740
+ const { styles: styles2, classnames, children, type, events, linkProps, Tag } = useFrame(layerKey, {
3741
+ ...restProps,
3742
+ pauseInteractions
3743
+ });
3699
3744
  const resultStyles = inputStyles ?? styles2;
3700
3745
  const isMounted = useMounted();
3701
3746
  if (isMounted && hidden) {
@@ -3717,7 +3762,7 @@ const Frame = ({
3717
3762
  return /* @__PURE__ */ jsx(
3718
3763
  Tag,
3719
3764
  {
3720
- className: hash,
3765
+ className: classnames,
3721
3766
  "data-key": layerKey,
3722
3767
  style: {
3723
3768
  ...resultStyles,
@@ -3733,7 +3778,7 @@ const Frame = ({
3733
3778
  const FragmentInternal = ({
3734
3779
  fragmentId,
3735
3780
  globalManager,
3736
- interactive,
3781
+ pauseInteractions,
3737
3782
  collectStyle,
3738
3783
  FrameElement = Frame
3739
3784
  }) => {
@@ -3765,7 +3810,7 @@ const FragmentInternal = ({
3765
3810
  FrameElement,
3766
3811
  {
3767
3812
  layerKey: childLink,
3768
- interactive,
3813
+ pauseInteractions,
3769
3814
  collectStyle,
3770
3815
  hidden: !isResize && !isPrimary && !isTopFragment,
3771
3816
  style: { display: isPrimary ? null : "none" }
@@ -3790,7 +3835,7 @@ const Fragment = (props) => {
3790
3835
  const InstanceInitial = ({
3791
3836
  Tag: inputTag,
3792
3837
  style = {},
3793
- interactive = true,
3838
+ pauseInteractions,
3794
3839
  FrameElement,
3795
3840
  ...instanceProps
3796
3841
  }) => {
@@ -3804,13 +3849,13 @@ const InstanceInitial = ({
3804
3849
  parentManager,
3805
3850
  events,
3806
3851
  props,
3807
- hash,
3852
+ classnames,
3808
3853
  innerManager,
3809
3854
  definitions,
3810
3855
  globalManager
3811
3856
  } = useInstance({
3812
3857
  ...instanceProps,
3813
- pauseInteractions: !interactive
3858
+ pauseInteractions
3814
3859
  });
3815
3860
  if (ssr) {
3816
3861
  (_c = (_b = globalManager == null ? void 0 : globalManager.$load) == null ? void 0 : _b.loadFragment) == null ? void 0 : _c.call(_b, fragmentId, { suspense: true });
@@ -3841,7 +3886,7 @@ const InstanceInitial = ({
3841
3886
  children: parentManager ? /* @__PURE__ */ jsx(
3842
3887
  Tag,
3843
3888
  {
3844
- className: hash,
3889
+ className: classnames,
3845
3890
  "data-key": instanceProps.layerKey,
3846
3891
  style: { ...style, ...cssProps },
3847
3892
  ...link.linkProps,
@@ -3852,7 +3897,7 @@ const InstanceInitial = ({
3852
3897
  fragmentId,
3853
3898
  globalManager,
3854
3899
  FrameElement,
3855
- interactive
3900
+ pauseInteractions
3856
3901
  }
3857
3902
  )
3858
3903
  }
@@ -3862,7 +3907,7 @@ const InstanceInitial = ({
3862
3907
  fragmentId,
3863
3908
  globalManager,
3864
3909
  FrameElement,
3865
- interactive
3910
+ pauseInteractions
3866
3911
  }
3867
3912
  ) })
3868
3913
  }
@@ -3885,7 +3930,18 @@ const AreaInitial = (areaProps) => {
3885
3930
  }
3886
3931
  const areaData = useArea(areaProps);
3887
3932
  if (!areaData) return null;
3888
- return /* @__PURE__ */ jsx(Instance, { fragmentId: areaData.fragmentId, props: areaData == null ? void 0 : areaData.props });
3933
+ return /* @__PURE__ */ jsx(
3934
+ Scope,
3935
+ {
3936
+ fragmentManager: areaData.fragmentManager,
3937
+ layerKey: "Area",
3938
+ value: {
3939
+ type: definition.scopeTypes.AreaScope,
3940
+ ...areaData ?? {}
3941
+ },
3942
+ children: /* @__PURE__ */ jsx(Instance, { fragmentId: areaData.fragmentId, props: areaData == null ? void 0 : areaData.props })
3943
+ }
3944
+ );
3889
3945
  };
3890
3946
  const Area = (props) => {
3891
3947
  return "globalManager" in props ? /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(GlobalManager, { value: props.globalManager, children: /* @__PURE__ */ jsx(AreaInitial, { ...props }) }) }) : /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(AreaInitial, { ...props }) });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fragmentsx/render-react",
3
3
  "private": false,
4
- "version": "1.1.1",
4
+ "version": "1.1.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -38,7 +38,7 @@
38
38
  "vite": "^6.1.0",
39
39
  "vite-plugin-css-injected-by-js": "^3.5.2",
40
40
  "vite-plugin-dts": "^4.5.0",
41
- "@fragmentsx/render-core": "0.1.0"
41
+ "@fragmentsx/render-core": "0.1.1"
42
42
  },
43
43
  "scripts": {
44
44
  "clear": "rm -r -f ./dist",
@@ -1,3 +0,0 @@
1
- import { AreaProps } from '@fragmentsx/render-core';
2
- export declare const Area: (props: AreaProps) => import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Area/index.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EAIV,MAAM,yBAAyB,CAAC;AA6BjC,eAAO,MAAM,IAAI,UAAW,SAAS,4CAYpC,CAAC"}
@@ -1,7 +0,0 @@
1
- import { FrameProps } from '../Frame';
2
- import { FC } from 'react';
3
- interface CollectionProps extends FrameProps {
4
- }
5
- export declare const Collection: FC<CollectionProps>;
6
- export {};
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Collection/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAS,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAe,EAAE,EAAE,MAAM,OAAO,CAAC;AAGxC,UAAU,eAAgB,SAAQ,UAAU;CAAG;AAE/C,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA+D1C,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const Fragment: (props: any) => import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Fragment/index.tsx"],"names":[],"mappings":"AAgFA,eAAO,MAAM,QAAQ,yDAuBpB,CAAC"}
@@ -1,15 +0,0 @@
1
- import { ElementType, FC } from 'react';
2
- import { LinkKey } from '@graph-state/core';
3
- import { UseFrameOptions } from '@fragmentsx/render-core/dist/components/Frame/hooks/useFrame';
4
- export interface FrameProps extends UseFrameOptions {
5
- TextElement?: ElementType;
6
- InstanceElement?: ElementType;
7
- FrameElement?: ElementType;
8
- CollectionElement?: ElementType;
9
- styles?: boolean;
10
- hidden?: boolean;
11
- interactive?: boolean;
12
- layerKey: LinkKey;
13
- }
14
- export declare const Frame: FC<FrameProps>;
15
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Frame/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,EAAE,EAAyB,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAK5C,OAAO,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAC;AAG/F,MAAM,WAAW,UAAW,SAAQ,eAAe;IACjD,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,eAAe,CAAC,EAAE,WAAW,CAAC;IAC9B,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,iBAAiB,CAAC,EAAE,WAAW,CAAC;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,CAwDhC,CAAC"}
@@ -1,2 +0,0 @@
1
- export { GlobalManager } from '@fragmentsx/render-core';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/GlobalManager/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC"}
@@ -1,18 +0,0 @@
1
- import { ComponentPropsWithoutRef, ElementType } from 'react';
2
- import { LinkKey } from '@graph-state/core';
3
- interface InstanceOptions {
4
- ssr?: boolean;
5
- }
6
- export interface InstanceProps extends ComponentPropsWithoutRef<"div"> {
7
- FrameElement?: ElementType;
8
- layerKey?: LinkKey;
9
- fragmentId?: string;
10
- interactive?: boolean;
11
- props?: Record<string, unknown>;
12
- options?: InstanceOptions;
13
- globalManager?: unknown;
14
- Tag?: string | ElementType;
15
- }
16
- export declare const Instance: (props: any) => import("react/jsx-runtime").JSX.Element;
17
- export {};
18
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Instance/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAgB,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAW5C,UAAU,eAAe;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,aAAc,SAAQ,wBAAwB,CAAC,KAAK,CAAC;IACpE,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;CAC5B;AAoFD,eAAO,MAAM,QAAQ,yDAYpB,CAAC"}
@@ -1,10 +0,0 @@
1
- import { LinkKey } from '@graph-state/core';
2
- import { ComponentPropsWithoutRef, ElementType, FC } from 'react';
3
- import { UseTextAttributes } from '@fragmentsx/render-core/dist/components/Text/hooks/useTextAttributes';
4
- interface TextProps extends ComponentPropsWithoutRef<"div">, UseTextAttributes {
5
- Tag?: string | ElementType;
6
- layerKey: LinkKey;
7
- }
8
- export declare const Text: FC<TextProps>;
9
- export {};
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Text/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAGlE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sEAAsE,CAAC;AAEzG,UAAU,SAAU,SAAQ,wBAAwB,CAAC,KAAK,CAAC,EAAE,iBAAiB;IAC5E,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAgB9B,CAAC"}
@@ -1,3 +0,0 @@
1
- import { GraphState } from '@graph-state/core';
2
- export declare const collectStyles: (globalManager: GraphState) => import("react/jsx-runtime").JSX.Element[] | null;
3
- //# sourceMappingURL=collectStyles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"collectStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/collectStyles.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C,eAAO,MAAM,aAAa,kBAAmB,UAAU,qDA4CtD,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare function serializeData(data: any): string;
2
- export declare function getHydratedData(id: string): any;
3
- //# sourceMappingURL=hydration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hydration.d.ts","sourceRoot":"","sources":["../../src/helpers/hydration.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,IAAI,EAAE,GAAG,UAGtC;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,OAYzC"}
@@ -1,2 +0,0 @@
1
- export declare const isBrowser: boolean;
2
- //# sourceMappingURL=isBrowser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isBrowser.d.ts","sourceRoot":"","sources":["../../src/helpers/isBrowser.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,SAAgC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { GraphState } from '@graph-state/core';
2
- export declare const loadFragmentManager: (globalManager: GraphState, fragmentId: number) => Promise<any>;
3
- //# sourceMappingURL=loadFragmentManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadFragmentManager.d.ts","sourceRoot":"","sources":["../../src/helpers/loadFragmentManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,eAAO,MAAM,mBAAmB,kBACf,UAAU,cACb,MAAM,iBAmBnB,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function reactCSRAdapter(PreactComponent: any): (props: any) => import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=reactCSRAdapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactCSRAdapter.d.ts","sourceRoot":"","sources":["../../src/hocs/reactCSRAdapter.tsx"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,CAAC,eAAe,EAAE,GAAG,WACX,GAAG,6CAgD3C"}
@@ -1,3 +0,0 @@
1
- export declare function createResource(resourceCache: any, key: string, fetcher: () => Promise<any>): any;
2
- export declare function reactSSRAdapter(PreactComponent: any): (props: any) => import("react/jsx-runtime").JSX.Element;
3
- //# sourceMappingURL=reactSSRAdapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactSSRAdapter.d.ts","sourceRoot":"","sources":["../../src/hocs/reactSSRAdapter.tsx"],"names":[],"mappings":"AAKA,wBAAgB,cAAc,CAC5B,aAAa,KAAA,EACb,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,OA2B5B;AAED,wBAAgB,eAAe,CAAC,eAAe,EAAE,GAAG,WACF,GAAG,6CA4BpD"}
package/dist/index.d.ts DELETED
@@ -1,10 +0,0 @@
1
- export { collectStyles } from './helpers/collectStyles';
2
- export { Instance } from './components/Instance';
3
- export { Area } from './components/Area';
4
- export { Text } from './components/Text';
5
- export { Frame } from './components/Frame';
6
- export { Fragment } from './components/Fragment';
7
- export { Collection } from './components/Collection';
8
- export { Scope } from './providers/Scope';
9
- export * from '@fragmentsx/render-core';
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,cAAc,yBAAyB,CAAC"}
@@ -1,10 +0,0 @@
1
- import { FC, PropsWithChildren } from 'react';
2
- import { GraphState, LinkKey } from '@graph-state/core';
3
- interface ScopeProps extends PropsWithChildren {
4
- fragmentManager: GraphState;
5
- layerKey: LinkKey;
6
- value: unknown;
7
- }
8
- export declare const Scope: FC<ScopeProps>;
9
- export {};
10
- //# sourceMappingURL=Scope.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Scope.d.ts","sourceRoot":"","sources":["../../src/providers/Scope.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAExD,UAAU,UAAW,SAAQ,iBAAiB;IAC5C,eAAe,EAAE,UAAU,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,eAAO,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,CAchC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function createReactComponent(PreactComponent: any): (props: any) => import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=reactAdapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactAdapter.d.ts","sourceRoot":"","sources":["../src/reactAdapter.ts"],"names":[],"mappings":"AAKA,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,GAAG,2DAMxD"}