@funnelsgrove/runtime 0.7.29 → 0.7.31

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.
@@ -33,12 +33,7 @@ function ActiveFunnelRuntimeConfigBoundary({ funnelId, funnelVersionId, children
33
33
  error: null,
34
34
  });
35
35
  useEffect(() => {
36
- // The server snapshot cannot see the browser query string, so a preview
37
- // frame can briefly mount this active boundary during hydration. Avoid a
38
- // same-origin config request before the parent switches to disabled mode.
39
- if (isPreviewFrameRuntime()) {
40
- return undefined;
41
- }
36
+ const isPreviewFrame = isPreviewFrameRuntime();
42
37
  let active = true;
43
38
  let refreshTimer = null;
44
39
  const refresh = () => loadFunnelRuntimeConfig(funnelId, { versionId: funnelVersionId })
@@ -64,7 +59,10 @@ function ActiveFunnelRuntimeConfigBoundary({ funnelId, funnelVersionId, children
64
59
  : { status: 'fallback', config: null, error: toError(error) }));
65
60
  });
66
61
  void refresh().then(() => {
67
- if (active) {
62
+ // Embedded previews are immutable for the lifetime of their iframe. They
63
+ // need the published config once, but must not multiply polling traffic
64
+ // by the number of step thumbnails open in the editor.
65
+ if (active && !isPreviewFrame) {
68
66
  refreshTimer = setInterval(() => void refresh(), FUNNEL_RUNTIME_CONFIG_REFRESH_INTERVAL_MS);
69
67
  }
70
68
  });
@@ -56,10 +56,15 @@ export type GeneratedOfferSetDiscount = {
56
56
  readonly position?: number | null;
57
57
  readonly metadata?: Record<string, unknown> | null;
58
58
  };
59
+ export type GeneratedOfferSetPaymentProviderModeConfig = {
60
+ readonly provider?: 'stripe' | 'solidgate' | null;
61
+ readonly stripePublishableKey?: string | null;
62
+ };
59
63
  export type GeneratedOfferSet = {
60
64
  readonly id?: string | null;
61
65
  readonly key: string;
62
66
  readonly paymentProfileId?: string | null;
67
+ readonly paymentProviderConfigByMode?: Partial<Record<RuntimeMode, GeneratedOfferSetPaymentProviderModeConfig>> | null;
63
68
  readonly isActive?: boolean | null;
64
69
  readonly metadata?: Record<string, unknown> | null;
65
70
  readonly items: readonly GeneratedOfferSetPlanItem[];
@@ -149,8 +149,22 @@ const normalizePublishedOfferSets = (config) => {
149
149
  ? { oldPriceLabel: pickString(item, 'oldPriceLabel', 'old_price_label') }
150
150
  : {})), { isDefault: (_a = pickBoolean(item, 'isDefault', 'is_default')) !== null && _a !== void 0 ? _a : false, providerMappingsByMode: Object.assign(Object.assign({}, (testMapping ? { test: testMapping } : {})), (liveMapping ? { live: liveMapping } : {})), metadata });
151
151
  });
152
- return Object.assign(Object.assign(Object.assign(Object.assign({}, (pickString(offerSet, 'id') ? { id: pickString(offerSet, 'id') } : {})), { key }), (pickString(offerSet, 'paymentProfileId', 'payment_profile_id')
152
+ const rawPaymentProviderConfigByMode = pick(offerSet, 'paymentProviderConfigByMode', 'payment_provider_config_by_mode');
153
+ const paymentProviderConfigByMode = isRecord(rawPaymentProviderConfigByMode)
154
+ ? Object.fromEntries(['test', 'live'].flatMap((mode) => {
155
+ const rawModeConfig = rawPaymentProviderConfigByMode[mode];
156
+ if (!isRecord(rawModeConfig)) {
157
+ return [];
158
+ }
159
+ const provider = parsePaymentProvider(pick(rawModeConfig, 'provider'), `Published runtime offer set "${key}" ${mode} payment provider config`);
160
+ const stripePublishableKey = pickString(rawModeConfig, 'stripePublishableKey', 'stripe_publishable_key');
161
+ return [[mode, Object.assign(Object.assign({}, (provider ? { provider } : {})), (stripePublishableKey ? { stripePublishableKey } : {}))]];
162
+ }))
163
+ : {};
164
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (pickString(offerSet, 'id') ? { id: pickString(offerSet, 'id') } : {})), { key }), (pickString(offerSet, 'paymentProfileId', 'payment_profile_id')
153
165
  ? { paymentProfileId: pickString(offerSet, 'paymentProfileId', 'payment_profile_id') }
166
+ : {})), (Object.keys(paymentProviderConfigByMode).length > 0
167
+ ? { paymentProviderConfigByMode }
154
168
  : {})), { isActive: (_a = pickBoolean(offerSet, 'isActive', 'is_active')) !== null && _a !== void 0 ? _a : true, metadata: isRecord(offerSet.metadata) ? offerSet.metadata : {}, items });
155
169
  });
156
170
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/runtime",
3
- "version": "0.7.29",
3
+ "version": "0.7.31",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",