@adapty/capacitor 3.17.0 → 4.0.0-beta.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.
- package/Package.swift +1 -1
- package/README.md +8 -0
- package/android/build.gradle +2 -2
- package/dist/esm/adapty-instance.d.ts +7 -0
- package/dist/esm/adapty-instance.js +8 -0
- package/dist/esm/adapty-instance.js.map +1 -0
- package/dist/esm/adapty.d.ts +112 -59
- package/dist/esm/adapty.js +132 -69
- package/dist/esm/adapty.js.map +1 -1
- package/dist/esm/coders/parse-flow.d.ts +3 -0
- package/dist/esm/coders/parse-flow.js +4 -0
- package/dist/esm/coders/parse-flow.js.map +1 -0
- package/dist/esm/default-configs.js +2 -2
- package/dist/esm/default-configs.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/adapty-plugin.d.ts +31 -17
- package/dist/esm/types/adapty-plugin.js.map +1 -1
- package/dist/esm/types/configs.d.ts +12 -14
- package/dist/esm/types/configs.js.map +1 -1
- package/dist/esm/types/flow-events.d.ts +1 -0
- package/dist/esm/types/flow-events.js +2 -0
- package/dist/esm/types/flow-events.js.map +1 -0
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/types/index.js +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/inputs.d.ts +1 -1
- package/dist/esm/types/inputs.js.map +1 -1
- package/dist/esm/ui-builder/base-view-emitter.d.ts +6 -0
- package/dist/esm/ui-builder/base-view-emitter.js +12 -0
- package/dist/esm/ui-builder/base-view-emitter.js.map +1 -1
- package/dist/esm/ui-builder/create-flow-view.d.ts +14 -0
- package/dist/esm/ui-builder/create-flow-view.js +16 -0
- package/dist/esm/ui-builder/create-flow-view.js.map +1 -0
- package/dist/esm/ui-builder/create-onboarding-view.d.ts +2 -0
- package/dist/esm/ui-builder/create-onboarding-view.js +2 -0
- package/dist/esm/ui-builder/create-onboarding-view.js.map +1 -1
- package/dist/esm/ui-builder/{paywall-view-controller.d.ts → flow-view-controller.d.ts} +37 -37
- package/dist/esm/ui-builder/{paywall-view-controller.js → flow-view-controller.js} +54 -51
- package/dist/esm/ui-builder/flow-view-controller.js.map +1 -0
- package/dist/esm/ui-builder/flow-view-emitter.d.ts +38 -0
- package/dist/esm/ui-builder/flow-view-emitter.js +151 -0
- package/dist/esm/ui-builder/flow-view-emitter.js.map +1 -0
- package/dist/esm/ui-builder/index.d.ts +5 -5
- package/dist/esm/ui-builder/index.js +3 -2
- package/dist/esm/ui-builder/index.js.map +1 -1
- package/dist/esm/ui-builder/onboarding-view-controller.d.ts +7 -5
- package/dist/esm/ui-builder/onboarding-view-controller.js +7 -5
- package/dist/esm/ui-builder/onboarding-view-controller.js.map +1 -1
- package/dist/esm/ui-builder/types.d.ts +11 -358
- package/dist/esm/ui-builder/types.js +52 -22
- package/dist/esm/ui-builder/types.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/plugin.cjs.js +906 -677
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +906 -677
- package/dist/plugin.js.map +1 -1
- package/package.json +3 -5
- package/AdaptyCapacitor.podspec +0 -20
- package/dist/esm/coders/parse-paywall.d.ts +0 -3
- package/dist/esm/coders/parse-paywall.js +0 -4
- package/dist/esm/coders/parse-paywall.js.map +0 -1
- package/dist/esm/types/paywall-events.d.ts +0 -1
- package/dist/esm/types/paywall-events.js +0 -2
- package/dist/esm/types/paywall-events.js.map +0 -1
- package/dist/esm/ui-builder/create-paywall-view.d.ts +0 -25
- package/dist/esm/ui-builder/create-paywall-view.js +0 -29
- package/dist/esm/ui-builder/create-paywall-view.js.map +0 -1
- package/dist/esm/ui-builder/paywall-view-controller.js.map +0 -1
- package/dist/esm/ui-builder/paywall-view-emitter.d.ts +0 -16
- package/dist/esm/ui-builder/paywall-view-emitter.js +0 -114
- package/dist/esm/ui-builder/paywall-view-emitter.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onboarding-view-controller.js","sourceRoot":"","sources":["../../../src/ui-builder/onboarding-view-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAU5D,MAAM,CAAC,MAAM,yBAAyB,GAAoC;IACxE,wBAAwB,EAAE,eAAe,CAAC,YAAY;CACvD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,OAAO,wBAAwB;IAKnC;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,UAA4B,EAC5B,YAAoB,EACpB,SAA0C,EAAE;QAE5C,MAAM,UAAU,GAAG,IAAI,wBAAwB,CAAC,YAAY,CAAC,CAAC;QAE9D,MAAM,GAAG,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,kCAAkC,CAAC;QACrD,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;QAChD,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAE1C,MAAM,KAAK,GAAG,YAAY,CAAC,qBAAqB,EAAE,CAAC;QACnD,MAAM,kBAAkB,mCAAQ,yBAAyB,GAAK,MAAM,CAAE,CAAC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;IACI,kBAAkB;QACvB,GAAG,CAAC,IAAI,CACN,oBAAoB,EACpB,GAAG,EAAE,CAAC,iDAAiD,EACvD,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CACxB,CAAC;QAEF,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAC;YACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC1B,CAAC;IACH,CAAC;CACF","sourcesContent":["import { AdaptyError } from '@adapty/core';\n\nimport type { Adapty } from '../adapty';\nimport { coderFactory } from '../coders/factory';\nimport { LogContext, Log } from '../logger';\nimport { WebPresentation } from '../types';\nimport type { AdaptyOnboarding } from '../types';\nimport type { components } from '../types/api';\nimport { mapValues, withErrorContext } from '../utils';\n\nimport { OnboardingViewEmitter } from './onboarding-view-emitter';\nimport { DEFAULT_ONBOARDING_EVENT_HANDLERS } from './types';\nimport type {\n AdaptyUiView,\n OnboardingEventHandlers,\n AdaptyIOSPresentationStyle,\n CreateOnboardingViewParamsInput,\n} from './types';\n\ntype Req = components['requests'];\n\nexport const DEFAULT_ONBOARDING_PARAMS: CreateOnboardingViewParamsInput = {\n externalUrlsPresentation: WebPresentation.BrowserInApp,\n};\n\n/**\n * Controller for managing onboarding views.\n *\n * @remarks\n * This class provides methods to present, dismiss, and handle events for onboarding views\n * created with the Onboarding Builder. Create instances using the {@link createOnboardingView} function\n * rather than directly constructing this class.\n *\n * @public\n */\nexport class OnboardingViewController {\n private id: string | null = null;\n private adaptyPlugin: Adapty;\n private viewEmitter: OnboardingViewEmitter | null = null;\n\n /**\n * Intended way to create a OnboardingViewController instance.\n * It prepares a native controller to be presented\n * and creates reference between native controller and JS instance\n * @internal\n */\n static async create(\n onboarding: AdaptyOnboarding,\n adaptyPlugin: Adapty,\n params: CreateOnboardingViewParamsInput = {},\n ): Promise<OnboardingViewController> {\n const controller = new OnboardingViewController(adaptyPlugin);\n\n const ctx = new LogContext();\n const methodKey = 'adapty_ui_create_onboarding_view';\n const log = ctx.call({ methodName: methodKey });\n log.start(() => ({ onboarding, params }));\n\n const coder = coderFactory.createOnboardingCoder();\n const paramsWithDefaults = { ...DEFAULT_ONBOARDING_PARAMS, ...params };\n const encodedParams = coderFactory.createUiCreateOnboardingViewParamsCoder().encode(paramsWithDefaults);\n\n const data: Req['AdaptyUICreateOnboardingView.Request'] = {\n method: methodKey,\n onboarding: coder.encode(onboarding),\n ...encodedParams,\n };\n\n const result = (await controller.adaptyPlugin.handleMethodCall(\n methodKey,\n JSON.stringify(data),\n ctx,\n log,\n )) as AdaptyUiView;\n controller.id = result.id;\n\n await controller.setEventHandlers(DEFAULT_ONBOARDING_EVENT_HANDLERS);\n\n return controller;\n }\n\n /**\n * Since constructors in JS cannot be async, it is not\n * preferred to create ViewControllers in direct way.\n * Consider using @link{OnboardingViewController.create} instead\n *\n * @internal\n */\n private constructor(adaptyPlugin: Adapty) {\n this.adaptyPlugin = adaptyPlugin;\n }\n\n /**\n * Presents the onboarding view as a modal screen.\n *\n * @remarks\n * Calling `present` on an already visible onboarding view will result in an error.\n * The onboarding will be displayed with the configured presentation style on iOS.\n * On Android, the onboarding is always presented as a full-screen activity.\n *\n * @param options - Optional presentation options\n * @param options.iosPresentationStyle - iOS presentation style. Available options: `'full_screen'` (default) or `'page_sheet'`. Only affects iOS platform.\n * @returns A promise that resolves when the onboarding is presented.\n * @throws {@link AdaptyError} if the view reference is invalid or the view is already presented.\n *\n * @example\n * Present with default full-screen style\n * ```typescript\n * import { adapty, createOnboardingView } from '@adapty/capacitor';\n *\n * const onboarding = await adapty.getOnboarding({ placementId: 'YOUR_PLACEMENT_ID' });\n * const view = await createOnboardingView(onboarding);\n * await view.present();\n * ```\n *\n * @example\n * Present with page sheet style on iOS\n * ```typescript\n * await view.present({ iosPresentationStyle: 'page_sheet' });\n * ```\n */\n public async present(options: { iosPresentationStyle?: AdaptyIOSPresentationStyle } = {}): Promise<void> {\n const ctx = new LogContext();\n const methodKey = 'adapty_ui_present_onboarding_view';\n const log = ctx.call({ methodName: methodKey });\n log.start(() => ({ _id: this.id, iosPresentationStyle: options.iosPresentationStyle }));\n\n if (this.id === null) {\n throw new AdaptyError({ adaptyCode: 2002, message: 'No view reference' });\n }\n\n const data: any = {\n method: methodKey,\n id: this.id,\n ios_presentation_style: options.iosPresentationStyle ?? 'full_screen',\n };\n\n await this.adaptyPlugin.handleMethodCall(methodKey, JSON.stringify(data), ctx, log);\n }\n\n /**\n * Dismisses the onboarding view.\n *\n * @remarks\n * This method closes the onboarding and cleans up associated resources.\n * After dismissing, the view controller instance cannot be reused.\n *\n * @returns A promise that resolves when the onboarding is dismissed.\n * @throws {@link AdaptyError} if the view reference is invalid.\n *\n * @example\n * ```typescript\n * import { createOnboardingView } from '@adapty/capacitor';\n *\n * const view = await createOnboardingView(onboarding);\n * await view.present();\n * // ... later\n * await view.dismiss();\n * ```\n */\n public async dismiss(): Promise<void> {\n const ctx = new LogContext();\n const methodKey = 'adapty_ui_dismiss_onboarding_view';\n const log = ctx.call({ methodName: methodKey });\n log.start(() => ({ _id: this.id }));\n\n if (this.id === null) {\n throw new AdaptyError({ adaptyCode: 2002, message: 'No view reference' });\n }\n\n const data: Req['AdaptyUIDismissOnboardingView.Request'] = {\n method: methodKey,\n id: this.id,\n destroy: true,\n };\n\n await this.adaptyPlugin.handleMethodCall(methodKey, JSON.stringify(data), ctx, log);\n this.clearEventHandlers();\n }\n\n private onRequestClose = async () => {\n try {\n await this.dismiss();\n } catch (error) {\n Log.warn(\n 'setEventHandlers',\n () => 'Failed to dismiss onboarding',\n () => ({ error }),\n );\n }\n };\n\n /**\n * Registers event handlers for onboarding UI events.\n *\n * @remarks\n * Each event type can have only one handler — new handlers replace existing ones.\n * Default handlers are registered automatically in {@link createOnboardingView} and provide standard closing behavior:\n * - `onClose` - closes the onboarding when the close button is pressed or system back is used\n *\n * If you want to override the `onClose` listener, we strongly recommend returning `true`\n * from your custom listener to retain default closing behavior.\n *\n * Calling this method multiple times will replace previously registered handlers for provided events.\n *\n * @see {@link https://adapty.io/docs/capacitor-handling-onboarding-events | Handling Onboarding Events}\n *\n * @param eventHandlers - Set of event handling callbacks. Only provided handlers will be registered or updated.\n * @returns A promise that resolves to an unsubscribe function that removes all registered listeners.\n *\n * @example\n * Register custom event handlers\n * ```typescript\n * import { createOnboardingView } from '@adapty/capacitor';\n *\n * const view = await createOnboardingView(onboarding);\n *\n * const unsubscribe = await view.setEventHandlers({\n * onClose: () => {\n * console.log('Onboarding closed');\n * // Return true to keep default closing behavior\n * return true;\n * },\n * onActionPerformed: (action) => {\n * console.log('Action performed:', action.name);\n * },\n * onProductSelected: (product) => {\n * console.log('Product selected:', product.vendorProductId);\n * }\n * });\n *\n * await view.present();\n *\n * // Later, unsubscribe all handlers\n * unsubscribe();\n * ```\n */\n public async setEventHandlers(eventHandlers: Partial<OnboardingEventHandlers> = {}): Promise<() => void> {\n const ctx = new LogContext();\n const log = ctx.call({ methodName: 'setEventHandlers' });\n log.start(() => ({ _id: this.id }));\n\n if (this.id === null) {\n throw new AdaptyError({ adaptyCode: 2002, message: 'No view reference' });\n }\n\n Log.verbose(\n 'setEventHandlers',\n () => 'Registering onboarding event handlers for view',\n () => ({ id: this.id }),\n );\n\n const viewEmitter = this.viewEmitter ?? new OnboardingViewEmitter(this.id);\n this.viewEmitter = viewEmitter;\n\n const wrappedErrorLogEventHandlers = mapValues(eventHandlers, (handler, eventName) =>\n handler && typeof handler === 'function'\n ? withErrorContext(handler, eventName as string, 'OnboardingViewController')\n : undefined,\n );\n\n // Merge with defaults to ensure default behavior is preserved after unsubscribe/resubscribe cycles\n const finalEventHandlers: Partial<OnboardingEventHandlers> = {\n ...DEFAULT_ONBOARDING_EVENT_HANDLERS,\n ...wrappedErrorLogEventHandlers,\n };\n\n for (const [eventName, handler] of Object.entries(finalEventHandlers)) {\n if (handler && typeof handler === 'function') {\n try {\n await viewEmitter.addListener(eventName as keyof OnboardingEventHandlers, handler, this.onRequestClose);\n Log.verbose(\n 'setEventHandlers',\n () => 'Registered onboarding handler',\n () => ({ eventName }),\n );\n } catch (error) {\n Log.error(\n 'setEventHandlers',\n () => `Failed to register onboarding handler for ${eventName}`,\n () => ({ error }),\n );\n }\n }\n }\n\n const unsubscribe = () => {\n Log.info(\n 'setEventHandlers',\n () => 'Unsubscribing onboarding event handlers for view',\n () => ({ id: this.id }),\n );\n if (this.viewEmitter) {\n this.viewEmitter.removeAllListeners();\n this.viewEmitter = null;\n }\n };\n\n return unsubscribe;\n }\n\n /**\n * Clears all registered event handlers.\n *\n * @remarks\n * This method removes all previously registered event handlers.\n * After calling this method, no event handlers will be active\n * until you call {@link setEventHandlers} again.\n *\n * Use this after dismiss to remove all event handlers.\n *\n * @example\n * ```typescript\n * const view = await createOnboardingView(onboarding);\n * await view.setEventHandlers({ onClose: handleClose });\n *\n * // Later, clear all handlers\n * view.clearEventHandlers();\n * ```\n */\n public clearEventHandlers(): void {\n Log.info(\n 'clearEventHandlers',\n () => 'Clearing all onboarding event handlers for view',\n () => ({ id: this.id }),\n );\n\n if (this.viewEmitter) {\n this.viewEmitter.removeAllListeners();\n this.viewEmitter = null;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"onboarding-view-controller.js","sourceRoot":"","sources":["../../../src/ui-builder/onboarding-view-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,iCAAiC,EAAE,MAAM,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AAG,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CACtB,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,GAAG,CAAC,KAAK,CACP,kBAAkB,EAClB,GAAG,EAAE,CAAC,6CAA6C,SAAS,EAAE,EAC9D,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAClB,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,WAAW,GAAG,GAAG,EAAE;YACvB,GAAG,CAAC,IAAI,CACN,kBAAkB,EAClB,GAAG,EAAE,CAAC,kDAAkD,EACxD,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CACxB,CAAC;YACF,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrB,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAC;gBACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YAC1B,CAAC;QACH,CAAC,CAAC;QAEF,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACI,kBAAkB;QACvB,GAAG,CAAC,IAAI,CACN,oBAAoB,EACpB,GAAG,EAAE,CAAC,iDAAiD,EACvD,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CACxB,CAAC;QAEF,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAC;YACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC1B,CAAC;IACH,CAAC;CACF","sourcesContent":["import { AdaptyError } from '@adapty/core';\n\nimport type { Adapty } from '../adapty';\nimport { coderFactory } from '../coders/factory';\nimport { LogContext, Log } from '../logger';\nimport { WebPresentation } from '../types';\nimport type { AdaptyOnboarding } from '../types';\nimport type { components } from '../types/api';\nimport { mapValues, withErrorContext } from '../utils';\n\nimport { OnboardingViewEmitter } from './onboarding-view-emitter';\nimport { DEFAULT_ONBOARDING_EVENT_HANDLERS } from './types';\nimport type {\n AdaptyUiView,\n OnboardingEventHandlers,\n AdaptyIOSPresentationStyle,\n CreateOnboardingViewParamsInput,\n} from './types';\n\ntype Req = components['requests'];\n\nexport const DEFAULT_ONBOARDING_PARAMS: CreateOnboardingViewParamsInput = {\n externalUrlsPresentation: WebPresentation.BrowserInApp,\n};\n\n/**\n * Controller for managing onboarding views.\n *\n * @deprecated Since 4.0.0. Migrate onboardings to the Flow Builder API.\n *\n * @remarks\n * This class provides methods to present, dismiss, and handle events for onboarding views\n * created with the Onboarding Builder. Create instances using the {@link createOnboardingView} function\n * rather than directly constructing this class.\n *\n * @public\n */\nexport class OnboardingViewController {\n private id: string | null = null;\n private adaptyPlugin: Adapty;\n private viewEmitter: OnboardingViewEmitter | null = null;\n\n /**\n * Intended way to create a OnboardingViewController instance.\n * It prepares a native controller to be presented\n * and creates reference between native controller and JS instance\n * @internal\n */\n static async create(\n onboarding: AdaptyOnboarding,\n adaptyPlugin: Adapty,\n params: CreateOnboardingViewParamsInput = {},\n ): Promise<OnboardingViewController> {\n const controller = new OnboardingViewController(adaptyPlugin);\n\n const ctx = new LogContext();\n const methodKey = 'adapty_ui_create_onboarding_view';\n const log = ctx.call({ methodName: methodKey });\n log.start(() => ({ onboarding, params }));\n\n const coder = coderFactory.createOnboardingCoder();\n const paramsWithDefaults = { ...DEFAULT_ONBOARDING_PARAMS, ...params };\n const encodedParams = coderFactory.createUiCreateOnboardingViewParamsCoder().encode(paramsWithDefaults);\n\n const data: Req['AdaptyUICreateOnboardingView.Request'] = {\n method: methodKey,\n onboarding: coder.encode(onboarding),\n ...encodedParams,\n };\n\n const result = (await controller.adaptyPlugin.handleMethodCall(\n methodKey,\n JSON.stringify(data),\n ctx,\n log,\n )) as AdaptyUiView;\n controller.id = result.id;\n\n await controller.setEventHandlers(DEFAULT_ONBOARDING_EVENT_HANDLERS);\n\n return controller;\n }\n\n /**\n * Since constructors in JS cannot be async, it is not\n * preferred to create ViewControllers in direct way.\n * Consider using {@link OnboardingViewController.create} instead\n *\n * @internal\n */\n private constructor(adaptyPlugin: Adapty) {\n this.adaptyPlugin = adaptyPlugin;\n }\n\n /**\n * Presents the onboarding view as a modal screen.\n *\n * @remarks\n * Calling `present` on an already visible onboarding view will result in an error.\n * The onboarding will be displayed with the configured presentation style on iOS.\n * On Android, the onboarding is always presented as a full-screen activity.\n *\n * @param options - Optional presentation options\n * @param options.iosPresentationStyle - iOS presentation style. Available options: `'full_screen'` (default) or `'page_sheet'`. Only affects iOS platform.\n * @returns A promise that resolves when the onboarding is presented.\n * @throws {@link AdaptyError} if the view reference is invalid or the view is already presented.\n *\n * @example\n * Present with default full-screen style\n * ```typescript\n * import { adapty, createOnboardingView } from '@adapty/capacitor';\n *\n * const onboarding = await adapty.getOnboarding({ placementId: 'YOUR_PLACEMENT_ID' });\n * const view = await createOnboardingView(onboarding);\n * await view.present();\n * ```\n *\n * @example\n * Present with page sheet style on iOS\n * ```typescript\n * await view.present({ iosPresentationStyle: 'page_sheet' });\n * ```\n */\n public async present(options: { iosPresentationStyle?: AdaptyIOSPresentationStyle } = {}): Promise<void> {\n const ctx = new LogContext();\n const methodKey = 'adapty_ui_present_onboarding_view';\n const log = ctx.call({ methodName: methodKey });\n log.start(() => ({ _id: this.id, iosPresentationStyle: options.iosPresentationStyle }));\n\n if (this.id === null) {\n throw new AdaptyError({ adaptyCode: 2002, message: 'No view reference' });\n }\n\n const data: any = {\n method: methodKey,\n id: this.id,\n ios_presentation_style: options.iosPresentationStyle ?? 'full_screen',\n };\n\n await this.adaptyPlugin.handleMethodCall(methodKey, JSON.stringify(data), ctx, log);\n }\n\n /**\n * Dismisses the onboarding view.\n *\n * @remarks\n * This method closes the onboarding and cleans up associated resources.\n * After dismissing, the view controller instance cannot be reused.\n *\n * @returns A promise that resolves when the onboarding is dismissed.\n * @throws {@link AdaptyError} if the view reference is invalid.\n *\n * @example\n * ```typescript\n * import { createOnboardingView } from '@adapty/capacitor';\n *\n * const view = await createOnboardingView(onboarding);\n * await view.present();\n * // ... later\n * await view.dismiss();\n * ```\n */\n public async dismiss(): Promise<void> {\n const ctx = new LogContext();\n const methodKey = 'adapty_ui_dismiss_onboarding_view';\n const log = ctx.call({ methodName: methodKey });\n log.start(() => ({ _id: this.id }));\n\n if (this.id === null) {\n throw new AdaptyError({ adaptyCode: 2002, message: 'No view reference' });\n }\n\n const data: Req['AdaptyUIDismissOnboardingView.Request'] = {\n method: methodKey,\n id: this.id,\n destroy: true,\n };\n\n await this.adaptyPlugin.handleMethodCall(methodKey, JSON.stringify(data), ctx, log);\n this.clearEventHandlers();\n }\n\n private onRequestClose = async () => {\n try {\n await this.dismiss();\n } catch (error) {\n Log.warn(\n 'setEventHandlers',\n () => 'Failed to dismiss onboarding',\n () => ({ error }),\n );\n }\n };\n\n /**\n * Registers event handlers for onboarding UI events.\n *\n * @remarks\n * Each event type can have only one handler — new handlers replace existing ones.\n * Default handlers are registered automatically in {@link createOnboardingView} and provide standard closing behavior:\n * - `onClose` - closes the onboarding when the close button is pressed or system back is used\n *\n * If you want to override the `onClose` listener, we strongly recommend returning `true`\n * from your custom listener to retain default closing behavior.\n *\n * Calling this method multiple times will replace previously registered handlers for provided events.\n *\n * @see {@link https://adapty.io/docs/capacitor-handling-onboarding-events | Handling Onboarding Events}\n *\n * @param eventHandlers - Set of event handling callbacks. Only provided handlers will be registered or updated.\n * @returns A promise that resolves to an unsubscribe function that removes all registered listeners.\n *\n * @example\n * Register custom event handlers\n * ```typescript\n * import { createOnboardingView } from '@adapty/capacitor';\n *\n * const view = await createOnboardingView(onboarding);\n *\n * const unsubscribe = await view.setEventHandlers({\n * onClose: () => {\n * console.log('Onboarding closed');\n * // Return true to keep default closing behavior\n * return true;\n * },\n * onCustom: (actionId, meta) => {\n * console.log('Custom action:', actionId, meta);\n * },\n * onStateUpdated: (action, meta) => {\n * console.log('State updated:', action, meta);\n * }\n * });\n *\n * await view.present();\n *\n * // Later, unsubscribe all handlers\n * unsubscribe();\n * ```\n */\n public async setEventHandlers(eventHandlers: Partial<OnboardingEventHandlers> = {}): Promise<() => void> {\n const ctx = new LogContext();\n const log = ctx.call({ methodName: 'setEventHandlers' });\n log.start(() => ({ _id: this.id }));\n\n if (this.id === null) {\n throw new AdaptyError({ adaptyCode: 2002, message: 'No view reference' });\n }\n\n Log.verbose(\n 'setEventHandlers',\n () => 'Registering onboarding event handlers for view',\n () => ({ id: this.id }),\n );\n\n const viewEmitter = this.viewEmitter ?? new OnboardingViewEmitter(this.id);\n this.viewEmitter = viewEmitter;\n\n const wrappedErrorLogEventHandlers = mapValues(eventHandlers, (handler, eventName) =>\n handler && typeof handler === 'function'\n ? withErrorContext(handler, eventName as string, 'OnboardingViewController')\n : undefined,\n );\n\n // Merge with defaults to ensure default behavior is preserved after unsubscribe/resubscribe cycles\n const finalEventHandlers: Partial<OnboardingEventHandlers> = {\n ...DEFAULT_ONBOARDING_EVENT_HANDLERS,\n ...wrappedErrorLogEventHandlers,\n };\n\n for (const [eventName, handler] of Object.entries(finalEventHandlers)) {\n if (handler && typeof handler === 'function') {\n try {\n await viewEmitter.addListener(eventName as keyof OnboardingEventHandlers, handler, this.onRequestClose);\n Log.verbose(\n 'setEventHandlers',\n () => 'Registered onboarding handler',\n () => ({ eventName }),\n );\n } catch (error) {\n Log.error(\n 'setEventHandlers',\n () => `Failed to register onboarding handler for ${eventName}`,\n () => ({ error }),\n );\n }\n }\n }\n\n const unsubscribe = () => {\n Log.info(\n 'setEventHandlers',\n () => 'Unsubscribing onboarding event handlers for view',\n () => ({ id: this.id }),\n );\n if (this.viewEmitter) {\n this.viewEmitter.removeAllListeners();\n this.viewEmitter = null;\n }\n };\n\n return unsubscribe;\n }\n\n /**\n * Clears all registered event handlers.\n *\n * @remarks\n * This method removes all previously registered event handlers.\n * After calling this method, no event handlers will be active\n * until you call {@link setEventHandlers} again.\n *\n * Use this after dismiss to remove all event handlers.\n *\n * @example\n * ```typescript\n * const view = await createOnboardingView(onboarding);\n * await view.setEventHandlers({ onClose: handleClose });\n *\n * // Later, clear all handlers\n * view.clearEventHandlers();\n * ```\n */\n public clearEventHandlers(): void {\n Log.info(\n 'clearEventHandlers',\n () => 'Clearing all onboarding event handlers for view',\n () => ({ id: this.id }),\n );\n\n if (this.viewEmitter) {\n this.viewEmitter.removeAllListeners();\n this.viewEmitter = null;\n }\n }\n}\n"]}
|
|
@@ -1,363 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* EventHandler callback should not return a promise,
|
|
10
|
-
* because using `await` may postpone closing a paywall view.
|
|
11
|
-
*
|
|
12
|
-
* We don't want to block the UI thread.
|
|
13
|
-
*/
|
|
14
|
-
export type EventHandlerResult = boolean | void;
|
|
15
|
-
/**
|
|
16
|
-
* Purchase parameters keyed by AdaptyProductIdentifier objects
|
|
17
|
-
*/
|
|
18
|
-
export type ProductPurchaseParams = {
|
|
19
|
-
productId: AdaptyProductIdentifier;
|
|
20
|
-
params: MakePurchaseParamsInput;
|
|
21
|
-
}[];
|
|
22
|
-
export type AdaptyCustomAsset = AdaptyCustomImageAsset | AdaptyCustomVideoAsset | AdaptyCustomColorAsset | AdaptyCustomGradientAsset;
|
|
23
|
-
export type AdaptyCustomImageAsset = {
|
|
24
|
-
type: 'image';
|
|
25
|
-
base64: string;
|
|
26
|
-
} | {
|
|
27
|
-
type: 'image';
|
|
28
|
-
relativeAssetPath: string;
|
|
29
|
-
} | {
|
|
30
|
-
type: 'image';
|
|
31
|
-
fileLocation: FileLocation;
|
|
32
|
-
};
|
|
33
|
-
export type AdaptyCustomVideoAsset = {
|
|
34
|
-
type: 'video';
|
|
35
|
-
relativeAssetPath: string;
|
|
36
|
-
} | {
|
|
37
|
-
type: 'video';
|
|
38
|
-
fileLocation: FileLocation;
|
|
39
|
-
};
|
|
40
|
-
export type AdaptyCustomColorAsset = {
|
|
41
|
-
type: 'color';
|
|
42
|
-
argb: number;
|
|
43
|
-
} | {
|
|
44
|
-
type: 'color';
|
|
45
|
-
rgb: number;
|
|
46
|
-
} | {
|
|
47
|
-
type: 'color';
|
|
48
|
-
rgba: number;
|
|
49
|
-
};
|
|
50
|
-
export type AdaptyCustomGradientAsset = {
|
|
51
|
-
type: 'linear-gradient';
|
|
52
|
-
values: ({
|
|
53
|
-
p: number;
|
|
54
|
-
argb: number;
|
|
55
|
-
} | {
|
|
56
|
-
p: number;
|
|
57
|
-
rgb: number;
|
|
58
|
-
} | {
|
|
59
|
-
p: number;
|
|
60
|
-
rgba: number;
|
|
61
|
-
})[];
|
|
62
|
-
points?: {
|
|
63
|
-
x0?: number;
|
|
64
|
-
y0?: number;
|
|
65
|
-
x1?: number;
|
|
66
|
-
y1?: number;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
export type AdaptyUiOnboardingMeta = {
|
|
70
|
-
onboardingId: string;
|
|
71
|
-
screenClientId: string;
|
|
72
|
-
screenIndex: number;
|
|
73
|
-
totalScreens: number;
|
|
74
|
-
};
|
|
75
|
-
export type AdaptyUiOnboardingStateParams = {
|
|
76
|
-
id: string;
|
|
77
|
-
value: string;
|
|
78
|
-
label: string;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Paywall event handlers configuration
|
|
1
|
+
import type { FlowEventHandlers, OnboardingEventHandlers } from '@adapty/core';
|
|
2
|
+
export type { EventHandlerResult, ProductPurchaseParams, FlowEventHandlers, OnboardingEventHandlers, OnboardingAnalyticsEventName, AdaptyUiOnboardingMeta, AdaptyUiOnboardingStateParams, OnboardingStateUpdatedAction, FlowPermissionResponse, FlowPermissionStatus, AdaptyPermission, CreateFlowViewParamsInput, CreateOnboardingViewParamsInput, AdaptyUiView, AdaptyUiMediaCache, AdaptyUiDialogConfig, AdaptyCustomAsset, AdaptyCustomImageAsset, AdaptyCustomVideoAsset, AdaptyCustomColorAsset, AdaptyCustomGradientAsset, AdaptyIOSPresentationStyle, } from '@adapty/core';
|
|
3
|
+
export { AdaptyUiDialogActionType } from '@adapty/core';
|
|
4
|
+
/**
|
|
5
|
+
* Default flow-view event handlers. Mirrors react-native-adapty v4 defaults:
|
|
6
|
+
* most handlers keep the view open (return false); onCloseButtonPress and
|
|
7
|
+
* onError close it (return true). onUrlPress / onRequestAppReview delegate to
|
|
8
|
+
* the native handler methods.
|
|
82
9
|
*
|
|
83
|
-
* @
|
|
84
|
-
*/
|
|
85
|
-
export interface EventHandlers {
|
|
86
|
-
/**
|
|
87
|
-
* Called when a user taps the close button on the paywall view
|
|
88
|
-
*
|
|
89
|
-
* If you return `true`, the paywall view will be closed.
|
|
90
|
-
* We strongly recommend to return `true` in this case.
|
|
91
|
-
* @default true
|
|
92
|
-
*/
|
|
93
|
-
onCloseButtonPress: () => EventHandlerResult;
|
|
94
|
-
/**
|
|
95
|
-
* Called when a user navigates back on Android
|
|
96
|
-
*
|
|
97
|
-
* If you return `true`, the paywall view will be closed.
|
|
98
|
-
* We strongly recommend to return `true` in this case.
|
|
99
|
-
* @default true
|
|
100
|
-
*/
|
|
101
|
-
onAndroidSystemBack: () => EventHandlerResult;
|
|
102
|
-
/**
|
|
103
|
-
* Called when a user taps an URL in the paywall view.
|
|
104
|
-
*
|
|
105
|
-
* If you return `true`, the paywall view will be closed.
|
|
106
|
-
* @default false
|
|
107
|
-
*
|
|
108
|
-
* The default onUrlPress handler does not support `browser_in_app`.
|
|
109
|
-
* To support it, install an in-app browser plugin (e.g. `@capacitor/inappbrowser`)
|
|
110
|
-
* and handle the `openIn` argument in your own custom onUrlPress handler.
|
|
111
|
-
*
|
|
112
|
-
* @param url - URL to open
|
|
113
|
-
* @param openIn - How the URL was configured to open in the dashboard:
|
|
114
|
-
* `'browser_in_app'` — in-app browser
|
|
115
|
-
* `'browser_out_app'` — external/system browser
|
|
116
|
-
*/
|
|
117
|
-
onUrlPress: (url: string, openIn: WebPresentation) => EventHandlerResult;
|
|
118
|
-
/**
|
|
119
|
-
* Called when a user performs a custom action in the paywall view
|
|
120
|
-
*
|
|
121
|
-
* If you return `true`, the paywall view will be closed.
|
|
122
|
-
* @default false
|
|
123
|
-
*/
|
|
124
|
-
onCustomAction: (actionId: string) => EventHandlerResult;
|
|
125
|
-
/**
|
|
126
|
-
* Called when a user selects a product in the paywall view
|
|
127
|
-
*
|
|
128
|
-
* If you return `true` from this callback, the paywall view will be closed.
|
|
129
|
-
* @default false
|
|
130
|
-
*/
|
|
131
|
-
onProductSelected: (productId: string) => EventHandlerResult;
|
|
132
|
-
/**
|
|
133
|
-
* Called when a purchase process starts
|
|
134
|
-
*
|
|
135
|
-
* If you return `true` from this callback, the paywall view will be closed.
|
|
136
|
-
* @default false
|
|
137
|
-
*/
|
|
138
|
-
onPurchaseStarted: (product: AdaptyPaywallProduct) => EventHandlerResult;
|
|
139
|
-
/**
|
|
140
|
-
* Called when the purchase succeeds, the user cancels their purchase, or the purchase appears to be pending
|
|
141
|
-
*
|
|
142
|
-
* If you return `true` from this callback, the paywall view will be closed.
|
|
143
|
-
* We strongly recommend returning `purchaseResult.type !== 'user_cancelled'` in this case.
|
|
144
|
-
* @default `purchaseResult.type !== 'user_cancelled'`
|
|
145
|
-
*
|
|
146
|
-
* @param purchaseResult - object, which provides details about the purchase.
|
|
147
|
-
* If the result is `'success'`, it also includes the updated user's profile.
|
|
148
|
-
*/
|
|
149
|
-
onPurchaseCompleted: (purchaseResult: AdaptyPurchaseResult, product: AdaptyPaywallProduct) => EventHandlerResult;
|
|
150
|
-
/**
|
|
151
|
-
* Called if a purchase fails after a user taps the purchase button
|
|
152
|
-
*
|
|
153
|
-
* If you return `true` from this callback, the paywall view will be closed.
|
|
154
|
-
* @default false
|
|
155
|
-
*
|
|
156
|
-
* @param error - AdaptyError object with error code and message
|
|
157
|
-
*/
|
|
158
|
-
onPurchaseFailed: (error: AdaptyError, product: AdaptyPaywallProduct) => EventHandlerResult;
|
|
159
|
-
/**
|
|
160
|
-
* Called when a user taps the restore button in the paywall view
|
|
161
|
-
*
|
|
162
|
-
* If you return `true` from this callback, the paywall view will be closed.
|
|
163
|
-
* @default false
|
|
164
|
-
*/
|
|
165
|
-
onRestoreStarted: () => EventHandlerResult;
|
|
166
|
-
/**
|
|
167
|
-
* Called when a purchase is completed
|
|
168
|
-
*
|
|
169
|
-
* If you return `true` from this callback, the paywall view will be closed.
|
|
170
|
-
* We strongly recommend to return `true` in this case.
|
|
171
|
-
* @default true
|
|
172
|
-
*
|
|
173
|
-
* @param profile - updated user profile
|
|
174
|
-
*/
|
|
175
|
-
onRestoreCompleted: (profile: AdaptyProfile) => EventHandlerResult;
|
|
176
|
-
/**
|
|
177
|
-
* Called if a restore fails after a user taps the restore button
|
|
178
|
-
*
|
|
179
|
-
* If you return `true` from this callback, the paywall view will be closed.
|
|
180
|
-
* @default false
|
|
181
|
-
*
|
|
182
|
-
* @param error - AdaptyError object with error code and message
|
|
183
|
-
*/
|
|
184
|
-
onRestoreFailed: (error: AdaptyError) => EventHandlerResult;
|
|
185
|
-
/**
|
|
186
|
-
* Called when the paywall view appears
|
|
187
|
-
*
|
|
188
|
-
* If you return `true`, the paywall view will be closed.
|
|
189
|
-
* @default false
|
|
190
|
-
*/
|
|
191
|
-
onAppeared: () => EventHandlerResult;
|
|
192
|
-
/**
|
|
193
|
-
* Called when the paywall view disappears
|
|
194
|
-
*
|
|
195
|
-
* If you return `true`, the paywall view will be closed.
|
|
196
|
-
* @default false
|
|
197
|
-
*/
|
|
198
|
-
onDisappeared: () => EventHandlerResult;
|
|
199
|
-
/**
|
|
200
|
-
* Called if a paywall view fails to render.
|
|
201
|
-
* This should not ever happen, but if it does, feel free to report it to us.
|
|
202
|
-
*
|
|
203
|
-
* If you return `true` from this callback, the paywall view will be closed.
|
|
204
|
-
* @default true
|
|
205
|
-
*
|
|
206
|
-
* @param error - AdaptyError object with error code and message
|
|
207
|
-
*/
|
|
208
|
-
onRenderingFailed: (error: AdaptyError) => EventHandlerResult;
|
|
209
|
-
/**
|
|
210
|
-
* Called if a product list fails to load on a presented view,
|
|
211
|
-
* for example, if there is no internet connection
|
|
212
|
-
*
|
|
213
|
-
* If you return `true` from this callback, the paywall view will be closed.
|
|
214
|
-
* @default false
|
|
215
|
-
*
|
|
216
|
-
* @param error - AdaptyError object with error code and message
|
|
217
|
-
*/
|
|
218
|
-
onLoadingProductsFailed: (error: AdaptyError) => EventHandlerResult;
|
|
219
|
-
/**
|
|
220
|
-
* Called when web payment navigation finishes
|
|
221
|
-
*
|
|
222
|
-
* If you return `true`, the paywall view will be closed.
|
|
223
|
-
* @default false
|
|
224
|
-
*/
|
|
225
|
-
onWebPaymentNavigationFinished: (product?: AdaptyPaywallProduct, error?: AdaptyError) => EventHandlerResult;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Default event handlers that provide standard closing behavior
|
|
229
|
-
*/
|
|
230
|
-
export declare const DEFAULT_EVENT_HANDLERS: EventHandlers;
|
|
231
|
-
export type OnboardingStateUpdatedAction = {
|
|
232
|
-
elementId: string;
|
|
233
|
-
elementType: 'select';
|
|
234
|
-
value: AdaptyUiOnboardingStateParams;
|
|
235
|
-
} | {
|
|
236
|
-
elementId: string;
|
|
237
|
-
elementType: 'multi_select';
|
|
238
|
-
value: AdaptyUiOnboardingStateParams[];
|
|
239
|
-
} | {
|
|
240
|
-
elementId: string;
|
|
241
|
-
elementType: 'input';
|
|
242
|
-
value: {
|
|
243
|
-
type: 'text' | 'email';
|
|
244
|
-
value: string;
|
|
245
|
-
} | {
|
|
246
|
-
type: 'number';
|
|
247
|
-
value: number;
|
|
248
|
-
};
|
|
249
|
-
} | {
|
|
250
|
-
elementId: string;
|
|
251
|
-
elementType: 'date_picker';
|
|
252
|
-
value: {
|
|
253
|
-
day?: number;
|
|
254
|
-
month?: number;
|
|
255
|
-
year?: number;
|
|
256
|
-
};
|
|
257
|
-
};
|
|
258
|
-
export interface AdaptyUiView {
|
|
259
|
-
id: string;
|
|
260
|
-
}
|
|
261
|
-
export interface AdaptyUiMediaCache {
|
|
262
|
-
memoryStorageTotalCostLimit?: number;
|
|
263
|
-
memoryStorageCountLimit?: number;
|
|
264
|
-
diskStorageSizeLimit?: number;
|
|
265
|
-
}
|
|
266
|
-
export interface AdaptyUiDialogConfig {
|
|
267
|
-
/**
|
|
268
|
-
* The action title to display as part of the dialog. If you provide two actions,
|
|
269
|
-
* be sure `primaryAction` cancels the operation and leaves things unchanged.
|
|
270
|
-
*/
|
|
271
|
-
primaryActionTitle: string;
|
|
272
|
-
/**
|
|
273
|
-
* The secondary action title to display as part of the dialog.
|
|
274
|
-
*/
|
|
275
|
-
secondaryActionTitle?: string;
|
|
276
|
-
/**
|
|
277
|
-
* The title of the dialog.
|
|
278
|
-
*/
|
|
279
|
-
title?: string;
|
|
280
|
-
/**
|
|
281
|
-
* Descriptive text that provides additional details about the reason for the dialog.
|
|
282
|
-
*/
|
|
283
|
-
content?: string;
|
|
284
|
-
}
|
|
285
|
-
export declare const AdaptyUiDialogActionType: Readonly<{
|
|
286
|
-
primary: "primary";
|
|
287
|
-
secondary: "secondary";
|
|
288
|
-
}>;
|
|
289
|
-
export type AdaptyUiDialogActionType = (typeof AdaptyUiDialogActionType)[keyof typeof AdaptyUiDialogActionType];
|
|
290
|
-
/**
|
|
291
|
-
* Additional options for creating a paywall view
|
|
292
|
-
*
|
|
293
|
-
* @see {@link https://adapty.io/docs/capacitor-present-paywalls | [DOC] Creating Paywall View}
|
|
10
|
+
* @internal
|
|
294
11
|
*/
|
|
295
|
-
export
|
|
296
|
-
/**
|
|
297
|
-
* `true` if you want to prefetch products before presenting a paywall view.
|
|
298
|
-
*/
|
|
299
|
-
prefetchProducts?: boolean;
|
|
300
|
-
/**
|
|
301
|
-
* This value limits the timeout (in milliseconds) for this method.
|
|
302
|
-
*/
|
|
303
|
-
loadTimeoutMs?: number;
|
|
304
|
-
/**
|
|
305
|
-
* If you are going to use custom tags functionality, pass an object with tags and corresponding replacement values
|
|
306
|
-
*
|
|
307
|
-
* ```
|
|
308
|
-
* {
|
|
309
|
-
* 'USERNAME': 'Bruce',
|
|
310
|
-
* 'CITY': 'Philadelphia'
|
|
311
|
-
* }
|
|
312
|
-
* ```
|
|
313
|
-
*/
|
|
314
|
-
customTags?: Record<string, string>;
|
|
315
|
-
/**
|
|
316
|
-
* If you are going to use custom timer functionality, pass an object with timer ids and corresponding dates the timers should end at
|
|
317
|
-
*/
|
|
318
|
-
customTimers?: Record<string, Date>;
|
|
319
|
-
/**
|
|
320
|
-
* Use this when you need to override paywall assets with your own
|
|
321
|
-
*/
|
|
322
|
-
customAssets?: Record<string, AdaptyCustomAsset>;
|
|
323
|
-
/**
|
|
324
|
-
* Provide per-product purchase parameters keyed by Adapty product identifier
|
|
325
|
-
*/
|
|
326
|
-
productPurchaseParams?: ProductPurchaseParams;
|
|
327
|
-
}
|
|
12
|
+
export declare const DEFAULT_FLOW_EVENT_HANDLERS: FlowEventHandlers;
|
|
328
13
|
/**
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
* @see {@link https://adapty.io/docs/capacitor-get-onboardings | [DOC] Creating Onboarding View}
|
|
14
|
+
* @internal
|
|
332
15
|
*/
|
|
333
|
-
export interface CreateOnboardingViewParamsInput {
|
|
334
|
-
/**
|
|
335
|
-
* If you want to change the presentation behavior of external URLs, pass a preferred value.
|
|
336
|
-
*
|
|
337
|
-
* @default {@link WebPresentation.BrowserInApp}
|
|
338
|
-
*/
|
|
339
|
-
externalUrlsPresentation?: WebPresentation;
|
|
340
|
-
}
|
|
341
|
-
export interface OnboardingEventHandlers {
|
|
342
|
-
onClose: (actionId: string, meta: AdaptyUiOnboardingMeta) => EventHandlerResult;
|
|
343
|
-
onCustom: (actionId: string, meta: AdaptyUiOnboardingMeta) => EventHandlerResult;
|
|
344
|
-
onPaywall: (actionId: string, meta: AdaptyUiOnboardingMeta) => EventHandlerResult;
|
|
345
|
-
onStateUpdated: (action: OnboardingStateUpdatedAction, meta: AdaptyUiOnboardingMeta) => EventHandlerResult;
|
|
346
|
-
onFinishedLoading: (meta: AdaptyUiOnboardingMeta) => EventHandlerResult;
|
|
347
|
-
onAnalytics: (event: {
|
|
348
|
-
name: string;
|
|
349
|
-
/**
|
|
350
|
-
* @deprecated Use `elementId` instead
|
|
351
|
-
*/
|
|
352
|
-
element_id?: string;
|
|
353
|
-
elementId?: string;
|
|
354
|
-
reply?: string;
|
|
355
|
-
}, meta: AdaptyUiOnboardingMeta) => EventHandlerResult;
|
|
356
|
-
onError: (error: AdaptyError) => EventHandlerResult;
|
|
357
|
-
}
|
|
358
16
|
export declare const DEFAULT_ONBOARDING_EVENT_HANDLERS: Partial<OnboardingEventHandlers>;
|
|
359
|
-
/**
|
|
360
|
-
* iOS presentation style for paywall and onboarding views
|
|
361
|
-
* @platform ios
|
|
362
|
-
*/
|
|
363
|
-
export type AdaptyIOSPresentationStyle = 'full_screen' | 'page_sheet';
|
|
@@ -1,42 +1,72 @@
|
|
|
1
|
+
import { adapty } from '../adapty-instance';
|
|
1
2
|
import { Log } from '../logger';
|
|
3
|
+
export { AdaptyUiDialogActionType } from '@adapty/core';
|
|
2
4
|
/**
|
|
3
|
-
* Default event handlers
|
|
5
|
+
* Default flow-view event handlers. Mirrors react-native-adapty v4 defaults:
|
|
6
|
+
* most handlers keep the view open (return false); onCloseButtonPress and
|
|
7
|
+
* onError close it (return true). onUrlPress / onRequestAppReview delegate to
|
|
8
|
+
* the native handler methods.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
4
11
|
*/
|
|
5
|
-
export const
|
|
12
|
+
export const DEFAULT_FLOW_EVENT_HANDLERS = {
|
|
6
13
|
onCloseButtonPress: () => true,
|
|
7
|
-
onAndroidSystemBack: () =>
|
|
14
|
+
onAndroidSystemBack: () => false,
|
|
15
|
+
// Delegate to the handler method, which opens the URL natively honoring
|
|
16
|
+
// `open_in` (`browser_out_app` → external browser, `browser_in_app` → in-app
|
|
17
|
+
// browser). Override this handler to open URLs yourself instead.
|
|
8
18
|
onUrlPress: (url, openIn) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
window.open(new URL(url), '_blank');
|
|
15
|
-
}
|
|
16
|
-
catch (_a) {
|
|
17
|
-
Log.warn('onUrlPress', () => `Invalid URL: ${url}`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return false;
|
|
19
|
+
adapty
|
|
20
|
+
.openWebUrl({ url, openIn })
|
|
21
|
+
.catch((error) => Log.warn('onUrlPress', () => `Failed to open url via native: ${error}`));
|
|
22
|
+
return false; // Keep flow view open
|
|
21
23
|
},
|
|
22
24
|
onCustomAction: () => false,
|
|
23
25
|
onProductSelected: () => false,
|
|
24
26
|
onPurchaseStarted: () => false,
|
|
25
|
-
onPurchaseCompleted: (
|
|
27
|
+
onPurchaseCompleted: () => false,
|
|
26
28
|
onPurchaseFailed: () => false,
|
|
27
29
|
onRestoreStarted: () => false,
|
|
28
|
-
onRestoreCompleted: () =>
|
|
30
|
+
onRestoreCompleted: () => false,
|
|
29
31
|
onRestoreFailed: () => false,
|
|
30
32
|
onAppeared: () => false,
|
|
31
33
|
onDisappeared: () => false,
|
|
32
|
-
|
|
34
|
+
onError: () => true,
|
|
33
35
|
onLoadingProductsFailed: () => false,
|
|
34
36
|
onWebPaymentNavigationFinished: () => false,
|
|
37
|
+
// Delegate to the handler method, which shows the platform app-review prompt
|
|
38
|
+
// natively (`SKStoreReviewController` on iOS, In-App Review on Android).
|
|
39
|
+
// Override this handler to control the prompt yourself instead.
|
|
40
|
+
onRequestAppReview: () => {
|
|
41
|
+
void adapty
|
|
42
|
+
.requestAppReview()
|
|
43
|
+
.catch((error) => Log.warn('onRequestAppReview', () => `Failed to request app review via native: ${error}`));
|
|
44
|
+
return false; // Keep flow view open
|
|
45
|
+
},
|
|
46
|
+
onAnalytics: () => false,
|
|
47
|
+
// There is no real default here: permissions must be declared in the app
|
|
48
|
+
// bundle by the developer, so we cannot grant them on the user's behalf. Warn
|
|
49
|
+
// and reply `denied` so native always gets a correlated answer.
|
|
50
|
+
onRequestPermission: async () => {
|
|
51
|
+
Log.warn('onRequestPermission', () => 'No onRequestPermission handler provided; replying `denied`. Declare the required ' +
|
|
52
|
+
'permissions in your app and provide an onRequestPermission handler to respond.');
|
|
53
|
+
return { status: 'denied' };
|
|
54
|
+
},
|
|
55
|
+
// Observer mode: no real default. If you enable observer mode and present a
|
|
56
|
+
// flow view, you must drive the purchase/restore yourself, so warn when no
|
|
57
|
+
// handler is provided.
|
|
58
|
+
onObserverPurchaseInitiated: () => {
|
|
59
|
+
Log.warn('onObserverPurchaseInitiated', () => 'No onObserverPurchaseInitiated handler provided. In observer mode you must drive the purchase yourself; provide this handler to do so.');
|
|
60
|
+
return false;
|
|
61
|
+
},
|
|
62
|
+
onObserverRestoreInitiated: () => {
|
|
63
|
+
Log.warn('onObserverRestoreInitiated', () => 'No onObserverRestoreInitiated handler provided. In observer mode you must drive the restore yourself; provide this handler to do so.');
|
|
64
|
+
return false;
|
|
65
|
+
},
|
|
35
66
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
40
70
|
export const DEFAULT_ONBOARDING_EVENT_HANDLERS = {
|
|
41
71
|
onClose: () => true,
|
|
42
72
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ui-builder/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AA0NhC;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAkB;IACnD,kBAAkB,EAAE,GAAG,EAAE,CAAC,IAAI;IAC9B,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAI;IAC/B,UAAU,EAAE,CAAC,GAAW,EAAE,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S;IAClB,SAAS,EAAE,WAAW;CACvB,CAAC,CAAC;AA8EH,MAAM,CAAC,MAAM,iCAAiC,GAAqC;IACjF,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;CACpB,CAAC","sourcesContent":["import type { AdaptyError } from '@adapty/core';\n\nimport { Log } from '../logger';\nimport type {\n AdaptyPaywallProduct,\n AdaptyProductIdentifier,\n AdaptyProfile,\n AdaptyPurchaseResult,\n WebPresentation,\n} from '../types';\nimport type { FileLocation, MakePurchaseParamsInput } from '../types/inputs';\n\n/**\n * @internal\n */\nexport type ArgType<T> = T extends () => any ? void : T extends (arg: infer U) => any ? U : void;\n\n/**\n * EventHandler callback should not return a promise,\n * because using `await` may postpone closing a paywall view.\n *\n * We don't want to block the UI thread.\n */\nexport type EventHandlerResult = boolean | void;\n\n/**\n * Purchase parameters keyed by AdaptyProductIdentifier objects\n */\nexport type ProductPurchaseParams = {\n productId: AdaptyProductIdentifier;\n params: MakePurchaseParamsInput;\n}[];\n\nexport type AdaptyCustomAsset =\n | AdaptyCustomImageAsset\n | AdaptyCustomVideoAsset\n | AdaptyCustomColorAsset\n | AdaptyCustomGradientAsset;\n\nexport type AdaptyCustomImageAsset =\n | { type: 'image'; base64: string }\n | { type: 'image'; relativeAssetPath: string } // shorthand: uses same path for both iOS fileName and Android relativeAssetPath\n | { type: 'image'; fileLocation: FileLocation }; // full control for platform-specific paths\n\nexport type AdaptyCustomVideoAsset =\n | { type: 'video'; relativeAssetPath: string } // shorthand: uses same path for both iOS fileName and Android relativeAssetPath\n | { type: 'video'; fileLocation: FileLocation }; // full control for platform-specific paths\n\nexport type AdaptyCustomColorAsset =\n | { type: 'color'; argb: number /* e.g. 0xFFFF0000 (opaque red) */ }\n | { type: 'color'; rgb: number /* e.g. 0xFF0000 (red) */ }\n | { type: 'color'; rgba: number /* e.g. 0xFF0000FF (opaque red) */ };\n\nexport type AdaptyCustomGradientAsset = {\n type: 'linear-gradient';\n values: ({ p: number; argb: number } | { p: number; rgb: number } | { p: number; rgba: number })[];\n points?: { x0?: number; y0?: number; x1?: number; y1?: number };\n};\n\nexport type AdaptyUiOnboardingMeta = {\n onboardingId: string;\n screenClientId: string;\n screenIndex: number;\n totalScreens: number;\n};\n\nexport type AdaptyUiOnboardingStateParams = {\n id: string;\n value: string;\n label: string;\n};\n\n/**\n * Paywall event handlers configuration\n *\n * @see {@link https://adapty.io/docs/capacitor-handling-events | [DOC] Handling View Events}\n */\nexport interface EventHandlers {\n /**\n * Called when a user taps the close button on the paywall view\n *\n * If you return `true`, the paywall view will be closed.\n * We strongly recommend to return `true` in this case.\n * @default true\n */\n onCloseButtonPress: () => EventHandlerResult;\n /**\n * Called when a user navigates back on Android\n *\n * If you return `true`, the paywall view will be closed.\n * We strongly recommend to return `true` in this case.\n * @default true\n */\n onAndroidSystemBack: () => EventHandlerResult;\n /**\n * Called when a user taps an URL in the paywall view.\n *\n * If you return `true`, the paywall view will be closed.\n * @default false\n *\n * The default onUrlPress handler does not support `browser_in_app`.\n * To support it, install an in-app browser plugin (e.g. `@capacitor/inappbrowser`)\n * and handle the `openIn` argument in your own custom onUrlPress handler.\n *\n * @param url - URL to open\n * @param openIn - How the URL was configured to open in the dashboard:\n * `'browser_in_app'` — in-app browser\n * `'browser_out_app'` — external/system browser\n */\n onUrlPress: (url: string, openIn: WebPresentation) => EventHandlerResult;\n /**\n * Called when a user performs a custom action in the paywall view\n *\n * If you return `true`, the paywall view will be closed.\n * @default false\n */\n onCustomAction: (actionId: string) => EventHandlerResult;\n /**\n * Called when a user selects a product in the paywall view\n *\n * If you return `true` from this callback, the paywall view will be closed.\n * @default false\n */\n onProductSelected: (productId: string) => EventHandlerResult;\n /**\n * Called when a purchase process starts\n *\n * If you return `true` from this callback, the paywall view will be closed.\n * @default false\n */\n onPurchaseStarted: (product: AdaptyPaywallProduct) => EventHandlerResult;\n /**\n * Called when the purchase succeeds, the user cancels their purchase, or the purchase appears to be pending\n *\n * If you return `true` from this callback, the paywall view will be closed.\n * We strongly recommend returning `purchaseResult.type !== 'user_cancelled'` in this case.\n * @default `purchaseResult.type !== 'user_cancelled'`\n *\n * @param purchaseResult - object, which provides details about the purchase.\n * If the result is `'success'`, it also includes the updated user's profile.\n */\n onPurchaseCompleted: (purchaseResult: AdaptyPurchaseResult, product: AdaptyPaywallProduct) => EventHandlerResult;\n /**\n * Called if a purchase fails after a user taps the purchase button\n *\n * If you return `true` from this callback, the paywall view will be closed.\n * @default false\n *\n * @param error - AdaptyError object with error code and message\n */\n onPurchaseFailed: (error: AdaptyError, product: AdaptyPaywallProduct) => EventHandlerResult;\n /**\n * Called when a user taps the restore button in the paywall view\n *\n * If you return `true` from this callback, the paywall view will be closed.\n * @default false\n */\n onRestoreStarted: () => EventHandlerResult;\n /**\n * Called when a purchase is completed\n *\n * If you return `true` from this callback, the paywall view will be closed.\n * We strongly recommend to return `true` in this case.\n * @default true\n *\n * @param profile - updated user profile\n */\n onRestoreCompleted: (profile: AdaptyProfile) => EventHandlerResult;\n /**\n * Called if a restore fails after a user taps the restore button\n *\n * If you return `true` from this callback, the paywall view will be closed.\n * @default false\n *\n * @param error - AdaptyError object with error code and message\n */\n onRestoreFailed: (error: AdaptyError) => EventHandlerResult;\n /**\n * Called when the paywall view appears\n *\n * If you return `true`, the paywall view will be closed.\n * @default false\n */\n onAppeared: () => EventHandlerResult;\n /**\n * Called when the paywall view disappears\n *\n * If you return `true`, the paywall view will be closed.\n * @default false\n */\n onDisappeared: () => EventHandlerResult;\n /**\n * Called if a paywall view fails to render.\n * This should not ever happen, but if it does, feel free to report it to us.\n *\n * If you return `true` from this callback, the paywall view will be closed.\n * @default true\n *\n * @param error - AdaptyError object with error code and message\n */\n onRenderingFailed: (error: AdaptyError) => EventHandlerResult;\n /**\n * Called if a product list fails to load on a presented view,\n * for example, if there is no internet connection\n *\n * If you return `true` from this callback, the paywall view will be closed.\n * @default false\n *\n * @param error - AdaptyError object with error code and message\n */\n onLoadingProductsFailed: (error: AdaptyError) => EventHandlerResult;\n /**\n * Called when web payment navigation finishes\n *\n * If you return `true`, the paywall view will be closed.\n * @default false\n */\n onWebPaymentNavigationFinished: (product?: AdaptyPaywallProduct, error?: AdaptyError) => EventHandlerResult;\n}\n\n/**\n * Default event handlers that provide standard closing behavior\n */\nexport const DEFAULT_EVENT_HANDLERS: EventHandlers = {\n onCloseButtonPress: () => true,\n onAndroidSystemBack: () => true,\n onUrlPress: (url: string, openIn: WebPresentation) => {\n if (openIn === 'browser_in_app') {\n Log.warn(\n 'onUrlPress',\n () =>\n 'open_in=browser_in_app is not supported by the default onUrlPress handler. Override onUrlPress to support an in-app browser.',\n );\n }\n if (typeof window !== 'undefined') {\n try {\n window.open(new URL(url), '_blank');\n } catch {\n Log.warn('onUrlPress', () => `Invalid URL: ${url}`);\n }\n }\n return false;\n },\n onCustomAction: () => false,\n onProductSelected: () => false,\n onPurchaseStarted: () => false,\n onPurchaseCompleted: (purchaseResult: AdaptyPurchaseResult) => purchaseResult?.type !== 'user_cancelled',\n onPurchaseFailed: () => false,\n onRestoreStarted: () => false,\n onRestoreCompleted: () => true,\n onRestoreFailed: () => false,\n onAppeared: () => false,\n onDisappeared: () => false,\n onRenderingFailed: () => true,\n onLoadingProductsFailed: () => false,\n onWebPaymentNavigationFinished: () => false,\n};\n\nexport type OnboardingStateUpdatedAction =\n | {\n elementId: string;\n elementType: 'select';\n value: AdaptyUiOnboardingStateParams;\n }\n | {\n elementId: string;\n elementType: 'multi_select';\n value: AdaptyUiOnboardingStateParams[];\n }\n | {\n elementId: string;\n elementType: 'input';\n value: { type: 'text' | 'email'; value: string } | { type: 'number'; value: number };\n }\n | {\n elementId: string;\n elementType: 'date_picker';\n value: {\n day?: number;\n month?: number;\n year?: number;\n };\n };\n\nexport interface AdaptyUiView {\n id: string;\n}\n\nexport interface AdaptyUiMediaCache {\n memoryStorageTotalCostLimit?: number;\n memoryStorageCountLimit?: number;\n diskStorageSizeLimit?: number;\n}\n\nexport interface AdaptyUiDialogConfig {\n /**\n * The action title to display as part of the dialog. If you provide two actions,\n * be sure `primaryAction` cancels the operation and leaves things unchanged.\n */\n primaryActionTitle: string;\n /**\n * The secondary action title to display as part of the dialog.\n */\n secondaryActionTitle?: string;\n /**\n * The title of the dialog.\n */\n title?: string;\n /**\n * Descriptive text that provides additional details about the reason for the dialog.\n */\n content?: string;\n}\n\nexport const AdaptyUiDialogActionType = Object.freeze({\n primary: 'primary',\n secondary: 'secondary',\n});\n\nexport type AdaptyUiDialogActionType = (typeof AdaptyUiDialogActionType)[keyof typeof AdaptyUiDialogActionType];\n\n/**\n * Additional options for creating a paywall view\n *\n * @see {@link https://adapty.io/docs/capacitor-present-paywalls | [DOC] Creating Paywall View}\n */\nexport interface CreatePaywallViewParamsInput {\n /**\n * `true` if you want to prefetch products before presenting a paywall view.\n */\n prefetchProducts?: boolean;\n /**\n * This value limits the timeout (in milliseconds) for this method.\n */\n loadTimeoutMs?: number;\n /**\n * If you are going to use custom tags functionality, pass an object with tags and corresponding replacement values\n *\n * ```\n * {\n * 'USERNAME': 'Bruce',\n * 'CITY': 'Philadelphia'\n * }\n * ```\n */\n customTags?: Record<string, string>;\n /**\n * If you are going to use custom timer functionality, pass an object with timer ids and corresponding dates the timers should end at\n */\n customTimers?: Record<string, Date>;\n /**\n * Use this when you need to override paywall assets with your own\n */\n customAssets?: Record<string, AdaptyCustomAsset>;\n /**\n * Provide per-product purchase parameters keyed by Adapty product identifier\n */\n productPurchaseParams?: ProductPurchaseParams;\n}\n\n/**\n * Additional options for creating an onboarding view\n *\n * @see {@link https://adapty.io/docs/capacitor-get-onboardings | [DOC] Creating Onboarding View}\n */\nexport interface CreateOnboardingViewParamsInput {\n /**\n * If you want to change the presentation behavior of external URLs, pass a preferred value.\n *\n * @default {@link WebPresentation.BrowserInApp}\n */\n externalUrlsPresentation?: WebPresentation;\n}\n\nexport interface OnboardingEventHandlers {\n onClose: (actionId: string, meta: AdaptyUiOnboardingMeta) => EventHandlerResult;\n onCustom: (actionId: string, meta: AdaptyUiOnboardingMeta) => EventHandlerResult;\n onPaywall: (actionId: string, meta: AdaptyUiOnboardingMeta) => EventHandlerResult;\n onStateUpdated: (action: OnboardingStateUpdatedAction, meta: AdaptyUiOnboardingMeta) => EventHandlerResult;\n onFinishedLoading: (meta: AdaptyUiOnboardingMeta) => EventHandlerResult;\n onAnalytics: (\n event: {\n name: string;\n /**\n * @deprecated Use `elementId` instead\n */\n element_id?: string;\n elementId?: string;\n reply?: string;\n },\n meta: AdaptyUiOnboardingMeta,\n ) => EventHandlerResult;\n onError: (error: AdaptyError) => EventHandlerResult;\n}\n\nexport const DEFAULT_ONBOARDING_EVENT_HANDLERS: Partial<OnboardingEventHandlers> = {\n onClose: () => true,\n};\n\n/**\n * iOS presentation style for paywall and onboarding views\n * @platform ios\n */\nexport type AdaptyIOSPresentationStyle = 'full_screen' | 'page_sheet';\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ui-builder/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AA4BhC,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAsB;IAC5D,kBAAkB,EAAE,GAAG,EAAE,CAAC,IAAI;IAC9B,mBAAmB,EAAE,GAAG,EAAE,CAAC,KAAK;IAChC,wEAAwE;IACxE,6EAA6E;IAC7E,iEAAiE;IACjE,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QAC1B,MAAM;aACH,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;aAC3B,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAC,CAAC;QAE7F,OAAO,KAAK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C3E,uBAAuB;IACvB,2BAA2B,EAAE,GAAG,EAAE;QAChC,GAAG,CAAC,IAAI,CACN,6BAA6B,EAC7B,GAAG,EAAE,CACH,wIAAwI,CAC3I,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC;IACD,0BAA0B,EAAE,GAAG,EAAE;QAC/B,GAAG,CAAC,IAAI,CACN,4BAA4B,EAC5B,GAAG,EAAE,CACH,sIAAsI,CACzI,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAqC;IACjF,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;CACpB,CAAC","sourcesContent":["import type { FlowEventHandlers, OnboardingEventHandlers } from '@adapty/core';\n\nimport { adapty } from '../adapty-instance';\nimport { Log } from '../logger';\n\n// Re-export all shared UI types from @adapty/core\nexport type {\n EventHandlerResult,\n ProductPurchaseParams,\n FlowEventHandlers,\n OnboardingEventHandlers,\n OnboardingAnalyticsEventName,\n AdaptyUiOnboardingMeta,\n AdaptyUiOnboardingStateParams,\n OnboardingStateUpdatedAction,\n FlowPermissionResponse,\n FlowPermissionStatus,\n AdaptyPermission,\n CreateFlowViewParamsInput,\n CreateOnboardingViewParamsInput,\n AdaptyUiView,\n AdaptyUiMediaCache,\n AdaptyUiDialogConfig,\n AdaptyCustomAsset,\n AdaptyCustomImageAsset,\n AdaptyCustomVideoAsset,\n AdaptyCustomColorAsset,\n AdaptyCustomGradientAsset,\n AdaptyIOSPresentationStyle,\n} from '@adapty/core';\n\nexport { AdaptyUiDialogActionType } from '@adapty/core';\n\n/**\n * Default flow-view event handlers. Mirrors react-native-adapty v4 defaults:\n * most handlers keep the view open (return false); onCloseButtonPress and\n * onError close it (return true). onUrlPress / onRequestAppReview delegate to\n * the native handler methods.\n *\n * @internal\n */\nexport const DEFAULT_FLOW_EVENT_HANDLERS: FlowEventHandlers = {\n onCloseButtonPress: () => true,\n onAndroidSystemBack: () => false,\n // Delegate to the handler method, which opens the URL natively honoring\n // `open_in` (`browser_out_app` → external browser, `browser_in_app` → in-app\n // browser). Override this handler to open URLs yourself instead.\n onUrlPress: (url, openIn) => {\n adapty\n .openWebUrl({ url, openIn })\n .catch((error) => Log.warn('onUrlPress', () => `Failed to open url via native: ${error}`));\n\n return false; // Keep flow view open\n },\n onCustomAction: () => false,\n onProductSelected: () => false,\n onPurchaseStarted: () => false,\n onPurchaseCompleted: () => false,\n onPurchaseFailed: () => false,\n onRestoreStarted: () => false,\n onRestoreCompleted: () => false,\n onRestoreFailed: () => false,\n onAppeared: () => false,\n onDisappeared: () => false,\n onError: () => true,\n onLoadingProductsFailed: () => false,\n onWebPaymentNavigationFinished: () => false,\n // Delegate to the handler method, which shows the platform app-review prompt\n // natively (`SKStoreReviewController` on iOS, In-App Review on Android).\n // Override this handler to control the prompt yourself instead.\n onRequestAppReview: () => {\n void adapty\n .requestAppReview()\n .catch((error) => Log.warn('onRequestAppReview', () => `Failed to request app review via native: ${error}`));\n\n return false; // Keep flow view open\n },\n onAnalytics: () => false,\n // There is no real default here: permissions must be declared in the app\n // bundle by the developer, so we cannot grant them on the user's behalf. Warn\n // and reply `denied` so native always gets a correlated answer.\n onRequestPermission: async () => {\n Log.warn(\n 'onRequestPermission',\n () =>\n 'No onRequestPermission handler provided; replying `denied`. Declare the required ' +\n 'permissions in your app and provide an onRequestPermission handler to respond.',\n );\n\n return { status: 'denied' as const };\n },\n // Observer mode: no real default. If you enable observer mode and present a\n // flow view, you must drive the purchase/restore yourself, so warn when no\n // handler is provided.\n onObserverPurchaseInitiated: () => {\n Log.warn(\n 'onObserverPurchaseInitiated',\n () =>\n 'No onObserverPurchaseInitiated handler provided. In observer mode you must drive the purchase yourself; provide this handler to do so.',\n );\n\n return false;\n },\n onObserverRestoreInitiated: () => {\n Log.warn(\n 'onObserverRestoreInitiated',\n () =>\n 'No onObserverRestoreInitiated handler provided. In observer mode you must drive the restore yourself; provide this handler to do so.',\n );\n\n return false;\n },\n};\n\n/**\n * @internal\n */\nexport const DEFAULT_ONBOARDING_EVENT_HANDLERS: Partial<OnboardingEventHandlers> = {\n onClose: () => true,\n};\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "
|
|
1
|
+
declare const _default: "4.0.0-beta.1";
|
|
2
2
|
export default _default;
|
package/dist/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default '
|
|
1
|
+
export default '4.0.0-beta.1';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAe,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAe,cAAc,CAAC","sourcesContent":["export default '4.0.0-beta.1';\n"]}
|