@extenshi/pay 0.7.1 → 0.8.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 +11 -9
- package/dist/api/mock.d.ts +4 -0
- package/dist/api/mock.d.ts.map +1 -1
- package/dist/api/pay-api.d.ts +10 -3
- package/dist/api/pay-api.d.ts.map +1 -1
- package/dist/api/transport.d.ts.map +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/extenshi-pay.d.ts +21 -2
- package/dist/core/extenshi-pay.d.ts.map +1 -1
- package/dist/core/locale.d.ts +13 -0
- package/dist/core/locale.d.ts.map +1 -0
- package/dist/core.d.mts +208 -113
- package/dist/core.d.ts +208 -113
- package/dist/core.js +204 -14
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +204 -15
- package/dist/core.mjs.map +1 -1
- package/dist/extenshi-pay-lite.js +204 -14
- package/dist/extenshi-pay-lite.js.map +1 -1
- package/dist/extenshi-pay-lite.min.js +3 -2
- package/dist/extenshi-pay-lite.min.js.map +1 -1
- package/dist/extenshi-pay-lite.mjs +204 -15
- package/dist/extenshi-pay-lite.mjs.map +1 -1
- package/dist/extenshi-pay.cjs.js +1234 -180
- package/dist/extenshi-pay.cjs.js.map +1 -1
- package/dist/extenshi-pay.d.ts.map +1 -1
- package/dist/extenshi-pay.js +1234 -180
- package/dist/extenshi-pay.js.map +1 -1
- package/dist/extenshi-pay.min.js +3 -2
- package/dist/extenshi-pay.min.js.map +1 -1
- package/dist/extenshi-pay.min.mjs +3 -2
- package/dist/extenshi-pay.min.mjs.map +1 -1
- package/dist/extenshi-pay.mjs +1231 -181
- package/dist/extenshi-pay.mjs.map +1 -1
- package/dist/index.d.mts +268 -117
- package/dist/index.d.ts +268 -117
- package/dist/lite.d.mts +176 -82
- package/dist/lite.d.ts +176 -82
- package/dist/lite.d.ts.map +1 -1
- package/dist/payment/checkout.d.ts.map +1 -1
- package/dist/payment/recovery.d.ts +2 -0
- package/dist/payment/recovery.d.ts.map +1 -1
- package/dist/payment/withdrawal-waiver.d.ts +26 -0
- package/dist/payment/withdrawal-waiver.d.ts.map +1 -0
- package/dist/paywall/billing-profile-picker.d.ts +1 -1
- package/dist/paywall/billing-profile-picker.d.ts.map +1 -1
- package/dist/paywall/i18n.d.ts +94 -0
- package/dist/paywall/i18n.d.ts.map +1 -0
- package/dist/paywall/index.d.ts +2 -1
- package/dist/paywall/index.d.ts.map +1 -1
- package/dist/paywall/license-panel.d.ts +4 -1
- package/dist/paywall/license-panel.d.ts.map +1 -1
- package/dist/paywall/renderer.d.ts +16 -2
- package/dist/paywall/renderer.d.ts.map +1 -1
- package/dist/paywall/seller-details.d.ts +2 -1
- package/dist/paywall/seller-details.d.ts.map +1 -1
- package/dist/paywall/strings.d.ts +6 -4
- package/dist/paywall/strings.d.ts.map +1 -1
- package/dist/paywall.d.mts +93 -7
- package/dist/paywall.d.ts +93 -7
- package/dist/paywall.js +992 -41
- package/dist/paywall.js.map +1 -1
- package/dist/paywall.mjs +990 -42
- package/dist/paywall.mjs.map +1 -1
- package/dist/types/config.d.ts +6 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/contract.d.ts +25 -0
- package/dist/types/contract.d.ts.map +1 -1
- package/dist/types/entitlement.d.ts +22 -0
- package/dist/types/entitlement.d.ts.map +1 -1
- package/dist/types/errors.d.ts +1 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/paywall.d.ts +15 -2
- package/dist/types/paywall.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/dist/core.esm.js +0 -1681
- package/dist/core.esm.js.map +0 -1
- package/dist/extenshi-pay-lite.esm.js +0 -1664
- package/dist/extenshi-pay-lite.esm.js.map +0 -1
- package/dist/extenshi-pay.esm.js +0 -2496
- package/dist/extenshi-pay.esm.js.map +0 -1
- package/dist/extenshi-pay.esm.min.js +0 -7
- package/dist/extenshi-pay.esm.min.js.map +0 -1
- package/dist/paywall.esm.js +0 -442
- package/dist/paywall.esm.js.map +0 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* promotional claims here without marketing/legal review (see
|
|
2
|
+
* The paywall's strings in a locale, from the SDK dictionary (./i18n.ts).
|
|
3
|
+
* Do not add promotional claims without marketing/legal review (see
|
|
5
4
|
* .claude/modules/paywall-templates.md).
|
|
6
5
|
*/
|
|
7
6
|
import type { PaywallStrings } from '../types/paywall.js';
|
|
8
|
-
|
|
7
|
+
/** English (the default and the fallback). */
|
|
9
8
|
export declare const DEFAULT_STRINGS: PaywallStrings;
|
|
9
|
+
export declare const MOCK_PAYMENT_NOTICE: string;
|
|
10
|
+
/** The paywall strings for `locale` (English when we have no translation). */
|
|
11
|
+
export declare function stringsFor(locale: string | null | undefined): PaywallStrings;
|
|
10
12
|
//# sourceMappingURL=strings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/paywall/strings.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/paywall/strings.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AA2BzD,8CAA8C;AAC9C,eAAO,MAAM,eAAe,EAAE,cAA+C,CAAA;AAE7E,eAAO,MAAM,mBAAmB,QAA4B,CAAA;AAE5D,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc,CAE5E"}
|
package/dist/paywall.d.mts
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every string the SDK shows to the USER of an extension — paywall, license
|
|
3
|
+
* dialog, billing-profile picker, seller details — in the end-user languages
|
|
4
|
+
* (ROADMAP it. 13 T10, stage L2; closes it. 12 T9). Developer-facing error
|
|
5
|
+
* messages stay English.
|
|
6
|
+
*
|
|
7
|
+
* Self-contained on purpose: the SDK ships inside third-party extensions with
|
|
8
|
+
* no runtime dependencies and no remote code, so the dictionary is compiled
|
|
9
|
+
* in. Placeholders are `{name}`, `{date}`, `{status}`. A missing
|
|
10
|
+
* translation falls back to English, never to an empty string. The same
|
|
11
|
+
* languages as the hosted pages (shared-types END_USER_LOCALES); keep the
|
|
12
|
+
* lists in sync.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
declare const SDK_LOCALES: readonly ["en", "es", "pt-BR", "fr", "de", "it", "ru", "ja", "ko", "zh-CN", "ar"];
|
|
16
|
+
type SdkLocale = (typeof SDK_LOCALES)[number];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Buyer-facing withdrawal-waiver text (EU/EEA digital content, Directive
|
|
20
|
+
* 2011/83/EU art. 16(m); UK CCR 2013 reg. 37), per text version and SDK
|
|
21
|
+
* language. Its own module, not part of the paywall dictionary, so Lite can
|
|
22
|
+
* show it without bundling every paywall string.
|
|
23
|
+
*
|
|
24
|
+
* The recorded consent names the version, so a version's words never change:
|
|
25
|
+
* new wording is a new version here and a new PAY_WITHDRAWAL_WAIVER_VERSION.
|
|
26
|
+
*
|
|
27
|
+
* MIRRORED in shared-types/pay-withdrawal-waiver.ts, which the purchase
|
|
28
|
+
* confirmation email quotes; shared-types/pay-withdrawal-waiver.test.ts fails
|
|
29
|
+
* unless both copies are byte-identical. Change them together.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
declare const WITHDRAWAL_WAIVER_TEXTS: Readonly<Record<string, Readonly<Record<SdkLocale, string>>>>;
|
|
33
|
+
/**
|
|
34
|
+
* The waiver text to show for `serverVersion`, and the version to send with
|
|
35
|
+
* the consent. A version this SDK does not know (a newer server) shows this
|
|
36
|
+
* SDK's current text and sends its version: the consent always names the words
|
|
37
|
+
* actually shown.
|
|
38
|
+
*/
|
|
39
|
+
declare function withdrawalWaiverText(serverVersion: string, locale: string | null | undefined, seller: string): {
|
|
40
|
+
version: string;
|
|
41
|
+
text: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
1
44
|
declare const PAY_OFFER_KINDS: readonly ["one_time", "subscription", "lifetime"];
|
|
2
45
|
type PayOfferKind = (typeof PAY_OFFER_KINDS)[number];
|
|
3
46
|
declare const PAY_OFFER_INTERVALS: readonly ["month", "year"];
|
|
@@ -15,12 +58,17 @@ interface PayOfferDto {
|
|
|
15
58
|
description: string | null;
|
|
16
59
|
features: string[];
|
|
17
60
|
}
|
|
61
|
+
interface PayWithdrawalWaiver {
|
|
62
|
+
version: string;
|
|
63
|
+
}
|
|
18
64
|
/** Public author-provided contact details. Not a claim of identity verification. */
|
|
19
65
|
interface PaySellerPublic {
|
|
20
66
|
displayName: string;
|
|
21
67
|
/** HTTPS support page or plain email address. */
|
|
22
68
|
supportUrl: string;
|
|
23
69
|
termsUrl: string | null;
|
|
70
|
+
/** Optional for older servers: refunds section of the license terms. */
|
|
71
|
+
refundPolicyUrl?: string | null;
|
|
24
72
|
}
|
|
25
73
|
|
|
26
74
|
interface ThemeConfig {
|
|
@@ -34,7 +82,11 @@ interface ThemeConfig {
|
|
|
34
82
|
}
|
|
35
83
|
|
|
36
84
|
type PaywallMode = 'modal' | 'inline' | 'sidebar' | 'fullscreen' | 'minimal';
|
|
37
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Every user-visible string the paywall adds on top of the templates. The SDK
|
|
87
|
+
* fills them in the configured `locale` (src/paywall/i18n.ts); pass `strings`
|
|
88
|
+
* to override any of them.
|
|
89
|
+
*/
|
|
38
90
|
interface PaywallStrings {
|
|
39
91
|
title: string;
|
|
40
92
|
description: string;
|
|
@@ -49,6 +101,13 @@ interface PaywallStrings {
|
|
|
49
101
|
periodOnce: string;
|
|
50
102
|
footer: string;
|
|
51
103
|
restorePurchase: string;
|
|
104
|
+
/** Template headings and plan labels (were fixed English text in the templates). */
|
|
105
|
+
featuresHeading: string;
|
|
106
|
+
plansHeading: string;
|
|
107
|
+
freePlanName: string;
|
|
108
|
+
premiumPlanName: string;
|
|
109
|
+
popularBadge: string;
|
|
110
|
+
unlockHeading: string;
|
|
52
111
|
}
|
|
53
112
|
interface PaywallOptions {
|
|
54
113
|
/** Template to render (default `modal`). */
|
|
@@ -65,10 +124,24 @@ interface PaywallOptions {
|
|
|
65
124
|
/** Mount point for `inline` mode (default `document.body`). */
|
|
66
125
|
container?: HTMLElement;
|
|
67
126
|
strings?: Partial<PaywallStrings>;
|
|
68
|
-
|
|
127
|
+
/** `consent` carries the withdrawal waiver when the paywall showed one. */
|
|
128
|
+
onUpgrade?: (sku: string, consent?: UpgradeConsent) => void;
|
|
69
129
|
onClose?: () => void;
|
|
70
130
|
}
|
|
71
131
|
|
|
132
|
+
/**
|
|
133
|
+
* The buyer ticked the withdrawal-waiver checkbox (EU/EEA/UK digital content).
|
|
134
|
+
* `version` names the waiver words that were shown (`PAY_WITHDRAWAL_WAIVER_VERSION`).
|
|
135
|
+
*/
|
|
136
|
+
interface WithdrawalWaiverConsent {
|
|
137
|
+
version: string;
|
|
138
|
+
accepted: true;
|
|
139
|
+
}
|
|
140
|
+
/** What a paywall upgrade click carries besides the SKU. */
|
|
141
|
+
interface UpgradeConsent {
|
|
142
|
+
withdrawalWaiver?: WithdrawalWaiverConsent;
|
|
143
|
+
}
|
|
144
|
+
|
|
72
145
|
interface FormattedPrice {
|
|
73
146
|
/** Currency symbol/code as the locale renders it (`$`, `€`, `US$`). */
|
|
74
147
|
currency: string;
|
|
@@ -102,17 +175,25 @@ interface PaywallView {
|
|
|
102
175
|
mock?: boolean;
|
|
103
176
|
recoveryEnabled?: boolean;
|
|
104
177
|
seller?: PaySellerPublic | null;
|
|
178
|
+
/**
|
|
179
|
+
* From `PayOfferResponse.withdrawalWaiver`: when set (and the offer is
|
|
180
|
+
* purchasable) an unticked waiver checkbox gates every upgrade button.
|
|
181
|
+
* The waiver text is not overridable through `strings`: it is versioned.
|
|
182
|
+
*/
|
|
183
|
+
withdrawalWaiver?: PayWithdrawalWaiver | null;
|
|
105
184
|
locale: string | null;
|
|
106
185
|
theme: ThemeConfig;
|
|
107
186
|
strings: Partial<PaywallStrings>;
|
|
108
187
|
container?: HTMLElement;
|
|
109
188
|
}
|
|
110
189
|
interface PaywallRendererCallbacks {
|
|
111
|
-
|
|
190
|
+
/** `consent` is passed only when the paywall showed the withdrawal waiver (and it was ticked). */
|
|
191
|
+
onUpgrade: (sku: string, consent?: UpgradeConsent) => void;
|
|
112
192
|
onClose: () => void;
|
|
113
193
|
onRestore?: () => void;
|
|
114
194
|
}
|
|
115
195
|
declare const PAYWALL_HOST_CLASS = "extenshi-paywall-host";
|
|
196
|
+
declare const WITHDRAWAL_WAIVER_CLASS = "extenshi-withdrawal-waiver";
|
|
116
197
|
declare function escapeHtml(value: string): string;
|
|
117
198
|
declare function substitute(html: string, content: Record<string, string>): string;
|
|
118
199
|
declare function buildContent(view: PaywallView, strings: PaywallStrings): Record<string, string>;
|
|
@@ -128,18 +209,23 @@ declare class PaywallRenderer {
|
|
|
128
209
|
show(view: PaywallView): HTMLElement;
|
|
129
210
|
hide(): void;
|
|
130
211
|
private prune;
|
|
212
|
+
/**
|
|
213
|
+
* Inserts the unticked waiver checkbox right before the first upgrade
|
|
214
|
+
* button and keeps every upgrade button disabled until it is ticked.
|
|
215
|
+
*/
|
|
216
|
+
private mountWaiver;
|
|
131
217
|
private bind;
|
|
132
218
|
private reveal;
|
|
133
219
|
private close;
|
|
134
220
|
}
|
|
135
221
|
|
|
136
222
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* promotional claims here without marketing/legal review (see
|
|
223
|
+
* The paywall's strings in a locale, from the SDK dictionary (./i18n.ts).
|
|
224
|
+
* Do not add promotional claims without marketing/legal review (see
|
|
140
225
|
* .claude/modules/paywall-templates.md).
|
|
141
226
|
*/
|
|
142
227
|
|
|
228
|
+
/** English (the default and the fallback). */
|
|
143
229
|
declare const DEFAULT_STRINGS: PaywallStrings;
|
|
144
230
|
|
|
145
231
|
/**
|
|
@@ -156,5 +242,5 @@ declare const PAYWALL_SHARED_CSS: string;
|
|
|
156
242
|
declare const PAYWALL_TEMPLATES: Record<PaywallMode, PaywallTemplate>;
|
|
157
243
|
declare const PAYWALL_MODES: PaywallMode[];
|
|
158
244
|
|
|
159
|
-
export { DEFAULT_STRINGS, PAYWALL_HOST_CLASS, PAYWALL_MODES, PAYWALL_SHARED_CSS, PAYWALL_TEMPLATES, PaywallRenderer, buildContent, escapeHtml, formatPrice, periodLabel, resolveThemeMode, substitute, themeCss };
|
|
245
|
+
export { DEFAULT_STRINGS, PAYWALL_HOST_CLASS, PAYWALL_MODES, PAYWALL_SHARED_CSS, PAYWALL_TEMPLATES, PaywallRenderer, WITHDRAWAL_WAIVER_CLASS, WITHDRAWAL_WAIVER_TEXTS, buildContent, escapeHtml, formatPrice, periodLabel, resolveThemeMode, substitute, themeCss, withdrawalWaiverText };
|
|
160
246
|
export type { FormattedPrice, PaywallMode, PaywallOptions, PaywallRendererCallbacks, PaywallStrings, PaywallTemplate, PaywallView, ThemeConfig };
|
package/dist/paywall.d.ts
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every string the SDK shows to the USER of an extension — paywall, license
|
|
3
|
+
* dialog, billing-profile picker, seller details — in the end-user languages
|
|
4
|
+
* (ROADMAP it. 13 T10, stage L2; closes it. 12 T9). Developer-facing error
|
|
5
|
+
* messages stay English.
|
|
6
|
+
*
|
|
7
|
+
* Self-contained on purpose: the SDK ships inside third-party extensions with
|
|
8
|
+
* no runtime dependencies and no remote code, so the dictionary is compiled
|
|
9
|
+
* in. Placeholders are `{name}`, `{date}`, `{status}`. A missing
|
|
10
|
+
* translation falls back to English, never to an empty string. The same
|
|
11
|
+
* languages as the hosted pages (shared-types END_USER_LOCALES); keep the
|
|
12
|
+
* lists in sync.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
declare const SDK_LOCALES: readonly ["en", "es", "pt-BR", "fr", "de", "it", "ru", "ja", "ko", "zh-CN", "ar"];
|
|
16
|
+
type SdkLocale = (typeof SDK_LOCALES)[number];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Buyer-facing withdrawal-waiver text (EU/EEA digital content, Directive
|
|
20
|
+
* 2011/83/EU art. 16(m); UK CCR 2013 reg. 37), per text version and SDK
|
|
21
|
+
* language. Its own module, not part of the paywall dictionary, so Lite can
|
|
22
|
+
* show it without bundling every paywall string.
|
|
23
|
+
*
|
|
24
|
+
* The recorded consent names the version, so a version's words never change:
|
|
25
|
+
* new wording is a new version here and a new PAY_WITHDRAWAL_WAIVER_VERSION.
|
|
26
|
+
*
|
|
27
|
+
* MIRRORED in shared-types/pay-withdrawal-waiver.ts, which the purchase
|
|
28
|
+
* confirmation email quotes; shared-types/pay-withdrawal-waiver.test.ts fails
|
|
29
|
+
* unless both copies are byte-identical. Change them together.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
declare const WITHDRAWAL_WAIVER_TEXTS: Readonly<Record<string, Readonly<Record<SdkLocale, string>>>>;
|
|
33
|
+
/**
|
|
34
|
+
* The waiver text to show for `serverVersion`, and the version to send with
|
|
35
|
+
* the consent. A version this SDK does not know (a newer server) shows this
|
|
36
|
+
* SDK's current text and sends its version: the consent always names the words
|
|
37
|
+
* actually shown.
|
|
38
|
+
*/
|
|
39
|
+
declare function withdrawalWaiverText(serverVersion: string, locale: string | null | undefined, seller: string): {
|
|
40
|
+
version: string;
|
|
41
|
+
text: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
1
44
|
declare const PAY_OFFER_KINDS: readonly ["one_time", "subscription", "lifetime"];
|
|
2
45
|
type PayOfferKind = (typeof PAY_OFFER_KINDS)[number];
|
|
3
46
|
declare const PAY_OFFER_INTERVALS: readonly ["month", "year"];
|
|
@@ -15,12 +58,17 @@ interface PayOfferDto {
|
|
|
15
58
|
description: string | null;
|
|
16
59
|
features: string[];
|
|
17
60
|
}
|
|
61
|
+
interface PayWithdrawalWaiver {
|
|
62
|
+
version: string;
|
|
63
|
+
}
|
|
18
64
|
/** Public author-provided contact details. Not a claim of identity verification. */
|
|
19
65
|
interface PaySellerPublic {
|
|
20
66
|
displayName: string;
|
|
21
67
|
/** HTTPS support page or plain email address. */
|
|
22
68
|
supportUrl: string;
|
|
23
69
|
termsUrl: string | null;
|
|
70
|
+
/** Optional for older servers: refunds section of the license terms. */
|
|
71
|
+
refundPolicyUrl?: string | null;
|
|
24
72
|
}
|
|
25
73
|
|
|
26
74
|
interface ThemeConfig {
|
|
@@ -34,7 +82,11 @@ interface ThemeConfig {
|
|
|
34
82
|
}
|
|
35
83
|
|
|
36
84
|
type PaywallMode = 'modal' | 'inline' | 'sidebar' | 'fullscreen' | 'minimal';
|
|
37
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Every user-visible string the paywall adds on top of the templates. The SDK
|
|
87
|
+
* fills them in the configured `locale` (src/paywall/i18n.ts); pass `strings`
|
|
88
|
+
* to override any of them.
|
|
89
|
+
*/
|
|
38
90
|
interface PaywallStrings {
|
|
39
91
|
title: string;
|
|
40
92
|
description: string;
|
|
@@ -49,6 +101,13 @@ interface PaywallStrings {
|
|
|
49
101
|
periodOnce: string;
|
|
50
102
|
footer: string;
|
|
51
103
|
restorePurchase: string;
|
|
104
|
+
/** Template headings and plan labels (were fixed English text in the templates). */
|
|
105
|
+
featuresHeading: string;
|
|
106
|
+
plansHeading: string;
|
|
107
|
+
freePlanName: string;
|
|
108
|
+
premiumPlanName: string;
|
|
109
|
+
popularBadge: string;
|
|
110
|
+
unlockHeading: string;
|
|
52
111
|
}
|
|
53
112
|
interface PaywallOptions {
|
|
54
113
|
/** Template to render (default `modal`). */
|
|
@@ -65,10 +124,24 @@ interface PaywallOptions {
|
|
|
65
124
|
/** Mount point for `inline` mode (default `document.body`). */
|
|
66
125
|
container?: HTMLElement;
|
|
67
126
|
strings?: Partial<PaywallStrings>;
|
|
68
|
-
|
|
127
|
+
/** `consent` carries the withdrawal waiver when the paywall showed one. */
|
|
128
|
+
onUpgrade?: (sku: string, consent?: UpgradeConsent) => void;
|
|
69
129
|
onClose?: () => void;
|
|
70
130
|
}
|
|
71
131
|
|
|
132
|
+
/**
|
|
133
|
+
* The buyer ticked the withdrawal-waiver checkbox (EU/EEA/UK digital content).
|
|
134
|
+
* `version` names the waiver words that were shown (`PAY_WITHDRAWAL_WAIVER_VERSION`).
|
|
135
|
+
*/
|
|
136
|
+
interface WithdrawalWaiverConsent {
|
|
137
|
+
version: string;
|
|
138
|
+
accepted: true;
|
|
139
|
+
}
|
|
140
|
+
/** What a paywall upgrade click carries besides the SKU. */
|
|
141
|
+
interface UpgradeConsent {
|
|
142
|
+
withdrawalWaiver?: WithdrawalWaiverConsent;
|
|
143
|
+
}
|
|
144
|
+
|
|
72
145
|
interface FormattedPrice {
|
|
73
146
|
/** Currency symbol/code as the locale renders it (`$`, `€`, `US$`). */
|
|
74
147
|
currency: string;
|
|
@@ -102,17 +175,25 @@ interface PaywallView {
|
|
|
102
175
|
mock?: boolean;
|
|
103
176
|
recoveryEnabled?: boolean;
|
|
104
177
|
seller?: PaySellerPublic | null;
|
|
178
|
+
/**
|
|
179
|
+
* From `PayOfferResponse.withdrawalWaiver`: when set (and the offer is
|
|
180
|
+
* purchasable) an unticked waiver checkbox gates every upgrade button.
|
|
181
|
+
* The waiver text is not overridable through `strings`: it is versioned.
|
|
182
|
+
*/
|
|
183
|
+
withdrawalWaiver?: PayWithdrawalWaiver | null;
|
|
105
184
|
locale: string | null;
|
|
106
185
|
theme: ThemeConfig;
|
|
107
186
|
strings: Partial<PaywallStrings>;
|
|
108
187
|
container?: HTMLElement;
|
|
109
188
|
}
|
|
110
189
|
interface PaywallRendererCallbacks {
|
|
111
|
-
|
|
190
|
+
/** `consent` is passed only when the paywall showed the withdrawal waiver (and it was ticked). */
|
|
191
|
+
onUpgrade: (sku: string, consent?: UpgradeConsent) => void;
|
|
112
192
|
onClose: () => void;
|
|
113
193
|
onRestore?: () => void;
|
|
114
194
|
}
|
|
115
195
|
declare const PAYWALL_HOST_CLASS = "extenshi-paywall-host";
|
|
196
|
+
declare const WITHDRAWAL_WAIVER_CLASS = "extenshi-withdrawal-waiver";
|
|
116
197
|
declare function escapeHtml(value: string): string;
|
|
117
198
|
declare function substitute(html: string, content: Record<string, string>): string;
|
|
118
199
|
declare function buildContent(view: PaywallView, strings: PaywallStrings): Record<string, string>;
|
|
@@ -128,18 +209,23 @@ declare class PaywallRenderer {
|
|
|
128
209
|
show(view: PaywallView): HTMLElement;
|
|
129
210
|
hide(): void;
|
|
130
211
|
private prune;
|
|
212
|
+
/**
|
|
213
|
+
* Inserts the unticked waiver checkbox right before the first upgrade
|
|
214
|
+
* button and keeps every upgrade button disabled until it is ticked.
|
|
215
|
+
*/
|
|
216
|
+
private mountWaiver;
|
|
131
217
|
private bind;
|
|
132
218
|
private reveal;
|
|
133
219
|
private close;
|
|
134
220
|
}
|
|
135
221
|
|
|
136
222
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* promotional claims here without marketing/legal review (see
|
|
223
|
+
* The paywall's strings in a locale, from the SDK dictionary (./i18n.ts).
|
|
224
|
+
* Do not add promotional claims without marketing/legal review (see
|
|
140
225
|
* .claude/modules/paywall-templates.md).
|
|
141
226
|
*/
|
|
142
227
|
|
|
228
|
+
/** English (the default and the fallback). */
|
|
143
229
|
declare const DEFAULT_STRINGS: PaywallStrings;
|
|
144
230
|
|
|
145
231
|
/**
|
|
@@ -156,5 +242,5 @@ declare const PAYWALL_SHARED_CSS: string;
|
|
|
156
242
|
declare const PAYWALL_TEMPLATES: Record<PaywallMode, PaywallTemplate>;
|
|
157
243
|
declare const PAYWALL_MODES: PaywallMode[];
|
|
158
244
|
|
|
159
|
-
export { DEFAULT_STRINGS, PAYWALL_HOST_CLASS, PAYWALL_MODES, PAYWALL_SHARED_CSS, PAYWALL_TEMPLATES, PaywallRenderer, buildContent, escapeHtml, formatPrice, periodLabel, resolveThemeMode, substitute, themeCss };
|
|
245
|
+
export { DEFAULT_STRINGS, PAYWALL_HOST_CLASS, PAYWALL_MODES, PAYWALL_SHARED_CSS, PAYWALL_TEMPLATES, PaywallRenderer, WITHDRAWAL_WAIVER_CLASS, WITHDRAWAL_WAIVER_TEXTS, buildContent, escapeHtml, formatPrice, periodLabel, resolveThemeMode, substitute, themeCss, withdrawalWaiverText };
|
|
160
246
|
export type { FormattedPrice, PaywallMode, PaywallOptions, PaywallRendererCallbacks, PaywallStrings, PaywallTemplate, PaywallView, ThemeConfig };
|