react-native-revnix 1.5.0 → 1.7.0

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 (49) hide show
  1. package/README.md +16 -0
  2. package/android/build.gradle +3 -0
  3. package/android/consumer-rules.pro +1 -0
  4. package/android/src/main/kotlin/com/revnix/reactnative/RevnixStoreModule.kt +43 -0
  5. package/dist/blocks/locale.js +7 -0
  6. package/dist/blocks/selection.d.ts +7 -1
  7. package/dist/blocks/selection.js +9 -0
  8. package/dist/blocks/tags.d.ts +3 -0
  9. package/dist/blocks/tags.js +33 -0
  10. package/dist/blocks/types.d.ts +45 -3
  11. package/dist/blocks/types.js +1 -0
  12. package/dist/client.d.ts +50 -11
  13. package/dist/client.js +408 -119
  14. package/dist/esm/blocks/locale.js +7 -0
  15. package/dist/esm/blocks/selection.js +8 -0
  16. package/dist/esm/blocks/tags.js +31 -0
  17. package/dist/esm/blocks/types.js +1 -0
  18. package/dist/esm/client.js +407 -119
  19. package/dist/esm/store/index.js +7 -0
  20. package/dist/esm/ui/RevnixBlockPaywall.js +103 -22
  21. package/dist/esm/ui/RevnixPaywall.js +7 -0
  22. package/dist/esm/ui/index.js +1 -1
  23. package/dist/esm/version.js +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/store/index.d.ts +8 -0
  26. package/dist/store/index.js +10 -1
  27. package/dist/types.d.ts +32 -0
  28. package/dist/ui/RevnixBlockPaywall.js +100 -19
  29. package/dist/ui/RevnixPaywall.d.ts +6 -2
  30. package/dist/ui/RevnixPaywall.js +8 -0
  31. package/dist/ui/index.d.ts +1 -1
  32. package/dist/ui/index.js +2 -1
  33. package/dist/version.d.ts +1 -1
  34. package/dist/version.js +1 -1
  35. package/ios/RevnixStore.m +4 -0
  36. package/ios/RevnixStore.swift +29 -0
  37. package/package.json +1 -1
  38. package/src/blocks/locale.ts +7 -0
  39. package/src/blocks/selection.ts +13 -0
  40. package/src/blocks/tags.ts +38 -0
  41. package/src/blocks/types.ts +51 -2
  42. package/src/client.ts +478 -154
  43. package/src/index.ts +1 -0
  44. package/src/store/index.ts +15 -0
  45. package/src/types.ts +30 -0
  46. package/src/ui/RevnixBlockPaywall.tsx +186 -20
  47. package/src/ui/RevnixPaywall.tsx +15 -1
  48. package/src/ui/index.ts +1 -0
  49. package/src/version.ts +1 -1
@@ -115,7 +115,14 @@ function localizeBlock(block, lookup) {
115
115
  case "text":
116
116
  return { ...block, text: at("text", block.text) };
117
117
  case "button":
118
+ case "toggle":
118
119
  return { ...block, label: at("label", block.label) };
120
+ case "timer":
121
+ return {
122
+ ...block,
123
+ format: opt("format", block.format),
124
+ expiredText: opt("expiredText", block.expiredText),
125
+ };
119
126
  case "list":
120
127
  return {
121
128
  ...block,
@@ -17,6 +17,14 @@ export function selectedPackageId(packages, ...candidates) {
17
17
  }
18
18
  return packages[0]?.packageId;
19
19
  }
20
+ export function toggleSelection(block, packages, selectedId) {
21
+ const on = packages[block.onPackageIndex];
22
+ const off = packages[block.offPackageIndex];
23
+ if (on === undefined || off === undefined)
24
+ return null;
25
+ const isOn = on.packageId === selectedId;
26
+ return { on: isOn, target: (isOn ? off : on).packageId };
27
+ }
20
28
  /** The context a package-bearing card opens for itself and its subtree. */
21
29
  export function packageContext(pkg, selectedId) {
22
30
  if (pkg === undefined)
@@ -115,3 +115,34 @@ export function resolveTags(text, pkg, all = []) {
115
115
  }
116
116
  });
117
117
  }
118
+ export function formatCountdown(format, remaining) {
119
+ const pad = (n) => String(n).padStart(2, "0");
120
+ let span = Infinity;
121
+ const part = (token, unit) => {
122
+ const value = Math.floor((remaining % span) / unit);
123
+ if (format.includes(token))
124
+ span = unit;
125
+ return value;
126
+ };
127
+ const days = part("{d}", 86400);
128
+ const hours = part("{hh}", 3600);
129
+ const minutes = part("{mm}", 60);
130
+ const seconds = part("{ss}", 1);
131
+ return format
132
+ .replace(/\{d\}/g, String(days))
133
+ .replace(/\{hh\}/g, pad(hours))
134
+ .replace(/\{mm\}/g, pad(minutes))
135
+ .replace(/\{ss\}/g, pad(seconds));
136
+ }
137
+ export function timerText(block, shownAt, now) {
138
+ const deadline = block.endsAt !== undefined
139
+ ? Date.parse(block.endsAt)
140
+ : shownAt + (block.duration ?? 0) * 1000;
141
+ const remaining = Number.isNaN(deadline)
142
+ ? 0
143
+ : Math.max(0, Math.floor((deadline - now) / 1000));
144
+ if (remaining > 0) {
145
+ return formatCountdown(block.format ?? "{hh}:{mm}:{ss}", remaining);
146
+ }
147
+ return block.expiredText ?? null;
148
+ }
@@ -34,6 +34,7 @@ export function hasCloseAction(blocks) {
34
34
  : b.type === "card"
35
35
  ? b.repeat === undefined &&
36
36
  b.packageIndex === undefined &&
37
+ b.layout !== "carousel" &&
37
38
  hasCloseAction(b.children)
38
39
  : (b.type === "text" || b.type === "image" || b.type === "button") &&
39
40
  b.action === "close");