@rocapine/react-native-onboarding 1.73.0 → 1.74.1

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 (105) hide show
  1. package/README.md +164 -3
  2. package/dist/OnboardingStudio.d.ts +82 -0
  3. package/dist/OnboardingStudio.d.ts.map +1 -0
  4. package/dist/OnboardingStudio.js +91 -0
  5. package/dist/OnboardingStudio.js.map +1 -0
  6. package/dist/OnboardingStudioClient.d.ts +14 -5
  7. package/dist/OnboardingStudioClient.d.ts.map +1 -1
  8. package/dist/OnboardingStudioClient.js +24 -9
  9. package/dist/OnboardingStudioClient.js.map +1 -1
  10. package/dist/index.d.ts +7 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +40 -4
  13. package/dist/index.js.map +1 -1
  14. package/dist/infra/provider/OnboardingProvider.d.ts +15 -2
  15. package/dist/infra/provider/OnboardingProvider.d.ts.map +1 -1
  16. package/dist/infra/provider/OnboardingProvider.js +66 -6
  17. package/dist/infra/provider/OnboardingProvider.js.map +1 -1
  18. package/dist/infra/queries/cacheKey.d.ts +41 -3
  19. package/dist/infra/queries/cacheKey.d.ts.map +1 -1
  20. package/dist/infra/queries/cacheKey.js +44 -8
  21. package/dist/infra/queries/cacheKey.js.map +1 -1
  22. package/dist/infra/queries/getOnboarding.query.d.ts.map +1 -1
  23. package/dist/infra/queries/getOnboarding.query.js +6 -1
  24. package/dist/infra/queries/getOnboarding.query.js.map +1 -1
  25. package/dist/paywalls/PaywallProvider.d.ts +52 -4
  26. package/dist/paywalls/PaywallProvider.d.ts.map +1 -1
  27. package/dist/paywalls/PaywallProvider.js +105 -7
  28. package/dist/paywalls/PaywallProvider.js.map +1 -1
  29. package/dist/paywalls/catalogSettleWaiter.d.ts +31 -0
  30. package/dist/paywalls/catalogSettleWaiter.d.ts.map +1 -0
  31. package/dist/paywalls/catalogSettleWaiter.js +58 -0
  32. package/dist/paywalls/catalogSettleWaiter.js.map +1 -0
  33. package/dist/paywalls/getPaywalls.query.d.ts.map +1 -1
  34. package/dist/paywalls/getPaywalls.query.js +6 -1
  35. package/dist/paywalls/getPaywalls.query.js.map +1 -1
  36. package/dist/paywalls/register.d.ts +105 -0
  37. package/dist/paywalls/register.d.ts.map +1 -0
  38. package/dist/paywalls/register.js +112 -0
  39. package/dist/paywalls/register.js.map +1 -0
  40. package/dist/paywalls/usePaywall.d.ts +29 -0
  41. package/dist/paywalls/usePaywall.d.ts.map +1 -1
  42. package/dist/paywalls/usePaywall.js +2 -1
  43. package/dist/paywalls/usePaywall.js.map +1 -1
  44. package/dist/userProperties/applyPatch.d.ts +18 -0
  45. package/dist/userProperties/applyPatch.d.ts.map +1 -0
  46. package/dist/userProperties/applyPatch.js +57 -0
  47. package/dist/userProperties/applyPatch.js.map +1 -0
  48. package/dist/userProperties/effectiveParams.d.ts +29 -0
  49. package/dist/userProperties/effectiveParams.d.ts.map +1 -0
  50. package/dist/userProperties/effectiveParams.js +56 -0
  51. package/dist/userProperties/effectiveParams.js.map +1 -0
  52. package/dist/userProperties/index.d.ts +9 -0
  53. package/dist/userProperties/index.d.ts.map +1 -0
  54. package/dist/userProperties/index.js +21 -0
  55. package/dist/userProperties/index.js.map +1 -0
  56. package/dist/userProperties/reserved.d.ts +33 -0
  57. package/dist/userProperties/reserved.d.ts.map +1 -0
  58. package/dist/userProperties/reserved.js +45 -0
  59. package/dist/userProperties/reserved.js.map +1 -0
  60. package/dist/userProperties/serialize.d.ts +38 -0
  61. package/dist/userProperties/serialize.d.ts.map +1 -0
  62. package/dist/userProperties/serialize.js +67 -0
  63. package/dist/userProperties/serialize.js.map +1 -0
  64. package/dist/userProperties/store.d.ts +65 -0
  65. package/dist/userProperties/store.d.ts.map +1 -0
  66. package/dist/userProperties/store.js +155 -0
  67. package/dist/userProperties/store.js.map +1 -0
  68. package/dist/userProperties/types.d.ts +21 -0
  69. package/dist/userProperties/types.d.ts.map +1 -0
  70. package/dist/userProperties/types.js +3 -0
  71. package/dist/userProperties/types.js.map +1 -0
  72. package/dist/userProperties/useUserProperties.d.ts +20 -0
  73. package/dist/userProperties/useUserProperties.d.ts.map +1 -0
  74. package/dist/userProperties/useUserProperties.js +30 -0
  75. package/dist/userProperties/useUserProperties.js.map +1 -0
  76. package/package.json +5 -1
  77. package/src/OnboardingStudio.ts +147 -0
  78. package/src/OnboardingStudioClient.ts +27 -11
  79. package/src/__tests__/OnboardingDataGate.test.tsx +445 -0
  80. package/src/__tests__/OnboardingStudio.test.ts +208 -0
  81. package/src/__tests__/cacheKey.test.ts +71 -0
  82. package/src/__tests__/getOnboarding.query.test.ts +47 -8
  83. package/src/index.ts +43 -0
  84. package/src/infra/provider/OnboardingProvider.tsx +98 -10
  85. package/src/infra/queries/cacheKey.ts +54 -9
  86. package/src/infra/queries/getOnboarding.query.ts +9 -1
  87. package/src/paywalls/PaywallProvider.tsx +162 -6
  88. package/src/paywalls/__tests__/catalogSettleWaiter.test.ts +134 -0
  89. package/src/paywalls/__tests__/getPaywalls.test.ts +29 -11
  90. package/src/paywalls/__tests__/register.test.ts +266 -0
  91. package/src/paywalls/catalogSettleWaiter.ts +72 -0
  92. package/src/paywalls/getPaywalls.query.ts +9 -1
  93. package/src/paywalls/register.ts +169 -0
  94. package/src/paywalls/usePaywall.ts +40 -2
  95. package/src/userProperties/__tests__/effectiveParams.test.ts +51 -0
  96. package/src/userProperties/__tests__/primitives.test.ts +96 -0
  97. package/src/userProperties/__tests__/store.test.ts +181 -0
  98. package/src/userProperties/applyPatch.ts +68 -0
  99. package/src/userProperties/effectiveParams.ts +60 -0
  100. package/src/userProperties/index.ts +11 -0
  101. package/src/userProperties/reserved.ts +44 -0
  102. package/src/userProperties/serialize.ts +61 -0
  103. package/src/userProperties/store.ts +179 -0
  104. package/src/userProperties/types.ts +22 -0
  105. package/src/userProperties/useUserProperties.ts +26 -0
