@namiml/web-sdk 1.7.0 → 1.7.2

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 (48) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/components/ContextProvider.d.ts +1 -0
  3. package/dist/components/NamiElement.d.ts +10 -1
  4. package/dist/components/PaywallScreen.d.ts +1 -0
  5. package/dist/components/TemplateComponent.d.ts +2 -1
  6. package/dist/components/containers/BackgroundContainer.d.ts +2 -0
  7. package/dist/components/containers/CarouselContainer.d.ts +2 -0
  8. package/dist/components/containers/CollapseContainer.d.ts +2 -0
  9. package/dist/components/containers/Container.d.ts +3 -1
  10. package/dist/components/containers/Content.d.ts +2 -0
  11. package/dist/components/containers/Footer.d.ts +4 -2
  12. package/dist/components/containers/Header.d.ts +4 -2
  13. package/dist/components/containers/ProductContainer.d.ts +2 -0
  14. package/dist/components/containers/ResponsiveGrid.d.ts +2 -0
  15. package/dist/components/elements/Button.d.ts +2 -0
  16. package/dist/components/elements/PlayPauseButton.d.ts +2 -0
  17. package/dist/components/elements/SegmentPicker.d.ts +2 -0
  18. package/dist/components/elements/Spacer.d.ts +2 -0
  19. package/dist/components/elements/Stack.d.ts +2 -0
  20. package/dist/components/elements/Text.d.ts +3 -0
  21. package/dist/components/elements/VolumeButton.d.ts +2 -0
  22. package/dist/components/styles/animations.d.ts +2 -0
  23. package/dist/components/utils/styles.d.ts +6 -3
  24. package/dist/nami/campaign.d.ts +14 -0
  25. package/dist/nami/flow/NamiFlow.d.ts +4 -0
  26. package/dist/nami/flow/NamiFlowManager.d.ts +3 -1
  27. package/dist/nami/namiRefs.d.ts +2 -0
  28. package/dist/nami/paywalls.d.ts +2 -0
  29. package/dist/nami/utils/resolvers/FlowLiquidResolver.d.ts +1 -0
  30. package/dist/nami/utils/resolvers/URLParamsResolver.d.ts +7 -0
  31. package/dist/nami-web.cjs +99 -23
  32. package/dist/nami-web.mjs +99 -23
  33. package/dist/nami-web.umd.js +101 -25
  34. package/dist/repositories/campaignRule.repository.d.ts +4 -2
  35. package/dist/repositories/device.repository.d.ts +4 -1
  36. package/dist/types/api.d.ts +1 -0
  37. package/dist/types/components/animation.d.ts +40 -0
  38. package/dist/types/components/index.d.ts +2 -0
  39. package/dist/types/externals/flow.d.ts +6 -0
  40. package/dist/types/externals/paywall.d.ts +1 -0
  41. package/dist/types/flow.d.ts +3 -1
  42. package/dist/types/paywall.d.ts +5 -5
  43. package/dist/utils/animations.d.ts +2 -0
  44. package/dist/utils/const.d.ts +1 -1
  45. package/dist/utils/device.d.ts +4 -0
  46. package/dist/utils/parsers.d.ts +9 -0
  47. package/dist/utils/url-params.d.ts +11 -0
  48. package/package.json +1 -1
