@developer_tribe/react-builder 1.2.27 → 1.2.29
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/dist/assets/samples/getSamples.d.ts +0 -3
- package/dist/build-components/BIcon/BIconProps.generated.d.ts +1 -2
- package/dist/build-components/CountDown/CountDownProps.generated.d.ts +2 -1
- package/dist/build-components/OnboardFooter/OnboardFooterProps.generated.d.ts +1 -2
- package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.d.ts +1 -2
- package/dist/build-components/OnboardTitle/OnboardTitleProps.generated.d.ts +1 -2
- package/dist/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.d.ts +1 -2
- package/dist/build-components/PaywallOptions/usePaywallOptionParamsFactory.d.ts +1 -1
- package/dist/build-components/PriceTag/PriceTag.d.ts +5 -0
- package/dist/build-components/PriceTag/PriceTagProps.generated.d.ts +63 -0
- package/dist/build-components/Pricing/Pricing.d.ts +5 -0
- package/dist/build-components/Pricing/PricingProps.generated.d.ts +59 -0
- package/dist/build-components/Promo/Promo.d.ts +5 -0
- package/dist/build-components/Promo/PromoProps.generated.d.ts +59 -0
- package/dist/build-components/Text/TextProps.generated.d.ts +1 -2
- package/dist/build-components/index.d.ts +4 -1
- package/dist/build-components/patterns.generated.d.ts +1405 -202
- package/dist/components/BuilderProvider.d.ts +5 -3
- package/dist/components/ParamsProvider.d.ts +16 -8
- package/dist/hooks/useSyncHtmlThemeClass.d.ts +1 -1
- package/dist/index.cjs.js +4 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +16 -3
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.web.cjs.js +4 -4
- package/dist/index.web.cjs.js.map +1 -1
- package/dist/index.web.esm.js +4 -4
- package/dist/index.web.esm.js.map +1 -1
- package/dist/logger.d.ts +18 -0
- package/dist/modals/InspectModal.d.ts +5 -0
- package/dist/modals/index.d.ts +1 -1
- package/dist/pages/ProjectPage.d.ts +3 -3
- package/dist/paywall/hooks/useCalculateLocalizedPrice.d.ts +4 -2
- package/dist/paywall/hooks/useDiscountRate.d.ts +3 -2
- package/dist/paywall/types/paywall-types.d.ts +7 -32
- package/dist/product-base/buildPaywallLocalizationParams.d.ts +16 -0
- package/dist/product-base/calculations.d.ts +29 -0
- package/dist/product-base/extractAndroidParams.d.ts +24 -0
- package/dist/product-base/extractIOSParams.d.ts +24 -0
- package/dist/product-base/index.d.ts +51 -0
- package/dist/product-base/periodLocalizationKeys.d.ts +44 -0
- package/dist/product-base/types.d.ts +155 -0
- package/dist/product-base/usePaywallLocalizationParams.d.ts +29 -0
- package/dist/store.d.ts +7 -1
- package/dist/styles.css +1 -1
- package/dist/types/PreviewConfig.d.ts +10 -16
- package/dist/utils/extractTextStyle/extractTextStyle.d.ts +2 -2
- package/dist/utils/extractTextStyle/extractTextStyleNative.d.ts +2 -2
- package/dist/utils/replaceLocalizationParams.d.ts +1 -1
- package/package.json +2 -2
- package/scripts/migrate-samples-to-current.ts +3 -3
- package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +28 -12
- package/src/DeviceMockFrame.tsx +15 -10
- package/src/assets/meta.json +1 -1
- package/src/assets/samples/carousel-sample.json +6 -5
- package/src/assets/samples/getSamples.ts +16 -49
- package/src/assets/samples/paywall-1.json +64 -22
- package/src/assets/samples/paywall-2.json +0 -15
- package/src/assets/samples/paywall-app-delete-offer.json +0 -15
- package/src/assets/samples/paywall-app-open-offer.json +0 -15
- package/src/assets/samples/paywall-back-offer.json +0 -15
- package/src/assets/samples/paywall-notification-offer.json +0 -15
- package/src/assets/samples/simple-1.json +1 -16
- package/src/assets/samples/simple-2.json +0 -15
- package/src/assets/samples/unmigrated-builder-1.1.1.json +0 -3
- package/src/assets/samples/unmigrated-builder1.json +0 -3
- package/src/assets/samples/unvalidated-builder1.json +0 -3
- package/src/assets/samples/unvalidated-crash1.json +0 -3
- package/src/assets/samples/unvalidated-crashcomponent1.json +0 -3
- package/src/assets/samples/vpn-onboard-1.json +1 -34
- package/src/assets/samples/vpn-onboard-2.json +1 -34
- package/src/assets/samples/vpn-onboard-3.json +1 -42
- package/src/assets/samples/vpn-onboard-4.json +0 -73
- package/src/assets/samples/vpn-onboard-5.json +0 -73
- package/src/assets/samples/vpn-onboard-6.json +0 -73
- package/src/assets/samples/vpn-onboard-7.json +529 -0
- package/src/attribute-analyser/style/native/useExtractImageStyle.ts +1 -4
- package/src/attribute-analyser/style/native/useExtractTextStyle.ts +3 -12
- package/src/attribute-analyser/style/native/useExtractViewStyle.ts +1 -4
- package/src/attribute-analyser/style/web/useExtractImageStyle.ts +1 -4
- package/src/attribute-analyser/style/web/useExtractTextStyle.ts +3 -12
- package/src/attribute-analyser/style/web/useExtractViewStyle.ts +1 -4
- package/src/attributes-editor/useAttributesEditorModel.ts +5 -52
- package/src/build-components/BIcon/BIconProps.generated.ts +1 -2
- package/src/build-components/CarouselDots/CarouselDots.tsx +6 -13
- package/src/build-components/CountDown/CountDownProps.generated.ts +2 -1
- package/src/build-components/NavigationBarColor/NavigationBarColor.tsx +2 -2
- package/src/build-components/OnboardButton/OnboardButton.tsx +1 -2
- package/src/build-components/OnboardDot/OnboardDot.tsx +6 -18
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +5 -3
- package/src/build-components/OnboardFooter/OnboardFooterProps.generated.ts +1 -2
- package/src/build-components/OnboardFooter/pattern.json +1 -1
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.generated.ts +1 -2
- package/src/build-components/OnboardTitle/OnboardTitleProps.generated.ts +1 -2
- package/src/build-components/PaywallCloseButton/PaywallCloseButtonProps.generated.ts +1 -2
- package/src/build-components/PaywallOptions/PaywallOptions.tsx +3 -3
- package/src/build-components/PaywallOptions/usePaywallOptionParamsFactory.ts +26 -13
- package/src/build-components/PaywallProvider/PaywallProvider.tsx +51 -12
- package/src/build-components/PriceTag/PriceTag.tsx +25 -0
- package/src/build-components/PriceTag/PriceTagProps.generated.ts +83 -0
- package/src/build-components/PriceTag/pattern.json +53 -0
- package/src/build-components/Pricing/Pricing.tsx +13 -0
- package/src/build-components/Pricing/PricingProps.generated.ts +76 -0
- package/src/build-components/Pricing/pattern.json +25 -0
- package/src/build-components/Promo/Promo.tsx +13 -0
- package/src/build-components/Promo/PromoProps.generated.ts +76 -0
- package/src/build-components/Promo/pattern.json +25 -0
- package/src/build-components/RadioButton/RadioButton.tsx +3 -5
- package/src/build-components/RenderNode.generated.tsx +15 -0
- package/src/build-components/StatusBarColor/StatusBarColor.tsx +2 -2
- package/src/build-components/Text/Text.tsx +12 -5
- package/src/build-components/Text/TextProps.generated.ts +1 -2
- package/src/build-components/Text/pattern.json +3 -2
- package/src/build-components/index.ts +15 -0
- package/src/build-components/patterns.generated.ts +1454 -181
- package/src/components/BottomBar.tsx +42 -39
- package/src/components/BuilderProvider.tsx +41 -14
- package/src/components/LocalizationParamsProvider.tsx +1 -1
- package/src/components/ParamsProvider.tsx +36 -11
- package/src/hooks/useLocalize.ts +7 -4
- package/src/hooks/useParams.ts +1 -1
- package/src/hooks/useSyncHtmlThemeClass.ts +2 -2
- package/src/index.ts +54 -8
- package/src/logger.ts +39 -0
- package/src/modals/InspectModal.tsx +331 -0
- package/src/modals/ProductPresetsModal.tsx +7 -14
- package/src/modals/index.ts +1 -1
- package/src/pages/DebugJsonPage.tsx +9 -22
- package/src/pages/ProjectDebug.tsx +1 -1
- package/src/pages/ProjectPage.tsx +29 -11
- package/src/pages/tabs/SideTool.tsx +28 -104
- package/src/paywall/hooks/useCalculateLocalizedPrice.ts +8 -3
- package/src/paywall/hooks/useDiscountRate.ts +11 -3
- package/src/paywall/types/paywall-types.ts +7 -38
- package/src/product-base/buildPaywallLocalizationParams.ts +100 -0
- package/src/product-base/calculations.ts +93 -0
- package/src/product-base/extractAndroidParams.ts +207 -0
- package/src/product-base/extractIOSParams.ts +199 -0
- package/src/product-base/index.ts +64 -0
- package/src/product-base/mockProducts.json +489 -0
- package/src/product-base/periodLocalizationKeys.ts +114 -0
- package/src/product-base/types.ts +183 -0
- package/src/product-base/usePaywallLocalizationParams.ts +61 -0
- package/src/store.ts +18 -1
- package/src/styles/index.scss +1 -0
- package/src/styles/modals/_inspect-modal.scss +155 -0
- package/src/types/PreviewConfig.ts +157 -16
- package/src/utils/extractTextStyle/extractTextStyle.ts +14 -6
- package/src/utils/extractTextStyle/extractTextStyleNative.ts +8 -6
- package/src/utils/logRenderStore.ts +6 -10
- package/src/utils/parseColor.ts +0 -1
- package/src/utils/replaceLocalizationParams.ts +8 -4
- package/dist/modals/ScreenColorsModal.d.ts +0 -8
- package/src/assets/products.json +0 -98
- package/src/modals/ScreenColorsModal.tsx +0 -121
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IAP logger shim — delegates to console.
|
|
3
|
+
*
|
|
4
|
+
* The core project replaces this with a richer logger (Bugsnag remote, etc.).
|
|
5
|
+
* This minimal version keeps product-base compilable in the builder context.
|
|
6
|
+
*/
|
|
7
|
+
type LogPayload = Record<string, unknown>;
|
|
8
|
+
type LogOptions = {
|
|
9
|
+
remote?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare function noop(): void;
|
|
12
|
+
export declare const iapLogger: {
|
|
13
|
+
error(_tags: string[], message: string, payload?: LogPayload, _opts?: LogOptions): void;
|
|
14
|
+
warn(_tags: string[], message: string, payload?: LogPayload, _opts?: LogOptions): void;
|
|
15
|
+
info(_tags: string[], message: string, payload?: LogPayload, _opts?: LogOptions): void;
|
|
16
|
+
debug: typeof noop;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
package/dist/modals/index.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ export { DeviceSelectorModal } from './DeviceSelectorModal';
|
|
|
4
4
|
export { ColorModal } from './ColorModal';
|
|
5
5
|
export { IconPickerModal } from './IconPickerModal';
|
|
6
6
|
export { LocalicationModal } from './LocalicationModal';
|
|
7
|
-
export { ScreenColorsModal } from './ScreenColorsModal';
|
|
8
7
|
export { MockableFeatureModal } from './MockableFeatureModal';
|
|
9
8
|
export { ProductEditModal } from './ProductEditModal';
|
|
10
9
|
export { ProductPresetsModal } from './ProductPresetsModal';
|
|
11
10
|
export { BenefitEditModal } from './BenefitEditModal';
|
|
12
11
|
export { BenefitPresetsModal } from './BenefitPresetsModal';
|
|
12
|
+
export { InspectModal } from './InspectModal';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Project, ProjectColors, ProjectMeta } from '../types/Project';
|
|
2
|
-
import {
|
|
2
|
+
import { type Localication } from '../types/PreviewConfig';
|
|
3
3
|
import type { LogLevel } from '../types/Project';
|
|
4
4
|
import type { Fonts } from '../types/Fonts';
|
|
5
5
|
export type ProjectPageProps = {
|
|
6
6
|
project: Project;
|
|
7
7
|
onSaveProject: (project: ProjectMeta) => void;
|
|
8
|
-
|
|
8
|
+
localization?: Localication;
|
|
9
9
|
logLevel?: LogLevel;
|
|
10
10
|
projectColors?: ProjectColors;
|
|
11
11
|
onSaveProjectColors?: (colors: ProjectColors) => void;
|
|
@@ -20,4 +20,4 @@ export type ProjectPageProps = {
|
|
|
20
20
|
*/
|
|
21
21
|
appFont?: string | undefined;
|
|
22
22
|
};
|
|
23
|
-
export declare function ProjectPage({ project,
|
|
23
|
+
export declare function ProjectPage({ project, localization, onSaveProject, logLevel, projectColors, onSaveProjectColors, name, typography, appFont, }: ProjectPageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Extracts a numeric price string from a localized/formatted price.
|
|
3
|
+
* @param formattedPrice e.g. "$9.99", "€4,99"
|
|
4
|
+
* @returns Numeric string e.g. "9.99", "4.99"
|
|
3
5
|
*/
|
|
4
|
-
export declare function useCalculateLocalizedPrice(): string;
|
|
6
|
+
export declare function useCalculateLocalizedPrice(formattedPrice?: string): string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Calculates the discount percentage between a regular and promo price.
|
|
3
|
+
* @returns Discount as integer (e.g. 50 for 50%), or 0 if not calculable.
|
|
3
4
|
*/
|
|
4
|
-
export declare function useDiscountRate(): number;
|
|
5
|
+
export declare function useDiscountRate(regularPrice?: string, promoPrice?: string): number;
|
|
@@ -1,43 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Paywall-related types.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Product is now re-exported from product-base (the unified type with all
|
|
5
|
+
* platform-specific fields). This keeps every consumer compatible while
|
|
6
|
+
* gaining access to subscriptionOffers, pricingPhases, introductoryPrice, etc.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
* calls like `getProducts()` / `getSubscriptions()`.
|
|
8
|
-
* See: `https://www.npmjs.com/package/react-native-iap`
|
|
8
|
+
* See: product-base/types.ts for the full definition.
|
|
9
9
|
*/
|
|
10
10
|
export type { PaywallBenefits, PaywallBenefitValue } from './benefits';
|
|
11
|
-
|
|
12
|
-
* Minimal "product" representation (compatible with `react-native-iap` product-ish objects).
|
|
13
|
-
*
|
|
14
|
-
* Note: `react-native-iap` has slightly different fields per platform/product type.
|
|
15
|
-
* This is the common subset most paywalls need.
|
|
16
|
-
*/
|
|
17
|
-
export interface Product {
|
|
18
|
-
/** iOS: `productId`, Android: `productId` */
|
|
19
|
-
productId: string;
|
|
20
|
-
/** Display name / title from the store (when available). */
|
|
21
|
-
title?: string;
|
|
22
|
-
/** Description from the store (when available). */
|
|
23
|
-
description?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Localized formatted price (e.g. "$4.99", "€9,99").
|
|
26
|
-
* In `react-native-iap` this is typically `localizedPrice`.
|
|
27
|
-
*/
|
|
28
|
-
localizedPrice?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Raw price string from the store (often numeric string).
|
|
31
|
-
* In `react-native-iap` this is typically `price`.
|
|
32
|
-
*/
|
|
33
|
-
price?: string;
|
|
34
|
-
/** Currency code (e.g. "USD", "EUR"). */
|
|
35
|
-
currency?: string;
|
|
36
|
-
}
|
|
11
|
+
export type { Product } from '../../product-base/types';
|
|
37
12
|
/**
|
|
38
13
|
* A simple paywall model you can store/serialize.
|
|
39
14
|
*/
|
|
40
15
|
export interface PaywallModel {
|
|
41
|
-
product: Product[];
|
|
16
|
+
product: import('../../product-base/types').Product[];
|
|
42
17
|
benefits: import('./benefits').PaywallBenefits;
|
|
43
18
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure function that extracts all paywall localization params from a product.
|
|
3
|
+
*
|
|
4
|
+
* Platform-agnostic: caller provides `platform` to select iOS vs Android extraction.
|
|
5
|
+
* Optionally accepts a `localize` function for period text translation.
|
|
6
|
+
*/
|
|
7
|
+
import type { Product, ProductParams } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Extracts paywall localization params from a product.
|
|
10
|
+
*
|
|
11
|
+
* @param product - The selected product (iOS or Android shape)
|
|
12
|
+
* @param platform - 'ios' | 'android' — determines which extractor runs
|
|
13
|
+
* @param offerId - Optional offer id (for promo/discount matching)
|
|
14
|
+
* @param localize - Optional function to translate period keys (falls back to identity)
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildPaywallLocalizationParams(product: Product, platform: 'ios' | 'android', offerId?: string, localize?: (key: string) => string): ProductParams;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product calculation utilities
|
|
3
|
+
* Price, discount, period calculations
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Fiyat string'inden sadece sayıları extract eder
|
|
7
|
+
* @example "$9.99" → "9.99"
|
|
8
|
+
* @example "€4,99" → "4.99"
|
|
9
|
+
*/
|
|
10
|
+
export declare function extractPrice(formattedPrice: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* İndirim yüzdesini hesaplar
|
|
13
|
+
* @returns Discount percentage as string (e.g. "50")
|
|
14
|
+
*/
|
|
15
|
+
export declare function calculateDiscount(regularPrice: string, promoPrice: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Aylık eşdeğer fiyat hesaplar
|
|
18
|
+
* @param price - Fiyat (number)
|
|
19
|
+
* @param unit - Period unit (day/week/month/year)
|
|
20
|
+
* @returns Monthly price as string (e.g. "3.33")
|
|
21
|
+
*/
|
|
22
|
+
export declare function calculatePricePerMonth(price: number, unit: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Yıllık eşdeğer fiyat hesaplar
|
|
25
|
+
* @param price - Fiyat (number)
|
|
26
|
+
* @param unit - Period unit (day/week/month/year)
|
|
27
|
+
* @returns Yearly price as string (e.g. "119.88")
|
|
28
|
+
*/
|
|
29
|
+
export declare function calculatePricePerYear(price: number, unit: string): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Product } from './types';
|
|
2
|
+
export interface AndroidParams {
|
|
3
|
+
price: string;
|
|
4
|
+
promoPrice: string;
|
|
5
|
+
currency: string;
|
|
6
|
+
localizedPrice: string;
|
|
7
|
+
period: string;
|
|
8
|
+
periodValue: string;
|
|
9
|
+
periodType: string;
|
|
10
|
+
promoPeriod: string;
|
|
11
|
+
promoCycles: string;
|
|
12
|
+
promoPeriodUnit: string;
|
|
13
|
+
hasTrial: string;
|
|
14
|
+
trialPeriod: string;
|
|
15
|
+
trialPeriodUnit: string;
|
|
16
|
+
discountPercentage: string;
|
|
17
|
+
pricePerMonth: string;
|
|
18
|
+
pricePerYear: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Android product'tan params'ları extract eder
|
|
22
|
+
* pricingPhases'den trial, promo, regular bilgilerini parse eder
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractAndroidParams(product: Product, offerId?: string): AndroidParams;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Product } from './types';
|
|
2
|
+
export interface IOSParams {
|
|
3
|
+
price: string;
|
|
4
|
+
promoPrice: string;
|
|
5
|
+
currency: string;
|
|
6
|
+
localizedPrice: string;
|
|
7
|
+
period: string;
|
|
8
|
+
periodValue: string;
|
|
9
|
+
periodType: string;
|
|
10
|
+
promoPeriod: string;
|
|
11
|
+
promoCycles: string;
|
|
12
|
+
promoPeriodUnit: string;
|
|
13
|
+
hasTrial: string;
|
|
14
|
+
trialPeriod: string;
|
|
15
|
+
trialPeriodUnit: string;
|
|
16
|
+
discountPercentage: string;
|
|
17
|
+
pricePerMonth: string;
|
|
18
|
+
pricePerYear: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* iOS product'tan params'ları extract eder
|
|
22
|
+
* introductoryPrice ve discounts'tan trial/promo bilgilerini parse eder
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractIOSParams(product: Product, offerId?: string): IOSParams;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product base — centralized product utilities for paywall.
|
|
3
|
+
*
|
|
4
|
+
* This module is the single source of truth for product extraction, calculation
|
|
5
|
+
* and localization logic. It is consumed by:
|
|
6
|
+
* - This library's own web builder (PaywallProvider, ProductPresetsModal)
|
|
7
|
+
* - The core React Native project via `@developer_tribe/react-builder` exports
|
|
8
|
+
*
|
|
9
|
+
* Everything here is RN-safe (no DOM, no SCSS, no window/document).
|
|
10
|
+
*
|
|
11
|
+
* Includes:
|
|
12
|
+
* - types.ts : Product, PricingPhase, SubscriptionOffer, IOSDiscount, etc.
|
|
13
|
+
* - calculations.ts : extractPrice, calculateDiscount, pricePerMonth/Year
|
|
14
|
+
* - periodLocalizationKeys.ts : PERIOD_LOCALIZATION_KEYS, parseBillingPeriod, convertIOSPeriodUnit
|
|
15
|
+
* - extractAndroidParams.ts : Android pricingPhases extraction (trial, promo, regular)
|
|
16
|
+
* - extractIOSParams.ts : iOS introductoryPrice/discounts extraction
|
|
17
|
+
* - buildPaywallLocalizationParams.ts : Pure function — platform injected from outside
|
|
18
|
+
* - usePaywallLocalizationParams.ts : Generic React hook — all deps via config param
|
|
19
|
+
* - mockProducts.json : Mock product data for testing (Android + iOS)
|
|
20
|
+
*/
|
|
21
|
+
export * from './types';
|
|
22
|
+
export * from './calculations';
|
|
23
|
+
export * from './periodLocalizationKeys';
|
|
24
|
+
export * from './extractAndroidParams';
|
|
25
|
+
export * from './extractIOSParams';
|
|
26
|
+
export * from './buildPaywallLocalizationParams';
|
|
27
|
+
export * from './usePaywallLocalizationParams';
|
|
28
|
+
import type { Product } from './types';
|
|
29
|
+
/** Preset map: preset key → product array. */
|
|
30
|
+
export type MockProductPresets = Record<string, Product[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a deep-copy of all mock product presets.
|
|
33
|
+
*
|
|
34
|
+
* Use this instead of importing `mockProducts.json` directly so that:
|
|
35
|
+
* 1. Consumers don't couple to a JSON file path.
|
|
36
|
+
* 2. Each call returns a fresh copy (safe to mutate).
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* import { getMockProducts } from '@developer_tribe/react-builder';
|
|
40
|
+
* const presets = getMockProducts(); // { 'preset-1': [...], ... }
|
|
41
|
+
*/
|
|
42
|
+
export declare function getMockProducts(): MockProductPresets;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the product list for a specific preset key (deep-copied).
|
|
45
|
+
* Returns an empty array if the key doesn't exist.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* import { getMockProductsByPreset } from '@developer_tribe/react-builder';
|
|
49
|
+
* const products = getMockProductsByPreset('preset-1');
|
|
50
|
+
*/
|
|
51
|
+
export declare function getMockProductsByPreset(presetKey: string): Product[];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Period localization key'leri ve utility fonksiyonları
|
|
3
|
+
* Backend'den gelen localization key'leri ile çeviri yapılır
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Period localization key'leri
|
|
7
|
+
* Backend'de bu key'ler tanımlı olmalı
|
|
8
|
+
*/
|
|
9
|
+
export declare const PERIOD_LOCALIZATION_KEYS: {
|
|
10
|
+
readonly monthly: "base.builder.paywall.period.monthly";
|
|
11
|
+
readonly annual: "base.builder.paywall.period.annual";
|
|
12
|
+
readonly weekly: "base.builder.paywall.period.weekly";
|
|
13
|
+
readonly daily: "base.builder.paywall.period.daily";
|
|
14
|
+
readonly monthlyPromo: "base.builder.paywall.period.monthlyPromo";
|
|
15
|
+
readonly annualPromo: "base.builder.paywall.period.annualPromo";
|
|
16
|
+
};
|
|
17
|
+
export declare const PAYWALL_TEXT_KEYS: {
|
|
18
|
+
readonly pricingDefault: "base.builder.paywall.pricing.default.text";
|
|
19
|
+
readonly pricingFreeTrial: "base.builder.paywall.pricing.freeTrial.text";
|
|
20
|
+
readonly pricingRegular: "base.builder.paywall.pricing.regular.text";
|
|
21
|
+
readonly promoDefault: "base.builder.paywall.promo.default.text";
|
|
22
|
+
readonly promoFreeTrial: "base.builder.paywall.promo.freeTrial.text";
|
|
23
|
+
readonly promoRegular: "base.builder.paywall.promo.regular.text";
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Period ve promo durumuna göre doğru localization key'i seçer
|
|
27
|
+
*/
|
|
28
|
+
export declare function getPeriodLocalizationKey(period: 'day' | 'week' | 'month' | 'year', hasPromo: boolean): string;
|
|
29
|
+
/**
|
|
30
|
+
* ISO 8601 billing period'u parse eder
|
|
31
|
+
* @example "P1M" → { value: 1, unit: "month" }
|
|
32
|
+
* @example "P7D" → { value: 7, unit: "day" }
|
|
33
|
+
* @example "P1Y" → { value: 1, unit: "year" }
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseBillingPeriod(iso8601: string): {
|
|
36
|
+
value: number;
|
|
37
|
+
unit: 'day' | 'week' | 'month' | 'year';
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* iOS period unit'ini normalize eder
|
|
41
|
+
* @example "DAY" → "day"
|
|
42
|
+
* @example "MONTH" → "month"
|
|
43
|
+
*/
|
|
44
|
+
export declare function convertIOSPeriodUnit(iosUnit?: string): 'day' | 'week' | 'month' | 'year';
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product types for IAP.
|
|
3
|
+
*
|
|
4
|
+
* All platform-specific fields (iOS/Android) are included.
|
|
5
|
+
*
|
|
6
|
+
* See: `https://www.npmjs.com/package/react-native-iap`
|
|
7
|
+
*/
|
|
8
|
+
/** Purchase type: subscription or one-time in-app purchase. */
|
|
9
|
+
export type PurchaseType = 'in-app' | 'subs';
|
|
10
|
+
/** Subscription offer type */
|
|
11
|
+
export type SubscriptionOfferType = 'introductory' | 'promotional';
|
|
12
|
+
/** Payment mode */
|
|
13
|
+
export type PaymentMode = 'pay-as-you-go' | 'pay-up-front' | 'free-trial';
|
|
14
|
+
/** recurrenceMode values from Google Play Billing */
|
|
15
|
+
export type RecurrenceMode = 1 | 2 | 3;
|
|
16
|
+
/** iOS subscription period unit */
|
|
17
|
+
export type IOSPeriodUnit = 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
|
|
18
|
+
/** Normalized period unit */
|
|
19
|
+
export type PeriodUnit = 'day' | 'week' | 'month' | 'year';
|
|
20
|
+
/** A single billing phase (Google Play Billing) */
|
|
21
|
+
export interface PricingPhase {
|
|
22
|
+
/** ISO 8601 duration (e.g. "P1M", "P1Y", "P7D") */
|
|
23
|
+
billingPeriod: string;
|
|
24
|
+
/** How many times this phase repeats (0 = infinite) */
|
|
25
|
+
billingCycleCount: number;
|
|
26
|
+
/** Human-readable price (e.g. "$4.99") */
|
|
27
|
+
formattedPrice: string;
|
|
28
|
+
/** Price in micros (e.g. "4990000"). "0" = free (trial) */
|
|
29
|
+
priceAmountMicros: string;
|
|
30
|
+
/** Currency code (e.g. "USD") */
|
|
31
|
+
priceCurrencyCode: string;
|
|
32
|
+
/** Recurrence mode: 1=infinite, 2=finite/promo, 3=one-time/trial */
|
|
33
|
+
recurrenceMode: RecurrenceMode;
|
|
34
|
+
}
|
|
35
|
+
/** Android raw offer details (from Google Play Billing API) */
|
|
36
|
+
export interface AndroidOfferDetails {
|
|
37
|
+
basePlanId: string;
|
|
38
|
+
offerId?: string;
|
|
39
|
+
offerToken: string;
|
|
40
|
+
offerTags: string[];
|
|
41
|
+
pricingPhases: {
|
|
42
|
+
pricingPhaseList: PricingPhase[];
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** Normalized subscription offer (cross-platform) */
|
|
46
|
+
export interface SubscriptionOffer {
|
|
47
|
+
id: string;
|
|
48
|
+
displayPrice: string;
|
|
49
|
+
price: number;
|
|
50
|
+
type: SubscriptionOfferType;
|
|
51
|
+
currency: string;
|
|
52
|
+
paymentMode?: PaymentMode;
|
|
53
|
+
periodCount?: number;
|
|
54
|
+
period?: {
|
|
55
|
+
unit: PeriodUnit;
|
|
56
|
+
value: number;
|
|
57
|
+
};
|
|
58
|
+
basePlanIdAndroid?: string;
|
|
59
|
+
offerTokenAndroid?: string;
|
|
60
|
+
offerTagsAndroid?: string[];
|
|
61
|
+
pricingPhasesAndroid?: {
|
|
62
|
+
pricingPhaseList: PricingPhase[];
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** iOS introductory price */
|
|
66
|
+
export interface IOSIntroductoryPrice {
|
|
67
|
+
price: string;
|
|
68
|
+
priceIOS?: string;
|
|
69
|
+
type: 'free_trial' | 'pay_as_you_go' | 'pay_up_front';
|
|
70
|
+
numberOfPeriods: number;
|
|
71
|
+
subscriptionPeriod?: IOSPeriodUnit;
|
|
72
|
+
subscriptionPeriodUnitIOS?: IOSPeriodUnit;
|
|
73
|
+
subscriptionPeriodNumberIOS?: number;
|
|
74
|
+
}
|
|
75
|
+
/** iOS promotional discount */
|
|
76
|
+
export interface IOSDiscount {
|
|
77
|
+
identifier: string;
|
|
78
|
+
price: string;
|
|
79
|
+
numberOfPeriods: number;
|
|
80
|
+
subscriptionPeriod: IOSPeriodUnit;
|
|
81
|
+
}
|
|
82
|
+
/** Product input coming from builder for membership initialization. */
|
|
83
|
+
export interface ProductInput {
|
|
84
|
+
store_package_id: string;
|
|
85
|
+
offer_id?: string;
|
|
86
|
+
type?: string;
|
|
87
|
+
is_consumable?: boolean;
|
|
88
|
+
}
|
|
89
|
+
/** Unified product representation for IAP */
|
|
90
|
+
export interface Product {
|
|
91
|
+
/** iOS: `productId`, Android: `id` (normalized to productId) */
|
|
92
|
+
productId: string;
|
|
93
|
+
/** Android raw id */
|
|
94
|
+
id?: string;
|
|
95
|
+
title?: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
displayName?: string;
|
|
98
|
+
displayPrice?: string;
|
|
99
|
+
localizedPrice?: string;
|
|
100
|
+
price?: string;
|
|
101
|
+
currency?: string;
|
|
102
|
+
currencyCode?: string;
|
|
103
|
+
platform?: 'android' | 'ios';
|
|
104
|
+
debugDescription?: string | null;
|
|
105
|
+
/** Offer identifier from builder (Android offer token) */
|
|
106
|
+
offerId?: string;
|
|
107
|
+
type?: PurchaseType;
|
|
108
|
+
isConsumable?: boolean;
|
|
109
|
+
nameAndroid?: string;
|
|
110
|
+
productStatusAndroid?: unknown | null;
|
|
111
|
+
oneTimePurchaseOfferDetailsAndroid?: unknown | null;
|
|
112
|
+
discountOffers?: unknown | null;
|
|
113
|
+
/** Raw Google Play offer details */
|
|
114
|
+
subscriptionOfferDetailsAndroid?: AndroidOfferDetails[];
|
|
115
|
+
/** Normalized cross-platform offers */
|
|
116
|
+
subscriptionOffers?: SubscriptionOffer[];
|
|
117
|
+
introductoryPrice?: IOSIntroductoryPrice;
|
|
118
|
+
introductoryPriceIOS?: IOSIntroductoryPrice;
|
|
119
|
+
discounts?: IOSDiscount[];
|
|
120
|
+
subscriptionPeriodUnitIOS?: IOSPeriodUnit;
|
|
121
|
+
subscriptionPeriodNumberIOS?: number;
|
|
122
|
+
}
|
|
123
|
+
/** Product params exposed as localization variables (e.g. @price, @promoPrice). */
|
|
124
|
+
export interface ProductParams {
|
|
125
|
+
price: string;
|
|
126
|
+
promoPrice: string;
|
|
127
|
+
currency: string;
|
|
128
|
+
localizedPrice: string;
|
|
129
|
+
period: string;
|
|
130
|
+
promoPeriod: string;
|
|
131
|
+
promoPeriodUnit: string;
|
|
132
|
+
hasTrial: string;
|
|
133
|
+
trialPeriod: string;
|
|
134
|
+
trialPeriodUnit: string;
|
|
135
|
+
discountPercentage: string;
|
|
136
|
+
localizedPeriod: string;
|
|
137
|
+
localizedPromoPeriod: string;
|
|
138
|
+
localizedPromoPrice: string;
|
|
139
|
+
localizedCalculatedPrice: string;
|
|
140
|
+
localizedCalculatedPeriod: string;
|
|
141
|
+
baseLocalizedPricingText: string;
|
|
142
|
+
baseLocalizedPromoText: string;
|
|
143
|
+
productTitle: string;
|
|
144
|
+
productDescription: string;
|
|
145
|
+
productCurreny: string;
|
|
146
|
+
productId: string;
|
|
147
|
+
productSelected: string;
|
|
148
|
+
}
|
|
149
|
+
/** Keys excluded from single (per-option) params — these are global/context-level. */
|
|
150
|
+
type SingleExcludedKeys = 'productId' | 'productSelected';
|
|
151
|
+
/** Per-option (single product) params — same keys as ProductParams prefixed with `single`. */
|
|
152
|
+
export type SingleProductParams = {
|
|
153
|
+
[K in keyof Omit<ProductParams, SingleExcludedKeys> as `single${Capitalize<K>}`]: ProductParams[K];
|
|
154
|
+
};
|
|
155
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic React hook for extracting paywall localization params.
|
|
3
|
+
*
|
|
4
|
+
* All runtime dependencies (platform, localize, builderProducts) are injected
|
|
5
|
+
* via the `config` parameter — no hard-coded imports to any specific project.
|
|
6
|
+
*
|
|
7
|
+
* Usage (React Native / core):
|
|
8
|
+
* usePaywallLocalizationParams(product, productId, {
|
|
9
|
+
* platform: Platform.OS,
|
|
10
|
+
* localize: (key) => localize(key),
|
|
11
|
+
* builderProducts: builder.products,
|
|
12
|
+
* })
|
|
13
|
+
*
|
|
14
|
+
* Usage (Web builder):
|
|
15
|
+
* usePaywallLocalizationParams(product, productId, {
|
|
16
|
+
* platform: device.platform,
|
|
17
|
+
* localize,
|
|
18
|
+
* })
|
|
19
|
+
*/
|
|
20
|
+
import type { Product, ProductInput, ProductParams } from './types';
|
|
21
|
+
export type PaywallLocalizationConfig = {
|
|
22
|
+
/** 'ios' | 'android' — RN: Platform.OS, Web: device.platform */
|
|
23
|
+
platform: 'ios' | 'android';
|
|
24
|
+
/** Translates a localization key to a display string. Falls back to identity. */
|
|
25
|
+
localize?: (key: string) => string;
|
|
26
|
+
/** Builder product definitions — used to resolve offer_id for a product. */
|
|
27
|
+
builderProducts?: ProductInput[];
|
|
28
|
+
};
|
|
29
|
+
export declare function usePaywallLocalizationParams(selectedProduct?: Product, selectedProductId?: string, config?: PaywallLocalizationConfig): Partial<ProductParams>;
|
package/dist/store.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Device } from './types/Device';
|
|
2
|
-
import { type AppConfig } from './types/PreviewConfig';
|
|
2
|
+
import { type AppConfig, type Theme } from './types/PreviewConfig';
|
|
3
3
|
import { Node } from './types/Node';
|
|
4
4
|
import type { LogEntry, LogLevel, ProjectColors } from './types/Project';
|
|
5
5
|
import type { Product } from './paywall/types/paywall-types';
|
|
@@ -20,6 +20,12 @@ type RenderStore = {
|
|
|
20
20
|
setAppConfig: (appConfig: AppConfig) => void;
|
|
21
21
|
projectColors?: ProjectColors;
|
|
22
22
|
setProjectColors: (projectColors?: ProjectColors) => void;
|
|
23
|
+
theme: Theme;
|
|
24
|
+
setTheme: (theme: Theme) => void;
|
|
25
|
+
defaultLanguage: string;
|
|
26
|
+
setDefaultLanguage: (lang: string) => void;
|
|
27
|
+
isRtl: boolean;
|
|
28
|
+
setIsRtl: (isRtl: boolean) => void;
|
|
23
29
|
previewMode: boolean;
|
|
24
30
|
setPreviewMode: (previewMode: boolean) => void;
|
|
25
31
|
products: Product[];
|