@inttegro/svelte 0.4.0 → 0.5.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.
@@ -16,6 +16,7 @@
16
16
  locale,
17
17
  onCanceled,
18
18
  onCompleted,
19
+ onFailed,
19
20
  onError,
20
21
  onEvent,
21
22
  onReady,
@@ -57,6 +58,7 @@
57
58
 
58
59
  let active = true
59
60
  let canceled = false
61
+ let failed = false
60
62
  let instance: CheckoutController | undefined
61
63
  let unsubscribe: (() => void) | undefined
62
64
 
@@ -87,13 +89,16 @@
87
89
  }
88
90
  if (event.type === 'ready') onReady?.(event)
89
91
  if (event.type === 'completed') onCompleted?.(event)
90
- if (event.type === 'error') onError?.(event)
92
+ if (event.type === 'failed') {
93
+ failed = true
94
+ onFailed?.(event)
95
+ }
91
96
  })
92
97
  if (identity.presentation === 'modal') await instance.present()
93
98
  else await instance.mount(container)
94
99
  })
95
100
  .catch((error: unknown) => {
96
- if (active && !canceled) {
101
+ if (active && !canceled && !failed) {
97
102
  onError?.(
98
103
  error instanceof Error
99
104
  ? error
package/dist/index.d.ts CHANGED
@@ -25,4 +25,4 @@
25
25
  */
26
26
  export { default as Checkout } from './Checkout.svelte';
27
27
  export type { CheckoutProps, CheckoutPropsBase } from './types';
28
- export type { CheckoutAppearance, CheckoutErrorEvent, CheckoutEvent, CheckoutFeatures, CheckoutPresentation, CheckoutTheme, } from '@inttegro/js';
28
+ export type { CheckoutAppearance, CheckoutEvent, CheckoutFailedEvent, CheckoutOrder, CheckoutFeatures, CheckoutPresentation, CheckoutTheme, } from '@inttegro/js';
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CheckoutAppearance, CheckoutErrorEvent, CheckoutEvent, CheckoutFeatures, CheckoutPresentation } from '@inttegro/js';
1
+ import type { CheckoutAppearance, CheckoutEvent, CheckoutFeatures, CheckoutPresentation } from '@inttegro/js';
2
2
  /**
3
3
  * Props accepted by the Inttegro {@link Checkout} component.
4
4
  *
@@ -29,8 +29,12 @@ export interface CheckoutPropsBase {
29
29
  onCompleted?: ((event: Extract<CheckoutEvent, {
30
30
  type: 'completed';
31
31
  }>) => void) | undefined;
32
- /** Called for loader/mount failures and sanitized hosted errors. */
33
- onError?: ((event: CheckoutErrorEvent | Error) => void) | undefined;
32
+ /** Called when Checkout reaches a terminal failure state. */
33
+ onFailed?: ((event: Extract<CheckoutEvent, {
34
+ type: 'failed';
35
+ }>) => void) | undefined;
36
+ /** Called for loader or mount failures. */
37
+ onError?: ((error: Error) => void) | undefined;
34
38
  /** Called for every sanitized lifecycle event. */
35
39
  onEvent?: ((event: CheckoutEvent) => void) | undefined;
36
40
  /** Called once Checkout is initialized and interactive. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inttegro/svelte",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Svelte components for Inttegro hosted workflows",
5
5
  "type": "module",
6
6
  "svelte": "./dist/index.js",
@@ -26,7 +26,7 @@
26
26
  "typecheck": "svelte-check --tsconfig ./tsconfig.json"
27
27
  },
28
28
  "dependencies": {
29
- "@inttegro/js": "0.4.0"
29
+ "@inttegro/js": "0.5.1"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "svelte": ">=5"