@appfunnel-dev/sdk 2.0.0-canary.2 → 2.0.0-canary.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 (37) hide show
  1. package/dist/{checkout-DiQvRT5q.d.ts → checkout-7Dy6IedP.d.ts} +3 -0
  2. package/dist/{checkout-CZmEvWfC.d.cts → checkout-Dz8cGkB_.d.cts} +3 -0
  3. package/dist/{chunk-7UC5VXOR.js → chunk-AKO6XKXP.js} +28 -8
  4. package/dist/chunk-AKO6XKXP.js.map +1 -0
  5. package/dist/{chunk-VQOD2Z6Q.cjs → chunk-CY4VBSMX.cjs} +5 -3
  6. package/dist/chunk-CY4VBSMX.cjs.map +1 -0
  7. package/dist/{chunk-Z3TWO2PW.cjs → chunk-JSRKA375.cjs} +29 -7
  8. package/dist/chunk-JSRKA375.cjs.map +1 -0
  9. package/dist/{chunk-UIR6TGEW.js → chunk-M6U3FNRW.js} +5 -3
  10. package/dist/chunk-M6U3FNRW.js.map +1 -0
  11. package/dist/driver-paddle.cjs +14 -14
  12. package/dist/driver-paddle.d.cts +1 -1
  13. package/dist/driver-paddle.d.ts +1 -1
  14. package/dist/driver-paddle.js +1 -1
  15. package/dist/driver-stripe.cjs +13 -13
  16. package/dist/driver-stripe.d.cts +1 -1
  17. package/dist/driver-stripe.d.ts +1 -1
  18. package/dist/driver-stripe.js +1 -1
  19. package/dist/index.cjs +56 -43
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +13 -5
  22. package/dist/index.d.ts +13 -5
  23. package/dist/index.js +18 -5
  24. package/dist/index.js.map +1 -1
  25. package/dist/{manifest-DQThneiG.d.cts → manifest-Cr2y1op6.d.cts} +40 -3
  26. package/dist/{manifest-DQThneiG.d.ts → manifest-Cr2y1op6.d.ts} +40 -3
  27. package/dist/manifest-entry.cjs +129 -20
  28. package/dist/manifest-entry.cjs.map +1 -1
  29. package/dist/manifest-entry.d.cts +28 -3
  30. package/dist/manifest-entry.d.ts +28 -3
  31. package/dist/manifest-entry.js +105 -5
  32. package/dist/manifest-entry.js.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/chunk-7UC5VXOR.js.map +0 -1
  35. package/dist/chunk-UIR6TGEW.js.map +0 -1
  36. package/dist/chunk-VQOD2Z6Q.cjs.map +0 -1
  37. package/dist/chunk-Z3TWO2PW.cjs.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkZ3TWO2PW_cjs = require('./chunk-Z3TWO2PW.cjs');
3
+ var chunkJSRKA375_cjs = require('./chunk-JSRKA375.cjs');
4
4
  var chunkLJYLGLFS_cjs = require('./chunk-LJYLGLFS.cjs');
5
5
  var React = require('react');
6
6
  var ReactDOM = require('react-dom');
