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.
- package/README.md +16 -0
- package/android/build.gradle +3 -0
- package/android/consumer-rules.pro +1 -0
- package/android/src/main/kotlin/com/revnix/reactnative/RevnixStoreModule.kt +43 -0
- package/dist/blocks/locale.js +7 -0
- package/dist/blocks/selection.d.ts +7 -1
- package/dist/blocks/selection.js +9 -0
- package/dist/blocks/tags.d.ts +3 -0
- package/dist/blocks/tags.js +33 -0
- package/dist/blocks/types.d.ts +45 -3
- package/dist/blocks/types.js +1 -0
- package/dist/client.d.ts +50 -11
- package/dist/client.js +408 -119
- package/dist/esm/blocks/locale.js +7 -0
- package/dist/esm/blocks/selection.js +8 -0
- package/dist/esm/blocks/tags.js +31 -0
- package/dist/esm/blocks/types.js +1 -0
- package/dist/esm/client.js +407 -119
- package/dist/esm/store/index.js +7 -0
- package/dist/esm/ui/RevnixBlockPaywall.js +103 -22
- package/dist/esm/ui/RevnixPaywall.js +7 -0
- package/dist/esm/ui/index.js +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/store/index.d.ts +8 -0
- package/dist/store/index.js +10 -1
- package/dist/types.d.ts +32 -0
- package/dist/ui/RevnixBlockPaywall.js +100 -19
- package/dist/ui/RevnixPaywall.d.ts +6 -2
- package/dist/ui/RevnixPaywall.js +8 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +2 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/ios/RevnixStore.m +4 -0
- package/ios/RevnixStore.swift +29 -0
- package/package.json +1 -1
- package/src/blocks/locale.ts +7 -0
- package/src/blocks/selection.ts +13 -0
- package/src/blocks/tags.ts +38 -0
- package/src/blocks/types.ts +51 -2
- package/src/client.ts +478 -154
- package/src/index.ts +1 -0
- package/src/store/index.ts +15 -0
- package/src/types.ts +30 -0
- package/src/ui/RevnixBlockPaywall.tsx +186 -20
- package/src/ui/RevnixPaywall.tsx +15 -1
- package/src/ui/index.ts +1 -0
- 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)
|
package/dist/esm/blocks/tags.js
CHANGED
|
@@ -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
|
+
}
|
package/dist/esm/blocks/types.js
CHANGED
|
@@ -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");
|