@@ -4,10 +4,12 @@ import { NamiCampaign } from "../types/externals/campaign";
4
4
  export declare class CampaignRuleRepository {
5
5
  currentFormFactor: TDevice;
6
6
  splitPosition: number;
7
+ disableCampaignUpdates: boolean;
7
8
  static instance: CampaignRuleRepository;
8
- constructor(cFormFactor: TDevice);
9
+ constructor();
10
+ configure(formFactor: TDevice, splitPosition: number, namiCommands?: string[]): void;
9
11
  fetchCampaignRules(paywalls: IPaywall[]): Promise<NamiCampaign[]>;
10
- invokeAvailableCampaignsResponseHandler(campaigns?: NamiCampaign[]): void;
12
+ invokeAvailableCampaignsResponseHandler(): void;
11
13
  private getAnonymousCampaigns;
12
14
  private getCampaigns;
13
15
  private fallbackData;
@@ -1,7 +1,10 @@
1
1
  import { Device, DevicePayload } from "../types/device";
2
2
  export declare class DeviceRepository {
3
3
  static instance: DeviceRepository;
4
- createOrUpdateDevice(deviceData: DevicePayload): Promise<Device | null>;
4
+ createOrUpdateDevice(deviceData: DevicePayload, splitPositionUUID?: string): {
5
+ id: string;
6
+ device: Promise<Device | null>;
7
+ };
5
8
  createDevice(deviceData: DevicePayload): Promise<Device | null>;
6
9
  updateDevice(currentDeviceId: string, deviceData: DevicePayload): Promise<Device | null>;
7
10
  updateDeviceField<T>(key: string, value: T): Promise<Device | null>;
@@ -25,4 +25,5 @@ export type Impression = {
25
25
  segment?: string;
26
26
  call_to_action?: string;
27
27
  app_env?: string;
28
+ url_params?: Record<string, string>;
28
29
  };
@@ -0,0 +1,40 @@
1
+ export declare const NamiAnimationType: {
2
+ readonly Wave: "wave";
3
+ readonly Pulse: "pulse";
4
+ readonly None: "none";
5
+ };
6
+ export type NamiAnimationType = typeof NamiAnimationType[keyof typeof NamiAnimationType];
7
+ export type PulseSpec = typeof NamiAnimationType.Pulse | {
8
+ type: typeof NamiAnimationType.Pulse;
9
+ duration?: number;
10
+ scale?: number;
11
+ };
12
+ export type WaveSpec = typeof NamiAnimationType.Wave | {
13
+ type: typeof NamiAnimationType.Wave;
14
+ duration?: number;
15
+ delay?: number;
16
+ circle1Color?: string;
17
+ circle2Color?: string;
18
+ lineWidth?: number;
19
+ };
20
+ export type NoneSpec = typeof NamiAnimationType.None | {
21
+ type: typeof NamiAnimationType.None;
22
+ };
23
+ export type NamiAnimationSpec = WaveSpec | PulseSpec | NoneSpec;
24
+ export type NamiAnimationObjectSpec = Extract<WaveSpec, {
25
+ type: typeof NamiAnimationType.Wave;
26
+ }> | Extract<PulseSpec, {
27
+ type: typeof NamiAnimationType.Pulse;
28
+ }> | Extract<NoneSpec, {
29
+ type: typeof NamiAnimationType.None;
30
+ }>;
31
+ export type Wave = Required<Extract<WaveSpec, {
32
+ type: typeof NamiAnimationType.Wave;
33
+ }>>;
34
+ export type Pulse = Required<Extract<PulseSpec, {
35
+ type: typeof NamiAnimationType.Pulse;
36
+ }>>;
37
+ export type None = Required<Extract<NoneSpec, {
38
+ type: typeof NamiAnimationType.None;
39
+ }>>;
40
+ export type NamiAnimation = Wave | Pulse | None;
@@ -1,3 +1,4 @@
1
+ import { NamiAnimationSpec } from "./animation";
1
2
  import { TButtonContainer, TCarouselContainer, TCarouselSlide, TCollapseContainer, TFlexProductContainer, TPlayPauseButton, TProductContainer, TRadioButton, TResponsiveGrid, TStack, TToggleSwitch, TVolumeButton, UserAction } from "./containers";
2
3
  import { TConditionalComponent, TImageComponent, TQRCodeComponent, TSegmentPicker, TSegmentPickerItem, TSpacerComponent, TSvgImageComponent, TSymbolComponent, TTextComponent, TTextListComponent, TVideoComponent } from "./elements";
3
4
  export interface TBaseComponent {
@@ -68,6 +69,7 @@ export interface TBaseComponent {
68
69
  fixedHeight?: number;
69
70
  fixedWidth?: number | "fitContent";
70
71
  hidden?: boolean;
72
+ animation?: NamiAnimationSpec;
71
73
  }
72
74
  export type TComponent = TButtonContainer | TContainer | TTextListComponent | TTextComponent | TSpacerComponent | TImageComponent | TSvgImageComponent | TSymbolComponent | TCarouselContainer | TProductContainer | TFlexProductContainer | TStack | TConditionalComponent | TSegmentPicker | TSegmentPickerItem | TVideoComponent | TCollapseContainer | TResponsiveGrid | TVolumeButton | TPlayPauseButton | TQRCodeComponent | TToggleSwitch | TRadioButton;
73
75
  export type DirectionType = "vertical" | "horizontal";
@@ -36,6 +36,12 @@ export declare const NamiFlowManager: {
36
36
  * This can be used to end the flow at any point, typically after a handoff or custom logic.
37
37
  */
38
38
  finish: any;
39
+ /**
40
+ * Pauses the current flow.
41
+ *
42
+ * This can be used to temporarily halt the flow, typically in response to user input or other events.
43
+ */
44
+ pause: any;
39
45
  /**
40
46
  * Checks if a flow is currently open.
41
47
  *
@@ -1,5 +1,6 @@
1
1
  import { NamiPurchase } from "./purchase";
2
2
  import { NamiSKU } from "./sku";
3
+ export { PaywallManagerEvents as NamiPaywallManagerEvents } from '../paywall';
3
4
  /**
4
5
  * @enum NamiPaywallAction
5
6
  * Types of actions paywall will have
@@ -22,7 +22,9 @@ export declare enum NamiFlowActionFunction {
22
22
  FLOW_EVENT = "flowEvent",
23
23
  BLOCK_BACK = "blockBackToStep",
24
24
  FLOW_ENABLED = "flowInteractionEnabled",
25
- FLOW_DISABLED = "flowInteractionDisabled"
25
+ FLOW_DISABLED = "flowInteractionDisabled",
26
+ PAUSE = "flowPause",
27
+ RESUME = "flowResume"
26
28
  }
27
29
  export type NamiFlowHandoffStepHandler = (handoffTag: string, handoffData?: Record<string, any>) => void;
28
30
  export type NamiFlowEventHandler = (eventHandler: Record<string, any>) => void;
@@ -164,11 +164,11 @@ export type TOffer = {
164
164
  promoEligible: boolean;
165
165
  };
166
166
  export declare enum PaywallManagerEvents {
167
- REGISTER_BUY_SKU = "RegisterBuySKU",
168
- PAYWALL_CLOSE_REQUESTED = "PaywallCloseRequested",
169
- PAYWALL_SIGNIN_REQUESTED = "PaywallSignInRequested",
170
- PAYWALL_RESTORE_REQUESTED = "PaywallRestoreRequested",
171
- PAYWALL_DEEPLINK_ACTION = "PaywallDeeplinkAction"
167
+ BuySku = "RegisterBuySKU",
168
+ Close = "PaywallCloseRequested",
169
+ SignIn = "PaywallSignInRequested",
170
+ Restore = "PaywallRestoreRequested",
171
+ DeeplinkAction = "PaywallDeeplinkAction"
172
172
  }
173
173
  export type PaywallActionEvent = {
174
174
  action: NamiPaywallAction;
@@ -0,0 +1,2 @@
1
+ import { NamiAnimationSpec, NamiAnimation } from "../types/components/animation";
2
+ export declare function toNamiAnimation(spec: NamiAnimationSpec): NamiAnimation;
@@ -1 +1 @@
1
- export declare const NAMI_SDK_VERSION: string, PRODUCTION: string, DEVELOPMENT: string, PLATFORM_ID_REQUIRED: string, DEVICE_ID_REQUIRED: string, EXTERNAL_ID_REQUIRED: string, SDK_NOT_INITIALIZED: string, CAMPAIGN_NOT_AVAILABLE: string, FLOW_SCREENS_NOT_AVAILABLE: string, UNABLE_TO_UPDATE_CDP_ID: string, ANONYMOUS_MODE_ALREADY_ON: string, ANONYMOUS_MODE_ALREADY_OFF: string, ANONYMOUS_MODE_LOGIN_NOT_ALLOWED: string, SESSION_REQUIRED: string, DEVICE_ID_NOT_SET: string, AUTH_DEVICE: string, NAMI_CONFIGURATION: string, NAMI_PROFILE: string, API_CONFIG: string, API_CAMPAIGN_RULES: string, API_PAYWALLS: string, API_PRODUCTS: string, API_ACTIVE_ENTITLEMENTS: string, SERVER_NAMI_ENTITLEMENTS: string, INITIAL_APP_CONFIG: string, INITIAL_CAMPAIGN_RULES: string, INITIAL_PAYWALLS: string, INITIAL_PRODUCTS: string, LOCAL_NAMI_ENTITLEMENTS: string, CUSTOMER_ATTRIBUTES_KEY_PREFIX: string, NAMI_CUSTOMER_JOURNEY_STATE: string, ANONYMOUS_MODE: string, ANONYMOUS_UUID: string, KEY_SESSION_COUNTER: string, INITIAL_SESSION_COUNTER_VALUE: number, NAMI_LAST_IMPRESSION_ID: string, NAMI_PURCHASE_IMPRESSION_ID: string, NAMI_SESSION_ID: string, NAMI_LANGUAGE_CODE: string, NAMI_PURCHASE_CHANNEL: string, API_VERSION: any, BASE_URL_PATH: string, BASE_URL: string, BASE_STAGING_URL: string, CUSTOM_HOST_PREFIX: string, USE_STAGING_API: string, EXTENDED_CLIENT_INFO_PREFIX: string, EXTENDED_CLIENT_INFO_DELIMITER: string, VALIDATE_PRODUCT_GROUPS: string, EXTENDED_PLATFORM: string, EXTENDED_PLATFORM_VERSION: string, API_MAX_CALLS_LIMIT: number, API_RETRY_DELAY_SEC: number, API_TIMEOUT_LIMIT: number, DEVICE_API_TIMEOUT_LIMIT: number, STATUS_SUCCESS: number, STATUS_BAD_REQUEST: number, STATUS_NOT_FOUND: number, STATUS_CONFLICT: number, STATUS_INTERNAL_SERVER_ERROR: number, INITIAL_SUCCESS: string, RECONFIG_SUCCESS: string, ALREADY_CONFIGURED: string, AVAILABLE_CAMPAIGNS_CHANGED: string, PAYWALL_ACTION_EVENT: string, AVAILABLE_ACTIVE_ENTITLEMENTS_CHANGED: string, CUSTOMER_JOURNEY_STATE_CHANGED: string, SKU_TEXT_REGEX: RegExp, VAR_REGEX: RegExp, HTML_REGEX: RegExp, SMART_TEXT_PATTERN: string, CORS_PROXY_URL: string, CORS_PROXY_URL_LOCAL: string;
1
+ export declare const NAMI_SDK_VERSION: string, PRODUCTION: string, DEVELOPMENT: string, PLATFORM_ID_REQUIRED: string, DEVICE_ID_REQUIRED: string, EXTERNAL_ID_REQUIRED: string, SDK_NOT_INITIALIZED: string, CAMPAIGN_NOT_AVAILABLE: string, FLOW_SCREENS_NOT_AVAILABLE: string, UNABLE_TO_UPDATE_CDP_ID: string, ANONYMOUS_MODE_ALREADY_ON: string, ANONYMOUS_MODE_ALREADY_OFF: string, ANONYMOUS_MODE_LOGIN_NOT_ALLOWED: string, SESSION_REQUIRED: string, DEVICE_ID_NOT_SET: string, AUTH_DEVICE: string, NAMI_CONFIGURATION: string, NAMI_PROFILE: string, API_CONFIG: string, API_CAMPAIGN_RULES: string, API_PAYWALLS: string, API_PRODUCTS: string, API_ACTIVE_ENTITLEMENTS: string, SERVER_NAMI_ENTITLEMENTS: string, INITIAL_APP_CONFIG: string, INITIAL_CAMPAIGN_RULES: string, INITIAL_PAYWALLS: string, INITIAL_PRODUCTS: string, LOCAL_NAMI_ENTITLEMENTS: string, CUSTOMER_ATTRIBUTES_KEY_PREFIX: string, NAMI_CUSTOMER_JOURNEY_STATE: string, ANONYMOUS_MODE: string, ANONYMOUS_UUID: string, KEY_SESSION_COUNTER: string, INITIAL_SESSION_COUNTER_VALUE: number, NAMI_LAST_IMPRESSION_ID: string, NAMI_PURCHASE_IMPRESSION_ID: string, NAMI_SESSION_ID: string, NAMI_LANGUAGE_CODE: string, NAMI_PURCHASE_CHANNEL: string, API_VERSION: any, BASE_URL_PATH: string, BASE_URL: string, BASE_STAGING_URL: string, CUSTOM_HOST_PREFIX: string, USE_STAGING_API: string, EXTENDED_CLIENT_INFO_PREFIX: string, EXTENDED_CLIENT_INFO_DELIMITER: string, VALIDATE_PRODUCT_GROUPS: string, EXTENDED_PLATFORM: string, EXTENDED_PLATFORM_VERSION: string, API_MAX_CALLS_LIMIT: number, API_RETRY_DELAY_SEC: number, API_TIMEOUT_LIMIT: number, DEVICE_API_TIMEOUT_LIMIT: number, STATUS_SUCCESS: number, STATUS_BAD_REQUEST: number, STATUS_NOT_FOUND: number, STATUS_CONFLICT: number, STATUS_INTERNAL_SERVER_ERROR: number, INITIAL_SUCCESS: string, RECONFIG_SUCCESS: string, ALREADY_CONFIGURED: string, AVAILABLE_CAMPAIGNS_CHANGED: string, PAYWALL_ACTION_EVENT: string, AVAILABLE_ACTIVE_ENTITLEMENTS_CHANGED: string, CUSTOMER_JOURNEY_STATE_CHANGED: string, SKU_TEXT_REGEX: RegExp, VAR_REGEX: RegExp, HTML_REGEX: RegExp, SMART_TEXT_PATTERN: string;
@@ -4,3 +4,7 @@ export declare const getDeviceFormFactor: () => TDevice;
4
4
  export declare function getDeviceScaleFactor(formFactor?: string): number;
5
5
  export declare function generateUUID(): string;
6
6
  export declare function audienceSplitPosition(uuid: string): number;
7
+ export declare function bigintToUuid(v: bigint): string;
8
+ export declare function randomBigInt(n: bigint): bigint;
9
+ export declare function generateUuidForSplitPosition(targetPercent: number, tolerancePercent?: number): string;
10
+ export declare function uuidFromSplitPosition(namiCommands?: string[]): string | undefined;
@@ -0,0 +1,9 @@
1
+ export type TSemverObj = {
2
+ semver: string | undefined;
3
+ major: number;
4
+ minor: number;
5
+ patch: number;
6
+ prerelease: string;
7
+ buildmetadata: string;
8
+ };
9
+ export declare function parseToSemver(versionString: string): TSemverObj;
@@ -0,0 +1,11 @@
1
+ export declare class URLParams {
2
+ private static _instance;
3
+ params: Record<string, string>;
4
+ constructor();
5
+ static get instance(): URLParams;
6
+ static refresh(): void;
7
+ private setSearchParams;
8
+ private safeValue;
9
+ private extractSafeParams;
10
+ }
11
+ export declare const getUrlParams: () => Record<string, string>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@namiml/web-sdk",
3
3
  "type": "module",
4
- "version": "1.7.0",
4
+ "version": "1.7.2",
5
5
  "source": "src/nami-web.ts",
6
6
  "description": "Nami Web SDK makes subscriptions & in-app purchases easy, with powerful built-in paywalls and A/B testing",
7
7
  "scripts": {