@@ -452,9 +452,9 @@ function LocaleProvider({
452
452
  override,
453
453
  children
454
454
  }) {
455
- const [locale, setLocale] = React.useState(() => chunkZ3TWO2PW_cjs.resolveLocale(config, detected, override));
455
+ const [locale, setLocale] = React.useState(() => chunkJSRKA375_cjs.resolveLocale(config, detected, override));
456
456
  React.useEffect(() => {
457
- setLocale(chunkZ3TWO2PW_cjs.resolveLocale(config, detected, override));
457
+ setLocale(chunkJSRKA375_cjs.resolveLocale(config, detected, override));
458
458
  }, [config, detected, override]);
459
459
  const value = React.useMemo(
460
460
  () => ({ locale, setLocale, config, catalog }),
@@ -526,7 +526,7 @@ function useTranslation() {
526
526
  fmt,
527
527
  locale,
528
528
  setLocale,
529
- dir: chunkZ3TWO2PW_cjs.isRtl(locale) ? "rtl" : "ltr",
529
+ dir: chunkJSRKA375_cjs.isRtl(locale) ? "rtl" : "ltr",
530
530
  locales: config?.supported ?? [locale]
531
531
  };
532
532
  }
@@ -547,13 +547,13 @@ function useProduct(id) {
547
547
  const catalog = useCatalog();
548
548
  const locale = useActiveLocale();
549
549
  const resolved = id ? catalog.get(id) : void 0;
550
- return React.useMemo(() => resolved ? chunkZ3TWO2PW_cjs.formatProduct(resolved, locale) : void 0, [resolved, locale]);
550
+ return React.useMemo(() => resolved ? chunkJSRKA375_cjs.formatProduct(resolved, locale) : void 0, [resolved, locale]);
551
551
  }
552
552
  function useProducts() {
553
553
  const catalog = useCatalog();
554
554
  const locale = useActiveLocale();
555
555
  return React.useMemo(
556
- () => Array.from(catalog.values()).map((r) => chunkZ3TWO2PW_cjs.formatProduct(r, locale)),
556
+ () => Array.from(catalog.values()).map((r) => chunkJSRKA375_cjs.formatProduct(r, locale)),
557
557
  [catalog, locale]
558
558
  );
559
559
  }
@@ -634,10 +634,10 @@ function FunnelView({
634
634
  [pages]
635
635
  );
636
636
  const seedRef = React.useRef(null);
637
- if (seedRef.current === null) seedRef.current = chunkZ3TWO2PW_cjs.bucketingSeed(funnel.context);
637
+ if (seedRef.current === null) seedRef.current = chunkJSRKA375_cjs.bucketingSeed(funnel.context);
638
638
  const seed = seedRef.current;
639
639
  const experiments = React.useMemo(
640
- () => chunkZ3TWO2PW_cjs.resolveExperiments(pages, funnel.experiments, seed),
640
+ () => chunkJSRKA375_cjs.resolveExperiments(pages, funnel.experiments, seed),
641
641
  [pages, funnel.experiments, seed]
642
642
  );
643
643
  const toSlot = React.useCallback((k) => experiments.slotOf[k] ?? k, [experiments]);
@@ -656,8 +656,8 @@ function FunnelView({
656
656
  if (!initialKey || initialKey === start) return start ? [start] : [];
657
657
  const target = toSlot(initialKey);
658
658
  const page2 = flowPages.find((p) => p.key === target);
659
- const guard = chunkZ3TWO2PW_cjs.entryGuard(page2?.meta);
660
- const ok = page2 && (!guard || chunkZ3TWO2PW_cjs.evaluateGate(guard, funnel.snapshot()));
659
+ const guard = chunkJSRKA375_cjs.entryGuard(page2?.meta);
660
+ const ok = page2 && (!guard || chunkJSRKA375_cjs.evaluateGate(guard, funnel.snapshot()));
661
661
  const first = ok ? target : start;
662
662
  return first ? [first] : [];
663
663
  });
@@ -665,7 +665,7 @@ function FunnelView({
665
665
  const index = history.length - 1;
666
666
  const startKey = history[0];
667
667
  const total = React.useMemo(
668
- () => chunkZ3TWO2PW_cjs.expectedPathLength(flow, startKey, funnel.snapshot()),
668
+ () => chunkJSRKA375_cjs.expectedPathLength(flow, startKey, funnel.snapshot()),
669
669
  // currentKey in deps: re-trace as each step's answers settle the branch.
670
670
  [flow, startKey, currentKey, funnel]
671
671
  );
@@ -700,7 +700,7 @@ function FunnelView({
700
700
  usePageExitTimer(tracker, currentKey);
701
701
  const [isNavigating, startNav] = React.useTransition();
702
702
  const next = React.useCallback(() => {
703
- const target = chunkZ3TWO2PW_cjs.nextPage(flow, currentKey, funnel.snapshot());
703
+ const target = chunkJSRKA375_cjs.nextPage(flow, currentKey, funnel.snapshot());
704
704
  const resolved = target ? toSlot(target) : target;
705
705
  if (resolved) startNav(() => setHistory((h) => [...h, resolved]));
706
706
  }, [flow, currentKey, funnel, toSlot]);
@@ -724,7 +724,7 @@ function FunnelView({
724
724
  [loaders, toRenderKey]
725
725
  );
726
726
  const nextCandidates = React.useMemo(
727
- () => [...new Set(chunkZ3TWO2PW_cjs.outgoingKeys(flow, currentKey).map(toRenderKey))],
727
+ () => [...new Set(chunkJSRKA375_cjs.outgoingKeys(flow, currentKey).map(toRenderKey))],
728
728
  [flow, currentKey, toRenderKey]
729
729
  );
730
730
  React.useEffect(() => {
@@ -1103,6 +1103,14 @@ function driverWithEmail(driver, getEmail) {
1103
1103
  renderInline: driver.renderInline ? (req, cb) => driver.renderInline(enrich(req), cb) : void 0
1104
1104
  };
1105
1105
  }
1106
+ function driverWithCatalog(driver, catalog) {
1107
+ const enrich = (req) => req.catalogKey !== void 0 ? req : { ...req, catalogKey: catalog.get(req.product)?.catalogKey };
1108
+ return {
1109
+ ...driver,
1110
+ start: (req) => driver.start(enrich(req)),
1111
+ renderInline: driver.renderInline ? (req, cb) => driver.renderInline(enrich(req), cb) : void 0
1112
+ };
1113
+ }
1106
1114
  var DriverContext = React.createContext(null);
1107
1115
  function CheckoutDriverProvider({
1108
1116
  driver,
@@ -2572,12 +2580,15 @@ function FunnelProvider({
2572
2580
  const value2 = s.get("user.email");
2573
2581
  return typeof value2 === "string" && /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(value2) ? value2 : void 0;
2574
2582
  };
2583
+ const catalog = chunkJSRKA375_cjs.buildCatalog(products ?? []);
2575
2584
  return {
2576
2585
  funnel: createFunnel(s, ctx, busTracker, experiments ?? []),
2577
2586
  store: s,
2578
2587
  context: ctx,
2579
- catalog: chunkZ3TWO2PW_cjs.buildCatalog(products ?? []),
2580
- driver: driverWithEmail(checkout ?? createMockDriver(), emailForCheckout),
2588
+ catalog,
2589
+ // Slot catalog-key resolution wraps the email-enriching driver, so the wire charges the real
2590
+ // catalog key while pages + analytics keep the durable SLOT identity (req.product).
2591
+ driver: driverWithCatalog(driverWithEmail(checkout ?? createMockDriver(), emailForCheckout), catalog),
2581
2592
  tracker: busTracker,
2582
2593
  bus
2583
2594
  };
@@ -2849,7 +2860,8 @@ function createFunnelTree({
2849
2860
  config,
2850
2861
  pages,
2851
2862
  layout,
2852
- checkoutDriver
2863
+ checkoutDriver,
2864
+ messages
2853
2865
  }) {
2854
2866
  return function tree(opts) {
2855
2867
  const mode = opts.mode ?? "live";
@@ -2882,6 +2894,7 @@ function createFunnelTree({
2882
2894
  children: React.createElement(FunnelProvider, {
2883
2895
  config,
2884
2896
  products: opts.products ?? [],
2897
+ messages: opts.messages ?? messages,
2885
2898
  locale: opts.locale,
2886
2899
  tracker,
2887
2900
  checkout,
@@ -3045,111 +3058,111 @@ function Script({
3045
3058
 
3046
3059
  Object.defineProperty(exports, "assignVariant", {
3047
3060
  enumerable: true,
3048
- get: function () { return chunkZ3TWO2PW_cjs.assignVariant; }
3061
+ get: function () { return chunkJSRKA375_cjs.assignVariant; }
3049
3062
  });
3050
3063
  Object.defineProperty(exports, "bucketingSeed", {
3051
3064
  enumerable: true,
3052
- get: function () { return chunkZ3TWO2PW_cjs.bucketingSeed; }
3065
+ get: function () { return chunkJSRKA375_cjs.bucketingSeed; }
3053
3066
  });
3054
3067
  Object.defineProperty(exports, "buildCatalog", {
3055
3068
  enumerable: true,
3056
- get: function () { return chunkZ3TWO2PW_cjs.buildCatalog; }
3069
+ get: function () { return chunkJSRKA375_cjs.buildCatalog; }
3057
3070
  });
3058
3071
  Object.defineProperty(exports, "compileManifest", {
3059
3072
  enumerable: true,
3060
- get: function () { return chunkZ3TWO2PW_cjs.compileManifest; }
3073
+ get: function () { return chunkJSRKA375_cjs.compileManifest; }
3061
3074
  });
3062
3075
  Object.defineProperty(exports, "currencyExponent", {
3063
3076
  enumerable: true,
3064
- get: function () { return chunkZ3TWO2PW_cjs.currencyExponent; }
3077
+ get: function () { return chunkJSRKA375_cjs.currencyExponent; }
3065
3078
  });
3066
3079
  Object.defineProperty(exports, "defineFunnel", {
3067
3080
  enumerable: true,
3068
- get: function () { return chunkZ3TWO2PW_cjs.defineFunnel; }
3081
+ get: function () { return chunkJSRKA375_cjs.defineFunnel; }
3069
3082
  });
3070
3083
  Object.defineProperty(exports, "definePage", {
3071
3084
  enumerable: true,
3072
- get: function () { return chunkZ3TWO2PW_cjs.definePage; }
3085
+ get: function () { return chunkJSRKA375_cjs.definePage; }
3073
3086
  });
3074
3087
  Object.defineProperty(exports, "entryGuard", {
3075
3088
  enumerable: true,
3076
- get: function () { return chunkZ3TWO2PW_cjs.entryGuard; }
3089
+ get: function () { return chunkJSRKA375_cjs.entryGuard; }
3077
3090
  });
3078
3091
  Object.defineProperty(exports, "evaluateCondition", {
3079
3092
  enumerable: true,
3080
- get: function () { return chunkZ3TWO2PW_cjs.evaluateCondition; }
3093
+ get: function () { return chunkJSRKA375_cjs.evaluateCondition; }
3081
3094
  });
3082
3095
  Object.defineProperty(exports, "evaluateGate", {
3083
3096
  enumerable: true,
3084
- get: function () { return chunkZ3TWO2PW_cjs.evaluateGate; }
3097
+ get: function () { return chunkJSRKA375_cjs.evaluateGate; }
3085
3098
  });
3086
3099
  Object.defineProperty(exports, "expectedPathLength", {
3087
3100
  enumerable: true,
3088
- get: function () { return chunkZ3TWO2PW_cjs.expectedPathLength; }
3101
+ get: function () { return chunkJSRKA375_cjs.expectedPathLength; }
3089
3102
  });
3090
3103
  Object.defineProperty(exports, "fnv1a", {
3091
3104
  enumerable: true,
3092
- get: function () { return chunkZ3TWO2PW_cjs.fnv1a; }
3105
+ get: function () { return chunkJSRKA375_cjs.fnv1a; }
3093
3106
  });
3094
3107
  Object.defineProperty(exports, "formatMoney", {
3095
3108
  enumerable: true,
3096
- get: function () { return chunkZ3TWO2PW_cjs.formatMoney; }
3109
+ get: function () { return chunkJSRKA375_cjs.formatMoney; }
3097
3110
  });
3098
3111
  Object.defineProperty(exports, "formatProduct", {
3099
3112
  enumerable: true,
3100
- get: function () { return chunkZ3TWO2PW_cjs.formatProduct; }
3113
+ get: function () { return chunkJSRKA375_cjs.formatProduct; }
3101
3114
  });
3102
3115
  Object.defineProperty(exports, "hashToUnit", {
3103
3116
  enumerable: true,
3104
- get: function () { return chunkZ3TWO2PW_cjs.hashToUnit; }
3117
+ get: function () { return chunkJSRKA375_cjs.hashToUnit; }
3105
3118
  });
3106
3119
  Object.defineProperty(exports, "isRtl", {
3107
3120
  enumerable: true,
3108
- get: function () { return chunkZ3TWO2PW_cjs.isRtl; }
3121
+ get: function () { return chunkJSRKA375_cjs.isRtl; }
3109
3122
  });
3110
3123
  Object.defineProperty(exports, "isVariantKey", {
3111
3124
  enumerable: true,
3112
- get: function () { return chunkZ3TWO2PW_cjs.isVariantKey; }
3125
+ get: function () { return chunkJSRKA375_cjs.isVariantKey; }
3113
3126
  });
3114
3127
  Object.defineProperty(exports, "nextPage", {
3115
3128
  enumerable: true,
3116
- get: function () { return chunkZ3TWO2PW_cjs.nextPage; }
3129
+ get: function () { return chunkJSRKA375_cjs.nextPage; }
3117
3130
  });
3118
3131
  Object.defineProperty(exports, "outgoingKeys", {
3119
3132
  enumerable: true,
3120
- get: function () { return chunkZ3TWO2PW_cjs.outgoingKeys; }
3133
+ get: function () { return chunkJSRKA375_cjs.outgoingKeys; }
3121
3134
  });
3122
3135
  Object.defineProperty(exports, "pageMeta", {
3123
3136
  enumerable: true,
3124
- get: function () { return chunkZ3TWO2PW_cjs.pageMeta; }
3137
+ get: function () { return chunkJSRKA375_cjs.pageMeta; }
3125
3138
  });
3126
3139
  Object.defineProperty(exports, "parseSlotKey", {
3127
3140
  enumerable: true,
3128
- get: function () { return chunkZ3TWO2PW_cjs.parseSlotKey; }
3141
+ get: function () { return chunkJSRKA375_cjs.parseSlotKey; }
3129
3142
  });
3130
3143
  Object.defineProperty(exports, "pickByWeight", {
3131
3144
  enumerable: true,
3132
- get: function () { return chunkZ3TWO2PW_cjs.pickByWeight; }
3145
+ get: function () { return chunkJSRKA375_cjs.pickByWeight; }
3133
3146
  });
3134
3147
  Object.defineProperty(exports, "resolveExperiments", {
3135
3148
  enumerable: true,
3136
- get: function () { return chunkZ3TWO2PW_cjs.resolveExperiments; }
3149
+ get: function () { return chunkJSRKA375_cjs.resolveExperiments; }
3137
3150
  });
3138
3151
  Object.defineProperty(exports, "resolveLocale", {
3139
3152
  enumerable: true,
3140
- get: function () { return chunkZ3TWO2PW_cjs.resolveLocale; }
3153
+ get: function () { return chunkJSRKA375_cjs.resolveLocale; }
3141
3154
  });
3142
3155
  Object.defineProperty(exports, "resolveProduct", {
3143
3156
  enumerable: true,
3144
- get: function () { return chunkZ3TWO2PW_cjs.resolveProduct; }
3157
+ get: function () { return chunkJSRKA375_cjs.resolveProduct; }
3145
3158
  });
3146
3159
  Object.defineProperty(exports, "resolveRoute", {
3147
3160
  enumerable: true,
3148
- get: function () { return chunkZ3TWO2PW_cjs.resolveRoute; }
3161
+ get: function () { return chunkJSRKA375_cjs.resolveRoute; }
3149
3162
  });
3150
3163
  Object.defineProperty(exports, "validateExperiments", {
3151
3164
  enumerable: true,
3152
- get: function () { return chunkZ3TWO2PW_cjs.validateExperiments; }
3165
+ get: function () { return chunkJSRKA375_cjs.validateExperiments; }
3153
3166
  });
3154
3167
  Object.defineProperty(exports, "INLINE_SURFACES", {
3155
3168
  enumerable: true,