@@ -2,6 +2,7 @@ import { PaywallCatalog, PresentResult } from "./types";
2
2
  import type { CatalogStatus } from "./present";
3
3
  import type { ProductStatus } from "../products/types";
4
4
  import type { CustomPaywallScreens } from "./customScreens";
5
+ import type { RegisterFeature, RegisterResult } from "./register";
5
6
  export type UsePaywallResult = {
6
7
  /**
7
8
  * Present a paywall by moment. Never fetches — the catalog and its
@@ -14,6 +15,34 @@ export type UsePaywallResult = {
14
15
  * presented. See `resolvePresentDecision` in `present.ts`.
15
16
  */
16
17
  present: (moment: string) => Promise<PresentResult>;
18
+ /**
19
+ * Gate a feature on a moment — Superwall's `registerPlacement`, in this SDK's
20
+ * vocabulary:
21
+ *
22
+ * ```ts
23
+ * await register("unlock_stats", () => router.push("/stats"));
24
+ * ```
25
+ *
26
+ * - The moment has **no paywall** (not monetised, or not authored yet) → runs
27
+ * the feature immediately.
28
+ * - The moment **has** a paywall → presents it, and runs the feature **only**
29
+ * on a purchase. A dismiss or a cancel withholds it.
30
+ * - **No catalog is reachable** → fails OPEN: runs the feature and warns. An
31
+ * offline launch must not silently disable the app's features. Read
32
+ * `reason: "catalog-unavailable"` off the result to measure how often this
33
+ * happens.
34
+ *
35
+ * Gates on the moment **alone** — there is no entitlement check. Exclude
36
+ * paying users by setting a user property
37
+ * (`OnboardingStudio.setUserProperty("plan", "pro")`)
38
+ * and authoring an audience filter on it.
39
+ *
40
+ * **A Stripe-billed paywall never runs the feature**, even on a successful
41
+ * checkout: a Payment Link resolves out-of-band through RevenueCat, so the
42
+ * presentation never reports `"purchased"`. Grant access from your RevenueCat
43
+ * entitlement webhook. `register` warns when it presents one.
44
+ */
45
+ register: (moment: string, feature?: RegisterFeature) => Promise<RegisterResult>;
17
46
  /**
18
47
  * `true` once BOTH the catalog and its products have resolved — the one
19
48
  * flag meaning "calling `present()` now will not show a spinner".
@@ -1 +1 @@
1
- {"version":3,"file":"usePaywall.d.ts","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;;;;OASG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACpD;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B;;;;;;OAMG;IACH,aAAa,EAAE,aAAa,CAAC;IAC7B;;;OAGG;IACH,cAAc,EAAE,aAAa,CAAC;IAC9B;;;;;OAKG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,aAAa,EAAE,oBAAoB,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAO,gBAY7B,CAAC"}
1
+ {"version":3,"file":"usePaywall.d.ts","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;;;;OASG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACpD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACjF;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B;;;;;;OAMG;IACH,aAAa,EAAE,aAAa,CAAC;IAC7B;;;OAGG;IACH,cAAc,EAAE,aAAa,CAAC;IAC9B;;;;;OAKG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,aAAa,EAAE,oBAAoB,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAO,gBAqB7B,CAAC"}
@@ -10,9 +10,10 @@ const PaywallProvider_1 = require("./PaywallProvider");
10
10
  * `useProductRuntime()` degrades to `null` with no ancestor.
11
11
  */
12
12
  const usePaywall = () => {
13
- const { present, isReady, catalog, catalogStatus, productsStatus, isProviderMounted, customScreens } = (0, react_1.useContext)(PaywallProvider_1.PaywallContext);
13
+ const { present, register, isReady, catalog, catalogStatus, productsStatus, isProviderMounted, customScreens, } = (0, react_1.useContext)(PaywallProvider_1.PaywallContext);
14
14
  return {
15
15
  present,
16
+ register,
16
17
  isReady,
17
18
  catalog,
18
19
  catalogStatus,
@@ -1 +1 @@
1
- {"version":3,"file":"usePaywall.js","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AACnC,uDAAmD;AAqDnD;;;;;GAKG;AACI,MAAM,UAAU,GAAG,GAAqB,EAAE;IAC/C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,GAClG,IAAA,kBAAU,EAAC,gCAAc,CAAC,CAAC;IAC7B,OAAO;QACL,OAAO;QACP,OAAO;QACP,OAAO;QACP,aAAa;QACb,cAAc;QACd,iBAAiB;QACjB,aAAa;KACd,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,UAAU,cAYrB"}
1
+ {"version":3,"file":"usePaywall.js","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AACnC,uDAAmD;AAkFnD;;;;;GAKG;AACI,MAAM,UAAU,GAAG,GAAqB,EAAE;IAC/C,MAAM,EACJ,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,EACP,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,GAAG,IAAA,kBAAU,EAAC,gCAAc,CAAC,CAAC;IAC/B,OAAO;QACL,OAAO;QACP,QAAQ;QACR,OAAO;QACP,OAAO;QACP,aAAa;QACb,cAAc;QACd,iBAAiB;QACjB,aAAa;KACd,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,UAAU,cAqBrB"}
@@ -0,0 +1,18 @@
1
+ import type { UserProperties, UserPropertyPatch } from "./types";
2
+ /**
3
+ * The store's entire mutation logic, as a pure function — so merge semantics,
4
+ * deletion, and every rejection rule are covered by an importable test rather
5
+ * than through AsyncStorage and React.
6
+ *
7
+ * Warnings are RETURNED rather than logged here, so the same rules can be
8
+ * asserted without spying on `console`. The store logs them.
9
+ *
10
+ * Returns the SAME `current` object when nothing changed, so a no-op `set` does
11
+ * not notify subscribers or trigger a refetch — a host calling `set({ plan })`
12
+ * on every render must not re-key the catalog query each time.
13
+ */
14
+ export declare const applyUserPropertyPatch: (current: UserProperties, patch: UserPropertyPatch) => {
15
+ next: UserProperties;
16
+ warnings: string[];
17
+ };
18
+ //# sourceMappingURL=applyPatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyPatch.d.ts","sourceRoot":"","sources":["../../src/userProperties/applyPatch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,cAAc,EACvB,OAAO,iBAAiB,KACvB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAiD5C,CAAC"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyUserPropertyPatch = void 0;
4
+ const reserved_1 = require("./reserved");
5
+ /**
6
+ * The store's entire mutation logic, as a pure function — so merge semantics,
7
+ * deletion, and every rejection rule are covered by an importable test rather
8
+ * than through AsyncStorage and React.
9
+ *
10
+ * Warnings are RETURNED rather than logged here, so the same rules can be
11
+ * asserted without spying on `console`. The store logs them.
12
+ *
13
+ * Returns the SAME `current` object when nothing changed, so a no-op `set` does
14
+ * not notify subscribers or trigger a refetch — a host calling `set({ plan })`
15
+ * on every render must not re-key the catalog query each time.
16
+ */
17
+ const applyUserPropertyPatch = (current, patch) => {
18
+ const warnings = [];
19
+ const next = Object.assign({}, current);
20
+ let changed = false;
21
+ for (const key of Object.keys(patch)) {
22
+ if ((0, reserved_1.isReservedUserPropertyKey)(key)) {
23
+ warnings.push(`[user-properties] Ignoring "${key}" — the SDK puts that name on the ` +
24
+ "request querystring itself, and a duplicate silently breaks the request. " +
25
+ "Rename the property.");
26
+ continue;
27
+ }
28
+ const value = patch[key];
29
+ if (value === null || value === undefined) {
30
+ if (key in next) {
31
+ delete next[key];
32
+ changed = true;
33
+ }
34
+ continue;
35
+ }
36
+ const type = typeof value;
37
+ if (type === "number") {
38
+ if (!Number.isFinite(value)) {
39
+ warnings.push(`[user-properties] Ignoring "${key}" — ${String(value)} is not a finite ` +
40
+ 'number and would reach the server as "NaN"/"Infinity", matching nothing.');
41
+ continue;
42
+ }
43
+ }
44
+ else if (type !== "string" && type !== "boolean") {
45
+ warnings.push(`[user-properties] Ignoring "${key}" — a user property must be a string, ` +
46
+ `number or boolean, not ${type}. Audience filters compare scalars.`);
47
+ continue;
48
+ }
49
+ if (next[key] !== value) {
50
+ next[key] = value;
51
+ changed = true;
52
+ }
53
+ }
54
+ return { next: changed ? next : current, warnings };
55
+ };
56
+ exports.applyUserPropertyPatch = applyUserPropertyPatch;
57
+ //# sourceMappingURL=applyPatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyPatch.js","sourceRoot":"","sources":["../../src/userProperties/applyPatch.ts"],"names":[],"mappings":";;;AAAA,yCAAuD;AAGvD;;;;;;;;;;;GAWG;AACI,MAAM,sBAAsB,GAAG,CACpC,OAAuB,EACvB,KAAwB,EACsB,EAAE;IAChD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,IAAI,qBAAwB,OAAO,CAAE,CAAC;IAC5C,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,IAAI,IAAA,oCAAyB,EAAC,GAAG,CAAC,EAAE,CAAC;YACnC,QAAQ,CAAC,IAAI,CACX,+BAA+B,GAAG,oCAAoC;gBACpE,2EAA2E;gBAC3E,sBAAsB,CACzB,CAAC;YACF,SAAS;QACX,CAAC;QAED,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QAEzB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC1C,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;gBAChB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;gBACjB,OAAO,GAAG,IAAI,CAAC;YACjB,CAAC;YACD,SAAS;QACX,CAAC;QAED,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC;QAC1B,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,QAAQ,CAAC,IAAI,CACX,+BAA+B,GAAG,OAAO,MAAM,CAAC,KAAK,CAAC,mBAAmB;oBACvE,0EAA0E,CAC7E,CAAC;gBACF,SAAS;YACX,CAAC;QACH,CAAC;aAAM,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACnD,QAAQ,CAAC,IAAI,CACX,+BAA+B,GAAG,wCAAwC;gBACxE,0BAA0B,IAAI,qCAAqC,CACtE,CAAC;YACF,SAAS;QACX,CAAC;QAED,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YAClB,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;AACtD,CAAC,CAAC;AApDW,QAAA,sBAAsB,0BAoDjC"}
@@ -0,0 +1,29 @@
1
+ import type { UserProperties } from "./types";
2
+ /**
3
+ * The audience params a provider actually sends: the `customAudienceParams` prop
4
+ * as a static baseline, with the user-property store merged OVER it.
5
+ *
6
+ * Precedence is the store, per key. `customAudienceParams` is where build-time
7
+ * facts live (an `onboardingId`, a build channel) — set once at mount — and the
8
+ * store is where anything that changes at runtime lives. A runtime value losing
9
+ * to a mount-time prop would make the store useless for the case it exists for.
10
+ *
11
+ * The prop is neither deprecated nor removed: merging means every existing host
12
+ * keeps working untouched.
13
+ *
14
+ * Everything is serialized to a string here, once, so the query key, the cache
15
+ * key hash and the querystring all see the same bytes.
16
+ *
17
+ * The prop is typed `Record<string, any>` and predates this module, so its values
18
+ * are treated conservatively:
19
+ *
20
+ * - a reserved name is DROPPED, because it would break the request outright (the
21
+ * client puts that name on the querystring itself — see `reserved.ts`);
22
+ * - `null`/`undefined` is OMITTED rather than sent as the string `"null"`, which
23
+ * would match an audience filter testing for absence;
24
+ * - anything else non-scalar is stringified with `String(...)` rather than
25
+ * dropped, so a host already passing something exotic keeps the exact wire
26
+ * behaviour it had before this module existed.
27
+ */
28
+ export declare const resolveEffectiveParams: (baseline: Record<string, any>, properties: UserProperties) => Record<string, string>;
29
+ //# sourceMappingURL=effectiveParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effectiveParams.d.ts","sourceRoot":"","sources":["../../src/userProperties/effectiveParams.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC7B,YAAY,cAAc,KACzB,MAAM,CAAC,MAAM,EAAE,MAAM,CA0BvB,CAAC"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveEffectiveParams = void 0;
4
+ const reserved_1 = require("./reserved");
5
+ const serialize_1 = require("./serialize");
6
+ /**
7
+ * The audience params a provider actually sends: the `customAudienceParams` prop
8
+ * as a static baseline, with the user-property store merged OVER it.
9
+ *
10
+ * Precedence is the store, per key. `customAudienceParams` is where build-time
11
+ * facts live (an `onboardingId`, a build channel) — set once at mount — and the
12
+ * store is where anything that changes at runtime lives. A runtime value losing
13
+ * to a mount-time prop would make the store useless for the case it exists for.
14
+ *
15
+ * The prop is neither deprecated nor removed: merging means every existing host
16
+ * keeps working untouched.
17
+ *
18
+ * Everything is serialized to a string here, once, so the query key, the cache
19
+ * key hash and the querystring all see the same bytes.
20
+ *
21
+ * The prop is typed `Record<string, any>` and predates this module, so its values
22
+ * are treated conservatively:
23
+ *
24
+ * - a reserved name is DROPPED, because it would break the request outright (the
25
+ * client puts that name on the querystring itself — see `reserved.ts`);
26
+ * - `null`/`undefined` is OMITTED rather than sent as the string `"null"`, which
27
+ * would match an audience filter testing for absence;
28
+ * - anything else non-scalar is stringified with `String(...)` rather than
29
+ * dropped, so a host already passing something exotic keeps the exact wire
30
+ * behaviour it had before this module existed.
31
+ */
32
+ const resolveEffectiveParams = (baseline, properties) => {
33
+ const out = {};
34
+ for (const key of Object.keys(baseline !== null && baseline !== void 0 ? baseline : {})) {
35
+ if ((0, reserved_1.isReservedUserPropertyKey)(key)) {
36
+ console.warn(`[user-properties] Ignoring customAudienceParams."${key}" — the SDK puts ` +
37
+ "that name on the request querystring itself, and a duplicate silently " +
38
+ "breaks the request.");
39
+ continue;
40
+ }
41
+ const value = baseline[key];
42
+ if (value === null || value === undefined)
43
+ continue;
44
+ out[key] =
45
+ typeof value === "string" || typeof value === "number" || typeof value === "boolean"
46
+ ? (0, serialize_1.serializeUserPropertyValue)(value)
47
+ : String(value);
48
+ }
49
+ // The store wins.
50
+ for (const key of Object.keys(properties)) {
51
+ out[key] = (0, serialize_1.serializeUserPropertyValue)(properties[key]);
52
+ }
53
+ return out;
54
+ };
55
+ exports.resolveEffectiveParams = resolveEffectiveParams;
56
+ //# sourceMappingURL=effectiveParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effectiveParams.js","sourceRoot":"","sources":["../../src/userProperties/effectiveParams.ts"],"names":[],"mappings":";;;AAAA,yCAAuD;AACvD,2CAAyD;AAGzD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACI,MAAM,sBAAsB,GAAG,CACpC,QAA6B,EAC7B,UAA0B,EACF,EAAE;IAC1B,MAAM,GAAG,GAA2B,EAAE,CAAC;IAEvC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC,EAAE,CAAC;QAC9C,IAAI,IAAA,oCAAyB,EAAC,GAAG,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,CACV,oDAAoD,GAAG,mBAAmB;gBACxE,wEAAwE;gBACxE,qBAAqB,CACxB,CAAC;YACF,SAAS;QACX,CAAC;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QACpD,GAAG,CAAC,GAAG,CAAC;YACN,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS;gBAClF,CAAC,CAAC,IAAA,sCAA0B,EAAC,KAAK,CAAC;gBACnC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,kBAAkB;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC1C,GAAG,CAAC,GAAG,CAAC,GAAG,IAAA,sCAA0B,EAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AA7BW,QAAA,sBAAsB,0BA6BjC"}
@@ -0,0 +1,9 @@
1
+ export type { UserProperties, UserPropertyPatch, UserPropertyValue } from "./types";
2
+ export { RESERVED_USER_PROPERTY_KEYS, isReservedUserPropertyKey } from "./reserved";
3
+ export type { ReservedUserPropertyKey } from "./reserved";
4
+ export { serializeUserPropertyValue, toQueryParams, paramsHash } from "./serialize";
5
+ export { applyUserPropertyPatch } from "./applyPatch";
6
+ export { createUserPropertyStore, USER_PROPERTIES_STORAGE_KEY } from "./store";
7
+ export type { UserPropertySnapshot, UserPropertyStorage, UserPropertyStore } from "./store";
8
+ export { useUserProperties } from "./useUserProperties";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/userProperties/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACpF,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AACpF,YAAY,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAItD,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAC/E,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useUserProperties = exports.USER_PROPERTIES_STORAGE_KEY = exports.createUserPropertyStore = exports.applyUserPropertyPatch = exports.paramsHash = exports.toQueryParams = exports.serializeUserPropertyValue = exports.isReservedUserPropertyKey = exports.RESERVED_USER_PROPERTY_KEYS = void 0;
4
+ var reserved_1 = require("./reserved");
5
+ Object.defineProperty(exports, "RESERVED_USER_PROPERTY_KEYS", { enumerable: true, get: function () { return reserved_1.RESERVED_USER_PROPERTY_KEYS; } });
6
+ Object.defineProperty(exports, "isReservedUserPropertyKey", { enumerable: true, get: function () { return reserved_1.isReservedUserPropertyKey; } });
7
+ var serialize_1 = require("./serialize");
8
+ Object.defineProperty(exports, "serializeUserPropertyValue", { enumerable: true, get: function () { return serialize_1.serializeUserPropertyValue; } });
9
+ Object.defineProperty(exports, "toQueryParams", { enumerable: true, get: function () { return serialize_1.toQueryParams; } });
10
+ Object.defineProperty(exports, "paramsHash", { enumerable: true, get: function () { return serialize_1.paramsHash; } });
11
+ var applyPatch_1 = require("./applyPatch");
12
+ Object.defineProperty(exports, "applyUserPropertyPatch", { enumerable: true, get: function () { return applyPatch_1.applyUserPropertyPatch; } });
13
+ // `userPropertyStore` — the process-wide instance — is deliberately NOT
14
+ // re-exported for hosts: `OnboardingStudio` is the front door. It is imported
15
+ // directly by `OnboardingStudio.ts` and `useUserProperties.ts`.
16
+ var store_1 = require("./store");
17
+ Object.defineProperty(exports, "createUserPropertyStore", { enumerable: true, get: function () { return store_1.createUserPropertyStore; } });
18
+ Object.defineProperty(exports, "USER_PROPERTIES_STORAGE_KEY", { enumerable: true, get: function () { return store_1.USER_PROPERTIES_STORAGE_KEY; } });
19
+ var useUserProperties_1 = require("./useUserProperties");
20
+ Object.defineProperty(exports, "useUserProperties", { enumerable: true, get: function () { return useUserProperties_1.useUserProperties; } });
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/userProperties/index.ts"],"names":[],"mappings":";;;AACA,uCAAoF;AAA3E,uHAAA,2BAA2B,OAAA;AAAE,qHAAA,yBAAyB,OAAA;AAE/D,yCAAoF;AAA3E,uHAAA,0BAA0B,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,uGAAA,UAAU,OAAA;AAC9D,2CAAsD;AAA7C,oHAAA,sBAAsB,OAAA;AAC/B,wEAAwE;AACxE,8EAA8E;AAC9E,gEAAgE;AAChE,iCAA+E;AAAtE,gHAAA,uBAAuB,OAAA;AAAE,oHAAA,2BAA2B,OAAA;AAE7D,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Property names a host may NOT use, because `OnboardingStudioClient` puts them
3
+ * on the querystring itself.
4
+ *
5
+ * Two of them — `moment` and `now` — mirror the server's own
6
+ * `RESERVED_AUDIENCE_VARS`, which strips them because they are server-owned (a
7
+ * client supplying `now` is self-selecting into a time-gated audience).
8
+ *
9
+ * The other six close a collision that is live today and merely unreachable,
10
+ * because nobody hand-writes these names into `customAudienceParams`. The
11
+ * client appends user params FIRST, then its own:
12
+ *
13
+ * Object.entries(userDefinedParams).forEach(([k, v]) => urlParams.append(k, v));
14
+ * urlParams.append("projectId", this.projectId);
15
+ *
16
+ * `URLSearchParams.append` permits duplicates, and the two server-side readers
17
+ * disagree about which one wins: `url.searchParams.get("projectId")` returns the
18
+ * FIRST occurrence (the user's value — so the request resolves the wrong
19
+ * project, or 400s), while `Object.fromEntries(...)` is last-wins (so the
20
+ * json-logic data still holds the real one). The result is a failed or
21
+ * cross-project request with no diagnostic pointing at the property that caused
22
+ * it.
23
+ *
24
+ * A store whose whole purpose is to let a host name keys freely makes that a
25
+ * plausible accident, so this is where it gets refused. Refusing — rather than
26
+ * prefixing or escaping — keeps the wire format unchanged and puts the warning
27
+ * at the call site responsible.
28
+ */
29
+ export declare const RESERVED_USER_PROPERTY_KEYS: readonly ["projectId", "platform", "appVersion", "draft", "locale", "omitNulls", "moment", "now"];
30
+ export type ReservedUserPropertyKey = (typeof RESERVED_USER_PROPERTY_KEYS)[number];
31
+ /** Exact match, never a prefix — `projectIdentifier` is a perfectly good property. */
32
+ export declare const isReservedUserPropertyKey: (key: string) => boolean;
33
+ //# sourceMappingURL=reserved.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../../src/userProperties/reserved.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,2BAA2B,mGAS9B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnF,sFAAsF;AACtF,eAAO,MAAM,yBAAyB,GAAI,KAAK,MAAM,KAAG,OACU,CAAC"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isReservedUserPropertyKey = exports.RESERVED_USER_PROPERTY_KEYS = void 0;
4
+ /**
5
+ * Property names a host may NOT use, because `OnboardingStudioClient` puts them
6
+ * on the querystring itself.
7
+ *
8
+ * Two of them — `moment` and `now` — mirror the server's own
9
+ * `RESERVED_AUDIENCE_VARS`, which strips them because they are server-owned (a
10
+ * client supplying `now` is self-selecting into a time-gated audience).
11
+ *
12
+ * The other six close a collision that is live today and merely unreachable,
13
+ * because nobody hand-writes these names into `customAudienceParams`. The
14
+ * client appends user params FIRST, then its own:
15
+ *
16
+ * Object.entries(userDefinedParams).forEach(([k, v]) => urlParams.append(k, v));
17
+ * urlParams.append("projectId", this.projectId);
18
+ *
19
+ * `URLSearchParams.append` permits duplicates, and the two server-side readers
20
+ * disagree about which one wins: `url.searchParams.get("projectId")` returns the
21
+ * FIRST occurrence (the user's value — so the request resolves the wrong
22
+ * project, or 400s), while `Object.fromEntries(...)` is last-wins (so the
23
+ * json-logic data still holds the real one). The result is a failed or
24
+ * cross-project request with no diagnostic pointing at the property that caused
25
+ * it.
26
+ *
27
+ * A store whose whole purpose is to let a host name keys freely makes that a
28
+ * plausible accident, so this is where it gets refused. Refusing — rather than
29
+ * prefixing or escaping — keeps the wire format unchanged and puts the warning
30
+ * at the call site responsible.
31
+ */
32
+ exports.RESERVED_USER_PROPERTY_KEYS = [
33
+ "projectId",
34
+ "platform",
35
+ "appVersion",
36
+ "draft",
37
+ "locale",
38
+ "omitNulls",
39
+ "moment",
40
+ "now",
41
+ ];
42
+ /** Exact match, never a prefix — `projectIdentifier` is a perfectly good property. */
43
+ const isReservedUserPropertyKey = (key) => exports.RESERVED_USER_PROPERTY_KEYS.includes(key);
44
+ exports.isReservedUserPropertyKey = isReservedUserPropertyKey;
45
+ //# sourceMappingURL=reserved.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reserved.js","sourceRoot":"","sources":["../../src/userProperties/reserved.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACU,QAAA,2BAA2B,GAAG;IACzC,WAAW;IACX,UAAU;IACV,YAAY;IACZ,OAAO;IACP,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,KAAK;CACG,CAAC;AAIX,sFAAsF;AAC/E,MAAM,yBAAyB,GAAG,CAAC,GAAW,EAAW,EAAE,CAC/D,mCAAiD,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AADtD,QAAA,yBAAyB,6BAC6B"}
@@ -0,0 +1,38 @@
1
+ import type { UserProperties, UserPropertyValue } from "./types";
2
+ /**
3
+ * A property value as it crosses the wire.
4
+ *
5
+ * Note how this interacts with a studio audience filter. `json-logic-js` applies
6
+ * the plain JS operator, and the studio authors the literal — so the normal
7
+ * shape, `{">=": [{"var": "daysSinceInstall"}, 3]}`, coerces numerically
8
+ * (`"3" >= 3` is `true`) and behaves as an author expects. The case to know
9
+ * about is a filter whose literal is itself a STRING: `{">": [{"var":"day"}, "9"]}`
10
+ * compares lexicographically, so `"10"` is NOT greater than `"9"`. That is a
11
+ * property of the querystring wire format rather than of this function, but
12
+ * numbers being a first-class property type makes it much easier to reach.
13
+ */
14
+ export declare const serializeUserPropertyValue: (value: UserPropertyValue) => string;
15
+ /** The property map as the client's `userDefinedParams`. */
16
+ export declare const toQueryParams: (properties: UserProperties) => Record<string, string>;
17
+ /**
18
+ * A short, stable fingerprint of the resolved params, used to SCOPE the
19
+ * AsyncStorage cache keys (`infra/queries/cacheKey.ts`).
20
+ *
21
+ * Sorted by key, because the same logical params arrive in different insertion
22
+ * orders depending on whether they came from disk or from a fresh merge — an
23
+ * unsorted hash would make that a guaranteed spurious cache miss on every
24
+ * launch.
25
+ *
26
+ * `key=value;` per pair rather than bare concatenation, so `{ab:"c"}` and
27
+ * `{a:"bc"}` cannot collide.
28
+ *
29
+ * Returns `""` for an empty map. That is load-bearing: it makes the cache key of
30
+ * a host sending no params byte-identical to the pre-scoping key, so shipping
31
+ * this does not invalidate every existing install's cache.
32
+ *
33
+ * djb2 — this addresses accidental collision between one app's own param sets,
34
+ * not an adversary, and a crypto hash would mean pulling in a dependency to name
35
+ * a cache entry.
36
+ */
37
+ export declare const paramsHash: (params: Record<string, string>) => string;
38
+ //# sourceMappingURL=serialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/userProperties/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,iBAAiB,KAAG,MAIrE,CAAC;AAEF,4DAA4D;AAC5D,eAAO,MAAM,aAAa,GAAI,YAAY,cAAc,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAM/E,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,MAW3D,CAAC"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.paramsHash = exports.toQueryParams = exports.serializeUserPropertyValue = void 0;
4
+ /**
5
+ * A property value as it crosses the wire.
6
+ *
7
+ * Note how this interacts with a studio audience filter. `json-logic-js` applies
8
+ * the plain JS operator, and the studio authors the literal — so the normal
9
+ * shape, `{">=": [{"var": "daysSinceInstall"}, 3]}`, coerces numerically
10
+ * (`"3" >= 3` is `true`) and behaves as an author expects. The case to know
11
+ * about is a filter whose literal is itself a STRING: `{">": [{"var":"day"}, "9"]}`
12
+ * compares lexicographically, so `"10"` is NOT greater than `"9"`. That is a
13
+ * property of the querystring wire format rather than of this function, but
14
+ * numbers being a first-class property type makes it much easier to reach.
15
+ */
16
+ const serializeUserPropertyValue = (value) => {
17
+ if (typeof value === "number")
18
+ return String(value);
19
+ if (typeof value === "boolean")
20
+ return value ? "true" : "false";
21
+ return value;
22
+ };
23
+ exports.serializeUserPropertyValue = serializeUserPropertyValue;
24
+ /** The property map as the client's `userDefinedParams`. */
25
+ const toQueryParams = (properties) => {
26
+ const out = {};
27
+ for (const key of Object.keys(properties)) {
28
+ out[key] = (0, exports.serializeUserPropertyValue)(properties[key]);
29
+ }
30
+ return out;
31
+ };
32
+ exports.toQueryParams = toQueryParams;
33
+ /**
34
+ * A short, stable fingerprint of the resolved params, used to SCOPE the
35
+ * AsyncStorage cache keys (`infra/queries/cacheKey.ts`).
36
+ *
37
+ * Sorted by key, because the same logical params arrive in different insertion
38
+ * orders depending on whether they came from disk or from a fresh merge — an
39
+ * unsorted hash would make that a guaranteed spurious cache miss on every
40
+ * launch.
41
+ *
42
+ * `key=value;` per pair rather than bare concatenation, so `{ab:"c"}` and
43
+ * `{a:"bc"}` cannot collide.
44
+ *
45
+ * Returns `""` for an empty map. That is load-bearing: it makes the cache key of
46
+ * a host sending no params byte-identical to the pre-scoping key, so shipping
47
+ * this does not invalidate every existing install's cache.
48
+ *
49
+ * djb2 — this addresses accidental collision between one app's own param sets,
50
+ * not an adversary, and a crypto hash would mean pulling in a dependency to name
51
+ * a cache entry.
52
+ */
53
+ const paramsHash = (params) => {
54
+ const keys = Object.keys(params).sort();
55
+ if (keys.length === 0)
56
+ return "";
57
+ let hash = 5381;
58
+ for (const key of keys) {
59
+ const pair = `${key}=${params[key]};`;
60
+ for (let i = 0; i < pair.length; i++) {
61
+ hash = ((hash * 33) ^ pair.charCodeAt(i)) >>> 0;
62
+ }
63
+ }
64
+ return hash.toString(16).padStart(8, "0");
65
+ };
66
+ exports.paramsHash = paramsHash;
67
+ //# sourceMappingURL=serialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../src/userProperties/serialize.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AACI,MAAM,0BAA0B,GAAG,CAAC,KAAwB,EAAU,EAAE;IAC7E,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAChE,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAJW,QAAA,0BAA0B,8BAIrC;AAEF,4DAA4D;AACrD,MAAM,aAAa,GAAG,CAAC,UAA0B,EAA0B,EAAE;IAClF,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC1C,GAAG,CAAC,GAAG,CAAC,GAAG,IAAA,kCAA0B,EAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AANW,QAAA,aAAa,iBAMxB;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACI,MAAM,UAAU,GAAG,CAAC,MAA8B,EAAU,EAAE;IACnE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IACxC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACjC,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,GAAG,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC5C,CAAC,CAAC;AAXW,QAAA,UAAU,cAWrB"}
@@ -0,0 +1,65 @@
1
+ import type { UserProperties, UserPropertyPatch } from "./types";
2
+ /**
3
+ * The slice of AsyncStorage this needs, injected so the store is testable
4
+ * without mocking a module.
5
+ */
6
+ export type UserPropertyStorage = {
7
+ getItem: (key: string) => Promise<string | null>;
8
+ setItem: (key: string, value: string) => Promise<void>;
9
+ removeItem: (key: string) => Promise<void>;
10
+ };
11
+ /**
12
+ * ONE constant, deliberately not namespaced by `client.options.cacheKey` the way
13
+ * the payload caches are. `cacheKey` exists to pin a payload VERSION; user
14
+ * properties describe the USER, which is orthogonal. Deriving this from
15
+ * `cacheKey` would also force the store to learn about a client before it could
16
+ * hydrate, reintroducing the ordering problem hydration exists to remove.
17
+ *
18
+ * It also deliberately does NOT start with `rocapine-onboarding` or
19
+ * `rocapine-paywalls`, the two prefixes `OnboardingStudioClient.clearCache`
20
+ * scans: clearing a payload cache must not forget who the user is.
21
+ */
22
+ export declare const USER_PROPERTIES_STORAGE_KEY = "rocapine-user-properties";
23
+ export type UserPropertySnapshot = {
24
+ properties: UserProperties;
25
+ status: "hydrating" | "ready";
26
+ };
27
+ export type UserPropertyStore = {
28
+ get: () => UserProperties;
29
+ set: (patch: UserPropertyPatch) => void;
30
+ remove: (key: string) => void;
31
+ reset: () => void;
32
+ getSnapshot: () => UserPropertySnapshot;
33
+ subscribe: (listener: () => void) => () => void;
34
+ ensureHydrated: () => Promise<void>;
35
+ };
36
+ /**
37
+ * The mutable, persisted user-property map that feeds audience resolution.
38
+ *
39
+ * A module singleton (see `userProperties` below) rather than a provider +
40
+ * context, which is what every other piece of state in this package uses. The
41
+ * departure is deliberate and is the reason the feature exists: properties get
42
+ * set from a login handler, an analytics service, a push-token callback — code
43
+ * that is not a component and cannot call a hook. Superwall's own
44
+ * `setUserAttributes` is a singleton for the same reason.
45
+ *
46
+ * It also REMOVES a source of truth rather than adding one. With
47
+ * `customAudienceParams` passed separately to `OnboardingProvider` and
48
+ * `PaywallProvider`, an onboarding audience and a paywall audience can disagree
49
+ * about the same user. One store makes that impossible — they can now differ
50
+ * only by WHEN they read it, since each is resolved at its own serve time (see
51
+ * `useAudienceParams` in `OnboardingProvider`).
52
+ *
53
+ * Storage is injected so the whole thing is testable as a plain object.
54
+ */
55
+ export declare const createUserPropertyStore: (storage: UserPropertyStorage) => UserPropertyStore;
56
+ /**
57
+ * The process-wide store.
58
+ *
59
+ * INTERNAL: hosts reach this through `OnboardingStudio` (`setUserProperty`,
60
+ * `reset`, …) and `useUserProperties()`, never directly. Keeping one public
61
+ * front door means a host cannot half-use the facade and half-use the store, and
62
+ * leaves this module free to change shape.
63
+ */
64
+ export declare const userPropertyStore: UserPropertyStore;
65
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/userProperties/store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjE;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACjD,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,6BAA6B,CAAC;AAEtE,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,cAAc,CAAC;IAC3B,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,cAAc,CAAC;IAC1B,GAAG,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACxC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,WAAW,EAAE,MAAM,oBAAoB,CAAC;IACxC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAChD,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,mBAAmB,KAAG,iBA2GtE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,mBAAwC,CAAC"}