@getsupertab/supertab-js 3.20.6 → 3.22.0
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/README.md +5 -5
- package/dist/pkg/prod/{browser-ponyfill-Bd1SQoXo.js → browser-ponyfill-DQtSolF7.js} +1 -1
- package/dist/pkg/prod/{sentry-D_ec_r5z.js → sentry-BfU8w763.js} +1 -1
- package/dist/pkg/prod/{supertab-BrPk-nCo.js → supertab-B8Vn8zcc.js} +45 -25
- package/dist/pkg/prod/supertab.d.ts +23 -4
- package/dist/pkg/prod/supertab.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,17 +22,17 @@ const supertab = new Supertab({
|
|
|
22
22
|
clientId: "client.xyz",
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
const { show } = supertab.
|
|
25
|
+
const { show } = supertab.createPaywall({
|
|
26
26
|
experienceId: "experience.xyz",
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
console.log(
|
|
29
|
+
const paywallResult = await show();
|
|
30
|
+
console.log(paywallResult);
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
This example creates a new Supertab.js instance using the `new Supertab()` constructor.
|
|
34
|
-
Then, the `
|
|
35
|
-
The `show` function renders the
|
|
34
|
+
Then, the `createPaywall` method is used to create a new paywall.
|
|
35
|
+
The `show` function renders the paywall. Finally, once the user has completed or cancelled the purchase,
|
|
36
36
|
we print the result data to the browser console.
|
|
37
37
|
|
|
38
38
|
We've put a placeholder client ID and experience ID in this example.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as mu, T as gu, P as _u, a as Su, V as yu } from "./supertab-
|
|
1
|
+
import { r as mu, T as gu, P as _u, a as Su, V as yu } from "./supertab-B8Vn8zcc.js";
|
|
2
2
|
const b = typeof __SENTRY_DEBUG__ > "u" || __SENTRY_DEBUG__, q = globalThis, at = "9.40.0";
|
|
3
3
|
function ht() {
|
|
4
4
|
return lr(q), q;
|
|
@@ -4855,7 +4855,7 @@ const bA = sr({
|
|
|
4855
4855
|
VITE_STATIC_REDIRECT_URI: void 0,
|
|
4856
4856
|
VITE_GTM_CONTAINER_ID: "GTM-NG9GT7FM",
|
|
4857
4857
|
VITE_SENTRY_DSN: "https://d08f3f301f364ceba6345c393c538faf@o23455.ingest.us.sentry.io/4507736861573120",
|
|
4858
|
-
VITE_BASE_URL: "https://js.supertab.co/v3.
|
|
4858
|
+
VITE_BASE_URL: "https://js.supertab.co/v3.22.0/",
|
|
4859
4859
|
VITE_DEMO_CLIENT_ID: void 0,
|
|
4860
4860
|
VITE_API_BASE_URL: void 0,
|
|
4861
4861
|
VITE_SSO_BASE_URL: void 0,
|
|
@@ -4864,7 +4864,7 @@ const bA = sr({
|
|
|
4864
4864
|
VITE_CHECKOUT_URL: void 0,
|
|
4865
4865
|
TAPPER_ENV: "prod",
|
|
4866
4866
|
PACKAGE_NAME: "@getsupertab/supertab-js",
|
|
4867
|
-
PACKAGE_VERSION: "3.
|
|
4867
|
+
PACKAGE_VERSION: "3.22.0",
|
|
4868
4868
|
MONETIZATION_PROVIDER_SCRIPT_URL: void 0
|
|
4869
4869
|
}), I3 = US === "ctl" || US === "sbx" || US === "stg" ? !0 : US === "prod" && typeof window < "u" && window.location ? new URLSearchParams(window.location.search).has("supertab-enable-logging") : !1, Yt = {
|
|
4870
4870
|
log: (...o) => {
|
|
@@ -5564,7 +5564,7 @@ const rr = /* @__PURE__ */ F_(M), g4 = /* @__PURE__ */ FP({
|
|
|
5564
5564
|
default: rr
|
|
5565
5565
|
}, [M]), IS = async (o) => {
|
|
5566
5566
|
if (wA) {
|
|
5567
|
-
const { captureException: a } = await import("./sentry-
|
|
5567
|
+
const { captureException: a } = await import("./sentry-BfU8w763.js");
|
|
5568
5568
|
a(o);
|
|
5569
5569
|
}
|
|
5570
5570
|
}, qC = "tabjs";
|
|
@@ -6212,38 +6212,40 @@ class yM {
|
|
|
6212
6212
|
async purchase({
|
|
6213
6213
|
offeringId: a,
|
|
6214
6214
|
purchaseIntentId: s,
|
|
6215
|
-
|
|
6216
|
-
|
|
6215
|
+
onetimeOfferingId: f,
|
|
6216
|
+
currencyCode: d = "USD",
|
|
6217
|
+
metadata: g = {}
|
|
6217
6218
|
}) {
|
|
6218
|
-
if (!a && !s) {
|
|
6219
|
-
const
|
|
6219
|
+
if (!a && !s && !f) {
|
|
6220
|
+
const C = "Missing parameter: Provide one of 'offeringId' or 'onetimeOfferingId' (deprecated: 'purchaseIntentId').";
|
|
6220
6221
|
throw new f4({
|
|
6221
|
-
message:
|
|
6222
|
+
message: C,
|
|
6222
6223
|
code: xy.MISSING_PARAMETER
|
|
6223
6224
|
});
|
|
6224
6225
|
}
|
|
6225
6226
|
if (a)
|
|
6226
6227
|
return v2(async () => {
|
|
6227
|
-
const
|
|
6228
|
-
return g2(
|
|
6228
|
+
const C = new URL(this.apiConfig.urls.apiBaseUrl), k = this.apiConfig.headers;
|
|
6229
|
+
return g2(C, "post", "/purchases/offerings", {
|
|
6229
6230
|
header: {
|
|
6230
|
-
...
|
|
6231
|
+
...k,
|
|
6231
6232
|
contentType: "application/json"
|
|
6232
6233
|
// TODO: Remove this once we have a proper type for the header
|
|
6233
6234
|
},
|
|
6234
|
-
body: { offeringId: a, currencyCode:
|
|
6235
|
+
body: { offeringId: a, currencyCode: d, metadata: g ?? {} }
|
|
6235
6236
|
});
|
|
6236
6237
|
}).call(this);
|
|
6237
|
-
|
|
6238
|
+
const v = f || s;
|
|
6239
|
+
if (v)
|
|
6238
6240
|
return v2(async () => {
|
|
6239
|
-
const
|
|
6240
|
-
return g2(
|
|
6241
|
+
const C = new URL(this.apiConfig.urls.apiBaseUrl), k = this.apiConfig.headers;
|
|
6242
|
+
return g2(C, "post", "/purchases/onetime_offerings", {
|
|
6241
6243
|
header: {
|
|
6242
|
-
...
|
|
6244
|
+
...k,
|
|
6243
6245
|
contentType: "application/json"
|
|
6244
6246
|
// TODO: Remove this once we have a proper type for the header
|
|
6245
6247
|
},
|
|
6246
|
-
body: { onetimeOfferingId:
|
|
6248
|
+
body: { onetimeOfferingId: v }
|
|
6247
6249
|
});
|
|
6248
6250
|
}).call(this);
|
|
6249
6251
|
}
|
|
@@ -64753,7 +64755,7 @@ typeof ActiveXObject == "function" && (typeof global < "u" && global.ActiveXObje
|
|
|
64753
64755
|
typeof r0 != "function" && (r0 = void 0);
|
|
64754
64756
|
if (!r0 && !mk && !z4)
|
|
64755
64757
|
try {
|
|
64756
|
-
import("./browser-ponyfill-
|
|
64758
|
+
import("./browser-ponyfill-DQtSolF7.js").then((o) => o.b).then(function(o) {
|
|
64757
64759
|
r0 = o.default;
|
|
64758
64760
|
}).catch(function() {
|
|
64759
64761
|
});
|
|
@@ -65655,7 +65657,7 @@ class Tq extends gq {
|
|
|
65655
65657
|
supertabConfig: this.supertabConfig
|
|
65656
65658
|
}), this.api = new yM(this.apiConfig), this.auth = new bM(this.apiConfig), this.checkout = new wM(this.apiConfig);
|
|
65657
65659
|
}
|
|
65658
|
-
async
|
|
65660
|
+
async createPaywall({
|
|
65659
65661
|
merchantName: s,
|
|
65660
65662
|
merchantLogoUrl: f,
|
|
65661
65663
|
language: d,
|
|
@@ -65668,7 +65670,7 @@ class Tq extends gq {
|
|
|
65668
65670
|
const Te = document.body.style.overflow === "hidden";
|
|
65669
65671
|
if (W) {
|
|
65670
65672
|
C === null && !Te && (C = document.body.style.overflow || "", document.body.style.overflow = "hidden", Yt.log(
|
|
65671
|
-
"Supertab: Preventing page scrolling while
|
|
65673
|
+
"Supertab: Preventing page scrolling while paywall is visible"
|
|
65672
65674
|
));
|
|
65673
65675
|
return;
|
|
65674
65676
|
}
|
|
@@ -65682,10 +65684,10 @@ class Tq extends gq {
|
|
|
65682
65684
|
onError: (W) => {
|
|
65683
65685
|
throw IS(W), W;
|
|
65684
65686
|
},
|
|
65685
|
-
errorPrefix: "
|
|
65687
|
+
errorPrefix: "PaywallError"
|
|
65686
65688
|
}), { containerElement: O, shadowRoot: T, appElement: P } = this.createPaygateContainer(), D = await this.setupStyles(
|
|
65687
65689
|
T,
|
|
65688
|
-
"supertab-
|
|
65690
|
+
"supertab-paywall"
|
|
65689
65691
|
);
|
|
65690
65692
|
let A = null;
|
|
65691
65693
|
const { purchaseWidgetActor: F } = await _.initialize(), H = (W, ae) => async ({ offeringId: Te }) => {
|
|
@@ -65742,7 +65744,7 @@ class Tq extends gq {
|
|
|
65742
65744
|
const { priorEntitlement: Te } = F.getSnapshot().context;
|
|
65743
65745
|
if (Te) {
|
|
65744
65746
|
Yt.warn(
|
|
65745
|
-
"Not showing
|
|
65747
|
+
"Not showing Paywall because user has an entitlement"
|
|
65746
65748
|
), W(
|
|
65747
65749
|
yy(
|
|
65748
65750
|
F.getSnapshot().context
|
|
@@ -65779,9 +65781,27 @@ class Tq extends gq {
|
|
|
65779
65781
|
initialState: ue
|
|
65780
65782
|
};
|
|
65781
65783
|
} catch (C) {
|
|
65782
|
-
throw Yt.error("
|
|
65784
|
+
throw Yt.error("PaywallError: Failed to create Paywall:", C), C;
|
|
65783
65785
|
}
|
|
65784
65786
|
}
|
|
65787
|
+
/**
|
|
65788
|
+
* @deprecated Use createPaywall instead.
|
|
65789
|
+
*/
|
|
65790
|
+
async createPaygate({
|
|
65791
|
+
merchantName: s,
|
|
65792
|
+
merchantLogoUrl: f,
|
|
65793
|
+
language: d,
|
|
65794
|
+
experienceId: g,
|
|
65795
|
+
purchaseMetadata: v
|
|
65796
|
+
} = {}) {
|
|
65797
|
+
return this.createPaywall({
|
|
65798
|
+
merchantName: s,
|
|
65799
|
+
merchantLogoUrl: f,
|
|
65800
|
+
language: d,
|
|
65801
|
+
experienceId: g,
|
|
65802
|
+
purchaseMetadata: v
|
|
65803
|
+
});
|
|
65804
|
+
}
|
|
65785
65805
|
async createPurchaseButton({
|
|
65786
65806
|
containerElement: s,
|
|
65787
65807
|
label: f,
|
|
@@ -65867,7 +65887,7 @@ class Tq extends gq {
|
|
|
65867
65887
|
}
|
|
65868
65888
|
createPaygateContainer() {
|
|
65869
65889
|
const s = document.createElement("div");
|
|
65870
|
-
s.setAttribute("data-testid", "supertab-
|
|
65890
|
+
s.setAttribute("data-testid", "supertab-paywall-container");
|
|
65871
65891
|
const f = s.attachShadow({ mode: "open" }), d = document.createElement("div");
|
|
65872
65892
|
return f.appendChild(d), document.body.appendChild(s), { containerElement: s, shadowRoot: f, appElement: d };
|
|
65873
65893
|
}
|
|
@@ -174,7 +174,7 @@ declare class ApiClient {
|
|
|
174
174
|
}[] | null;
|
|
175
175
|
metadata?: unknown;
|
|
176
176
|
}>;
|
|
177
|
-
purchase({ offeringId, purchaseIntentId, currencyCode, metadata, }: PurchaseOfferingRequestClientFacing): Promise<{
|
|
177
|
+
purchase({ offeringId, purchaseIntentId, onetimeOfferingId, currencyCode, metadata, }: PurchaseOfferingRequestClientFacing): Promise<{
|
|
178
178
|
purchase: {
|
|
179
179
|
status: "completed" | "pending" | "abandoned";
|
|
180
180
|
id: string;
|
|
@@ -301,7 +301,11 @@ declare enum AuthStatus {
|
|
|
301
301
|
|
|
302
302
|
declare type BaseForPurchaseOfferingRequestClientFacing = Omit<PurchaseOfferingRequest, "metadata"> & {
|
|
303
303
|
metadata?: Metadata;
|
|
304
|
-
|
|
304
|
+
onetimeOfferingId?: string;
|
|
305
|
+
/**
|
|
306
|
+
* @deprecated Use onetimeOfferingId instead.
|
|
307
|
+
*/
|
|
308
|
+
purchaseIntentId?: string;
|
|
305
309
|
};
|
|
306
310
|
|
|
307
311
|
declare class CheckoutClient {
|
|
@@ -379,7 +383,12 @@ declare interface Offering {
|
|
|
379
383
|
isPayNow: boolean;
|
|
380
384
|
}
|
|
381
385
|
|
|
382
|
-
|
|
386
|
+
/**
|
|
387
|
+
* @deprecated Use PaywallExperienceResult instead.
|
|
388
|
+
*/
|
|
389
|
+
declare type PaygateExperienceResult = PaywallExperienceResult;
|
|
390
|
+
|
|
391
|
+
declare interface PaywallExperienceResult {
|
|
383
392
|
show: () => Promise<ExperienceStateSummary>;
|
|
384
393
|
logIn: () => Promise<ExperienceStateSummary>;
|
|
385
394
|
destroy: () => void;
|
|
@@ -409,7 +418,7 @@ declare type PurchaseOfferingRequest = {
|
|
|
409
418
|
metadata: Metadata;
|
|
410
419
|
};
|
|
411
420
|
|
|
412
|
-
declare type PurchaseOfferingRequestClientFacing = RequireAtLeastOne<BaseForPurchaseOfferingRequestClientFacing, "offeringId" | "purchaseIntentId">;
|
|
421
|
+
declare type PurchaseOfferingRequestClientFacing = RequireAtLeastOne<BaseForPurchaseOfferingRequestClientFacing, "offeringId" | "onetimeOfferingId" | "purchaseIntentId">;
|
|
413
422
|
|
|
414
423
|
declare enum PurchaseStatus {
|
|
415
424
|
COMPLETED = "completed",
|
|
@@ -430,6 +439,16 @@ export declare class Supertab extends SupertabClient {
|
|
|
430
439
|
auth: AuthClient;
|
|
431
440
|
checkout: CheckoutClient;
|
|
432
441
|
constructor(supertabConfig: SupertabConfig);
|
|
442
|
+
createPaywall({ merchantName, merchantLogoUrl, language, experienceId, purchaseMetadata, }?: {
|
|
443
|
+
merchantName?: string;
|
|
444
|
+
merchantLogoUrl?: string;
|
|
445
|
+
language?: string;
|
|
446
|
+
experienceId?: string;
|
|
447
|
+
purchaseMetadata?: Metadata;
|
|
448
|
+
}): Promise<PaywallExperienceResult>;
|
|
449
|
+
/**
|
|
450
|
+
* @deprecated Use createPaywall instead.
|
|
451
|
+
*/
|
|
433
452
|
createPaygate({ merchantName, merchantLogoUrl, language, experienceId, purchaseMetadata, }?: {
|
|
434
453
|
merchantName?: string;
|
|
435
454
|
merchantLogoUrl?: string;
|