autumn-js 0.0.52 → 0.0.53

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.
@@ -59,7 +59,8 @@ var useAutumn = () => {
59
59
  metadata,
60
60
  dialog,
61
61
  callback,
62
- entityData
62
+ entityData,
63
+ openInNewTab
63
64
  } = params;
64
65
  if (dialog) {
65
66
  setProdChangeComponent(dialog);
@@ -81,7 +82,11 @@ var useAutumn = () => {
81
82
  }
82
83
  let data = result.data;
83
84
  if (data?.checkout_url && typeof window !== "undefined") {
84
- window.open(data.checkout_url, "_blank");
85
+ if (openInNewTab) {
86
+ window.open(data.checkout_url, "_blank");
87
+ } else {
88
+ window.location.href = data.checkout_url;
89
+ }
85
90
  }
86
91
  try {
87
92
  await callback?.();
@@ -16,6 +16,7 @@ interface AttachParams {
16
16
  dialog?: (data: any) => JSX.Element | React.ReactNode;
17
17
  callback?: () => Promise<void> | void;
18
18
  entityData?: EntityDataParams;
19
+ openInNewTab?: boolean;
19
20
  }
20
21
  interface CancelParams {
21
22
  productId: string;
@@ -16,6 +16,7 @@ interface AttachParams {
16
16
  dialog?: (data: any) => JSX.Element | React.ReactNode;
17
17
  callback?: () => Promise<void> | void;
18
18
  entityData?: EntityDataParams;
19
+ openInNewTab?: boolean;
19
20
  }
20
21
  interface CancelParams {
21
22
  productId: string;
@@ -725,7 +725,8 @@ var useAutumn = () => {
725
725
  metadata,
726
726
  dialog,
727
727
  callback,
728
- entityData
728
+ entityData,
729
+ openInNewTab
729
730
  } = params;
730
731
  if (dialog) {
731
732
  setProdChangeComponent(dialog);
@@ -747,7 +748,11 @@ var useAutumn = () => {
747
748
  }
748
749
  let data = result.data;
749
750
  if (data?.checkout_url && typeof window !== "undefined") {
750
- window.open(data.checkout_url, "_blank");
751
+ if (openInNewTab) {
752
+ window.open(data.checkout_url, "_blank");
753
+ } else {
754
+ window.location.href = data.checkout_url;
755
+ }
751
756
  }
752
757
  try {
753
758
  await callback?.();
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {
4
4
  useAutumn
5
- } from "../chunk-CZDMG3HO.mjs";
5
+ } from "../chunk-WCVQJZIX.mjs";
6
6
  import "../chunk-YOMNTOJZ.mjs";
7
7
  import "../chunk-XSMSOCIP.mjs";
8
8
  import "../chunk-LS3NB4DU.mjs";
@@ -1028,7 +1028,8 @@ var useAutumn = () => {
1028
1028
  metadata,
1029
1029
  dialog,
1030
1030
  callback,
1031
- entityData
1031
+ entityData,
1032
+ openInNewTab
1032
1033
  } = params;
1033
1034
  if (dialog) {
1034
1035
  setProdChangeComponent(dialog);
@@ -1050,7 +1051,11 @@ var useAutumn = () => {
1050
1051
  }
1051
1052
  let data = result.data;
1052
1053
  if (data?.checkout_url && typeof window !== "undefined") {
1053
- window.open(data.checkout_url, "_blank");
1054
+ if (openInNewTab) {
1055
+ window.open(data.checkout_url, "_blank");
1056
+ } else {
1057
+ window.location.href = data.checkout_url;
1058
+ }
1054
1059
  }
1055
1060
  try {
1056
1061
  await callback?.();
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-WFJJYHON.mjs";
6
6
  import {
7
7
  useAutumn
8
- } from "./chunk-CZDMG3HO.mjs";
8
+ } from "./chunk-WCVQJZIX.mjs";
9
9
  import {
10
10
  useCustomer
11
11
  } from "./chunk-IHEJDHR2.mjs";
@@ -15,6 +15,7 @@ interface AttachParams {
15
15
  callback?: () => Promise<void>;
16
16
  withPreview?: "formatted" | "raw";
17
17
  entityData?: EntityDataParams;
18
+ openInNewTab?: boolean;
18
19
  }
19
20
  interface CreateEntityParams {
20
21
  id: string;
@@ -15,6 +15,7 @@ interface AttachParams {
15
15
  callback?: () => Promise<void>;
16
16
  withPreview?: "formatted" | "raw";
17
17
  entityData?: EntityDataParams;
18
+ openInNewTab?: boolean;
18
19
  }
19
20
  interface CreateEntityParams {
20
21
  id: string;
@@ -12,7 +12,7 @@ interface TrackParams {
12
12
  }
13
13
 
14
14
  declare const useAutumn: () => {
15
- attach: ({ productId, entityId, options, successUrl, forceCheckout, metadata, dialog, callback, entityData, }: AttachParams) => Promise<any>;
15
+ attach: ({ productId, entityId, options, successUrl, forceCheckout, metadata, dialog, callback, entityData, openInNewTab, }: AttachParams) => Promise<any>;
16
16
  check: ({ featureId, productId, entityId, requiredQuantity, sendEvent, withPreview, dialog, entityData, }: {
17
17
  featureId?: string;
18
18
  productId?: string;
@@ -12,7 +12,7 @@ interface TrackParams {
12
12
  }
13
13
 
14
14
  declare const useAutumn: () => {
15
- attach: ({ productId, entityId, options, successUrl, forceCheckout, metadata, dialog, callback, entityData, }: AttachParams) => Promise<any>;
15
+ attach: ({ productId, entityId, options, successUrl, forceCheckout, metadata, dialog, callback, entityData, openInNewTab, }: AttachParams) => Promise<any>;
16
16
  check: ({ featureId, productId, entityId, requiredQuantity, sendEvent, withPreview, dialog, entityData, }: {
17
17
  featureId?: string;
18
18
  productId?: string;
@@ -34,7 +34,8 @@ const useAutumn = () => {
34
34
  forceCheckout,
35
35
  metadata,
36
36
  callback,
37
- entityData
37
+ entityData,
38
+ openInNewTab
38
39
  }) => {
39
40
  const attachWithoutDialog = async (options) => {
40
41
  try {
@@ -45,7 +46,8 @@ const useAutumn = () => {
45
46
  successUrl,
46
47
  forceCheckout,
47
48
  metadata,
48
- entityData
49
+ entityData,
50
+ openInNewTab
49
51
  });
50
52
  } catch (error2) {
51
53
  return toClientErrorResponse(error2);
@@ -82,7 +84,8 @@ const useAutumn = () => {
82
84
  metadata,
83
85
  dialog,
84
86
  callback,
85
- entityData
87
+ entityData,
88
+ openInNewTab
86
89
  }) => {
87
90
  if (dialog) {
88
91
  setProdChangeComponent(dialog);
@@ -93,7 +96,8 @@ const useAutumn = () => {
93
96
  forceCheckout,
94
97
  metadata,
95
98
  callback,
96
- entityData
99
+ entityData,
100
+ openInNewTab
97
101
  });
98
102
  }
99
103
  let snakeOptions = options?.map((option) => ({
@@ -115,7 +119,11 @@ const useAutumn = () => {
115
119
  }
116
120
  let data = result.data;
117
121
  if (data?.checkout_url && typeof window !== "undefined") {
118
- window.open(data.checkout_url, "_blank");
122
+ if (openInNewTab) {
123
+ window.open(data.checkout_url, "_blank");
124
+ } else {
125
+ window.open(data.checkout_url, "_self");
126
+ }
119
127
  }
120
128
  try {
121
129
  await callback?.();
@@ -34,7 +34,8 @@ const useAutumn = () => {
34
34
  forceCheckout,
35
35
  metadata,
36
36
  callback,
37
- entityData
37
+ entityData,
38
+ openInNewTab
38
39
  }) => {
39
40
  const attachWithoutDialog = async (options) => {
40
41
  try {
@@ -45,7 +46,8 @@ const useAutumn = () => {
45
46
  successUrl,
46
47
  forceCheckout,
47
48
  metadata,
48
- entityData
49
+ entityData,
50
+ openInNewTab
49
51
  });
50
52
  } catch (error2) {
51
53
  return toClientErrorResponse(error2);
@@ -82,7 +84,8 @@ const useAutumn = () => {
82
84
  metadata,
83
85
  dialog,
84
86
  callback,
85
- entityData
87
+ entityData,
88
+ openInNewTab
86
89
  }) => {
87
90
  if (dialog) {
88
91
  setProdChangeComponent(dialog);
@@ -93,7 +96,8 @@ const useAutumn = () => {
93
96
  forceCheckout,
94
97
  metadata,
95
98
  callback,
96
- entityData
99
+ entityData,
100
+ openInNewTab
97
101
  });
98
102
  }
99
103
  let snakeOptions = options?.map((option) => ({
@@ -115,7 +119,11 @@ const useAutumn = () => {
115
119
  }
116
120
  let data = result.data;
117
121
  if (data?.checkout_url && typeof window !== "undefined") {
118
- window.open(data.checkout_url, "_blank");
122
+ if (openInNewTab) {
123
+ window.open(data.checkout_url, "_blank");
124
+ } else {
125
+ window.open(data.checkout_url, "_self");
126
+ }
119
127
  }
120
128
  try {
121
129
  await callback?.();
@@ -23,6 +23,7 @@ interface AttachParams {
23
23
  callback?: () => Promise<void>;
24
24
  withPreview?: "formatted" | "raw";
25
25
  entityData?: EntityDataParams;
26
+ openInNewTab?: boolean;
26
27
  }
27
28
  interface CreateEntityParams {
28
29
  id: string;
@@ -40,7 +41,7 @@ interface TrackParams {
40
41
  }
41
42
 
42
43
  declare const useAutumn: () => {
43
- attach: ({ productId, entityId, options, successUrl, forceCheckout, metadata, dialog, callback, entityData, }: AttachParams) => Promise<any>;
44
+ attach: ({ productId, entityId, options, successUrl, forceCheckout, metadata, dialog, callback, entityData, openInNewTab, }: AttachParams) => Promise<any>;
44
45
  check: ({ featureId, productId, entityId, requiredQuantity, sendEvent, withPreview, dialog, entityData, }: {
45
46
  featureId?: string;
46
47
  productId?: string;
@@ -23,6 +23,7 @@ interface AttachParams {
23
23
  callback?: () => Promise<void>;
24
24
  withPreview?: "formatted" | "raw";
25
25
  entityData?: EntityDataParams;
26
+ openInNewTab?: boolean;
26
27
  }
27
28
  interface CreateEntityParams {
28
29
  id: string;
@@ -40,7 +41,7 @@ interface TrackParams {
40
41
  }
41
42
 
42
43
  declare const useAutumn: () => {
43
- attach: ({ productId, entityId, options, successUrl, forceCheckout, metadata, dialog, callback, entityData, }: AttachParams) => Promise<any>;
44
+ attach: ({ productId, entityId, options, successUrl, forceCheckout, metadata, dialog, callback, entityData, openInNewTab, }: AttachParams) => Promise<any>;
44
45
  check: ({ featureId, productId, entityId, requiredQuantity, sendEvent, withPreview, dialog, entityData, }: {
45
46
  featureId?: string;
46
47
  productId?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "autumn-js",
3
3
  "description": "Autumn JS Library",
4
- "version": "0.0.52",
4
+ "version": "0.0.53",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
7
7
  "cli": "tsx src/cli/index.ts",