@aforoai/storefront-widgets 1.0.4 → 1.0.6
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/CHANGELOG.md +40 -0
- package/dist/index.cjs +77 -44
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +77 -44
- package/dist/loader.js +1 -1
- package/dist/loader.mjs +1 -1
- package/dist/sri.json +11 -11
- package/dist/vanilla/index.cjs +79 -44
- package/dist/vanilla/index.mjs +79 -44
- package/dist/vue/index.cjs +79 -44
- package/dist/vue/index.mjs +79 -44
- package/dist/widgets/checkout-flow.js +5 -5
- package/dist/widgets/invoice-list.js +6 -6
- package/dist/widgets/payment-method.js +5 -5
- package/dist/widgets/pricing-card.js +7 -7
- package/dist/widgets/subscribe-button.js +5 -5
- package/dist/widgets/subscription-manager.js +5 -5
- package/dist/widgets/upgrade-cancel.js +5 -5
- package/dist/widgets/usage-meter.js +5 -5
- package/loader.sri.txt +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -149,7 +149,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
149
149
|
throw await this.parseError(resp);
|
|
150
150
|
}
|
|
151
151
|
const body = await resp.json();
|
|
152
|
-
|
|
152
|
+
const data = body?.data ?? body;
|
|
153
|
+
if (!data || !data.sessionJwt || typeof data.expiresAt !== "number") {
|
|
153
154
|
throw new BridgeClientError(
|
|
154
155
|
"Malformed bridge exchange response",
|
|
155
156
|
500,
|
|
@@ -158,9 +159,9 @@ var _BridgeClient = class _BridgeClient {
|
|
|
158
159
|
);
|
|
159
160
|
}
|
|
160
161
|
return {
|
|
161
|
-
sessionJwt:
|
|
162
|
-
expiresAt:
|
|
163
|
-
customerId:
|
|
162
|
+
sessionJwt: data.sessionJwt,
|
|
163
|
+
expiresAt: data.expiresAt,
|
|
164
|
+
customerId: data.customerId ?? null
|
|
164
165
|
};
|
|
165
166
|
}
|
|
166
167
|
/**
|
|
@@ -246,16 +247,17 @@ var _BridgeClient = class _BridgeClient {
|
|
|
246
247
|
try {
|
|
247
248
|
const body = await resp.json();
|
|
248
249
|
if (!body || typeof body !== "object") return null;
|
|
250
|
+
const data = body.data ?? body;
|
|
249
251
|
return {
|
|
250
|
-
tenantSlug:
|
|
252
|
+
tenantSlug: data.tenantSlug,
|
|
251
253
|
branding: {
|
|
252
|
-
primaryColor:
|
|
253
|
-
secondaryColor:
|
|
254
|
-
logoUrl:
|
|
255
|
-
fontFamily:
|
|
254
|
+
primaryColor: data.primaryColor ?? null,
|
|
255
|
+
secondaryColor: data.secondaryColor ?? null,
|
|
256
|
+
logoUrl: data.logoUrl ?? null,
|
|
257
|
+
fontFamily: data.fontFamily ?? null
|
|
256
258
|
},
|
|
257
|
-
offerings: Array.isArray(
|
|
258
|
-
embeddableWidget:
|
|
259
|
+
offerings: Array.isArray(data.offerings) ? data.offerings : [],
|
|
260
|
+
embeddableWidget: data.embeddableWidget ?? null
|
|
259
261
|
};
|
|
260
262
|
} catch {
|
|
261
263
|
return null;
|
|
@@ -400,7 +402,8 @@ var _BridgeClient = class _BridgeClient {
|
|
|
400
402
|
false
|
|
401
403
|
);
|
|
402
404
|
}
|
|
403
|
-
|
|
405
|
+
const data = body?.data ?? body ?? {};
|
|
406
|
+
if (!data.checkoutUrl || !data.checkoutSessionId || !data.expiresAt) {
|
|
404
407
|
throw new BridgeClientError(
|
|
405
408
|
"Malformed checkout-initiate response (missing required fields)",
|
|
406
409
|
500,
|
|
@@ -409,9 +412,9 @@ var _BridgeClient = class _BridgeClient {
|
|
|
409
412
|
);
|
|
410
413
|
}
|
|
411
414
|
return {
|
|
412
|
-
checkoutUrl:
|
|
413
|
-
checkoutSessionId:
|
|
414
|
-
expiresAt:
|
|
415
|
+
checkoutUrl: data.checkoutUrl,
|
|
416
|
+
checkoutSessionId: data.checkoutSessionId,
|
|
417
|
+
expiresAt: data.expiresAt
|
|
415
418
|
};
|
|
416
419
|
}
|
|
417
420
|
/* ────────────────────────────────────────────────────────────────────
|
|
@@ -1219,13 +1222,16 @@ var _BridgeClient = class _BridgeClient {
|
|
|
1219
1222
|
if (!resp.ok) return emptyPage;
|
|
1220
1223
|
try {
|
|
1221
1224
|
const body = await resp.json();
|
|
1222
|
-
if (!body || typeof body !== "object")
|
|
1225
|
+
if (!body || typeof body !== "object") {
|
|
1226
|
+
return emptyPage;
|
|
1227
|
+
}
|
|
1228
|
+
const data = body.data ?? body;
|
|
1223
1229
|
return {
|
|
1224
|
-
content: Array.isArray(
|
|
1225
|
-
totalElements: typeof
|
|
1226
|
-
totalPages: typeof
|
|
1227
|
-
page: typeof
|
|
1228
|
-
size: typeof
|
|
1230
|
+
content: Array.isArray(data.content) ? data.content : [],
|
|
1231
|
+
totalElements: typeof data.totalElements === "number" && Number.isFinite(data.totalElements) ? data.totalElements : 0,
|
|
1232
|
+
totalPages: typeof data.totalPages === "number" && Number.isFinite(data.totalPages) ? data.totalPages : 0,
|
|
1233
|
+
page: typeof data.page === "number" && Number.isFinite(data.page) ? data.page : filter.page ?? 0,
|
|
1234
|
+
size: typeof data.size === "number" && Number.isFinite(data.size) ? data.size : filter.size ?? 10
|
|
1229
1235
|
};
|
|
1230
1236
|
} catch {
|
|
1231
1237
|
return emptyPage;
|
|
@@ -2644,6 +2650,7 @@ function WidgetShell(props) {
|
|
|
2644
2650
|
var DEFAULT_LAYOUT = "horizontal";
|
|
2645
2651
|
var DEFAULT_MAX_PLANS = 4;
|
|
2646
2652
|
var DEFAULT_CTA_TEXT = "Get Started";
|
|
2653
|
+
var DEFAULT_CARD_RADIUS = 12;
|
|
2647
2654
|
function clampLayout(raw) {
|
|
2648
2655
|
return raw === "horizontal" || raw === "vertical" || raw === "table" ? raw : void 0;
|
|
2649
2656
|
}
|
|
@@ -2654,7 +2661,7 @@ function setTenantDefaultsIdempotent(setter, next) {
|
|
|
2654
2661
|
setter((prev) => {
|
|
2655
2662
|
if (prev === next) return prev;
|
|
2656
2663
|
if (!prev && !next) return prev;
|
|
2657
|
-
if (prev && next && prev.layout === next.layout && prev.theme === next.theme && prev.maxPlans === next.maxPlans && prev.showFeatures === next.showFeatures && prev.ctaText === next.ctaText) {
|
|
2664
|
+
if (prev && next && prev.layout === next.layout && prev.theme === next.theme && prev.maxPlans === next.maxPlans && prev.showFeatures === next.showFeatures && prev.ctaText === next.ctaText && prev.borderRadius === next.borderRadius) {
|
|
2658
2665
|
return prev;
|
|
2659
2666
|
}
|
|
2660
2667
|
return next;
|
|
@@ -2669,7 +2676,8 @@ function extractTenantDefaults(config) {
|
|
|
2669
2676
|
theme: typeof raw.theme === "string" ? raw.theme : void 0,
|
|
2670
2677
|
maxPlans: typeof raw.maxPlans === "number" && Number.isFinite(raw.maxPlans) ? raw.maxPlans : void 0,
|
|
2671
2678
|
showFeatures: typeof raw.showFeatures === "boolean" ? raw.showFeatures : void 0,
|
|
2672
|
-
ctaText: typeof raw.ctaText === "string" && raw.ctaText.length > 0 ? raw.ctaText : void 0
|
|
2679
|
+
ctaText: typeof raw.ctaText === "string" && raw.ctaText.length > 0 ? raw.ctaText : void 0,
|
|
2680
|
+
borderRadius: typeof raw.borderRadius === "number" && Number.isFinite(raw.borderRadius) ? raw.borderRadius : void 0
|
|
2673
2681
|
};
|
|
2674
2682
|
}
|
|
2675
2683
|
var DARK_TOKEN_OVERLAY = {
|
|
@@ -2729,6 +2737,20 @@ function safeFormatCurrency(priceCents, currency, locale, intlOverride) {
|
|
|
2729
2737
|
return `${currency} ${amount.toFixed(2)}`;
|
|
2730
2738
|
}
|
|
2731
2739
|
}
|
|
2740
|
+
function resolveDisplayPrice(offering, locale, intlOverride) {
|
|
2741
|
+
const flat = safeFormatCurrency(offering.priceCents, offering.currency, locale, intlOverride);
|
|
2742
|
+
if (flat !== "\u2014") return { text: flat, unitSuffix: null };
|
|
2743
|
+
const perUnitPlan = offering.ratePlans?.find(
|
|
2744
|
+
(rp) => rp.pricingModel === "PER_UNIT" && rp.perUnitPriceCents != null
|
|
2745
|
+
);
|
|
2746
|
+
if (perUnitPlan) {
|
|
2747
|
+
const unitPrice = safeFormatCurrency(perUnitPlan.perUnitPriceCents, offering.currency, locale, intlOverride);
|
|
2748
|
+
if (unitPrice !== "\u2014") {
|
|
2749
|
+
return { text: unitPrice, unitSuffix: perUnitPlan.unitLabel || "unit" };
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
return { text: "\u2014", unitSuffix: null };
|
|
2753
|
+
}
|
|
2732
2754
|
function localizedName(o) {
|
|
2733
2755
|
return o.localizedDisplayName || o.name || "(unnamed plan)";
|
|
2734
2756
|
}
|
|
@@ -2777,6 +2799,7 @@ function PricingCardBody(props) {
|
|
|
2777
2799
|
theme: themeProp,
|
|
2778
2800
|
locale: localeProp,
|
|
2779
2801
|
maxPlans: maxPlansProp,
|
|
2802
|
+
borderRadius: borderRadiusProp,
|
|
2780
2803
|
showFeatures: showFeaturesProp,
|
|
2781
2804
|
ctaText: ctaTextProp,
|
|
2782
2805
|
ctaUrl: ctaUrlProp,
|
|
@@ -2790,6 +2813,7 @@ function PricingCardBody(props) {
|
|
|
2790
2813
|
const maxPlans = typeof maxPlansProp === "number" && Number.isFinite(maxPlansProp) ? maxPlansProp : typeof tenantDefaults?.maxPlans === "number" && Number.isFinite(tenantDefaults.maxPlans) ? tenantDefaults.maxPlans : DEFAULT_MAX_PLANS;
|
|
2791
2814
|
const showFeatures = typeof showFeaturesProp === "boolean" ? showFeaturesProp : typeof tenantDefaults?.showFeatures === "boolean" ? tenantDefaults.showFeatures : true;
|
|
2792
2815
|
const ctaTextEffective = ctaTextProp ?? tenantDefaults?.ctaText ?? void 0;
|
|
2816
|
+
const cardRadius = typeof borderRadiusProp === "number" && Number.isFinite(borderRadiusProp) ? borderRadiusProp : typeof tenantDefaults?.borderRadius === "number" && Number.isFinite(tenantDefaults.borderRadius) ? tenantDefaults.borderRadius : DEFAULT_CARD_RADIUS;
|
|
2793
2817
|
const shell = useWidgetShell();
|
|
2794
2818
|
const { tokens: shellTokens, bridgeClient, telemetry, bus, tenantSlug } = shell;
|
|
2795
2819
|
const isDark = React7.useMemo(() => {
|
|
@@ -3007,7 +3031,8 @@ function PricingCardBody(props) {
|
|
|
3007
3031
|
{
|
|
3008
3032
|
layout,
|
|
3009
3033
|
tokens,
|
|
3010
|
-
prefersReducedMotion
|
|
3034
|
+
prefersReducedMotion,
|
|
3035
|
+
cardRadius
|
|
3011
3036
|
}
|
|
3012
3037
|
)
|
|
3013
3038
|
}
|
|
@@ -3079,7 +3104,8 @@ function PricingCardBody(props) {
|
|
|
3079
3104
|
ctaTextProp: ctaTextEffective,
|
|
3080
3105
|
featuredOverride: featuredOfferingId,
|
|
3081
3106
|
onCtaClick: handleCtaClick,
|
|
3082
|
-
intlOverride
|
|
3107
|
+
intlOverride,
|
|
3108
|
+
cardRadius
|
|
3083
3109
|
}
|
|
3084
3110
|
)
|
|
3085
3111
|
}
|
|
@@ -3094,7 +3120,8 @@ function PlanGrid({
|
|
|
3094
3120
|
ctaTextProp,
|
|
3095
3121
|
featuredOverride,
|
|
3096
3122
|
onCtaClick,
|
|
3097
|
-
intlOverride
|
|
3123
|
+
intlOverride,
|
|
3124
|
+
cardRadius
|
|
3098
3125
|
}) {
|
|
3099
3126
|
const isHorizontal = layout === "horizontal";
|
|
3100
3127
|
const gridStyle2 = isHorizontal ? {
|
|
@@ -3117,7 +3144,8 @@ function PlanGrid({
|
|
|
3117
3144
|
ctaTextProp,
|
|
3118
3145
|
featured: offeringIsFeatured(o, featuredOverride),
|
|
3119
3146
|
onCtaClick,
|
|
3120
|
-
intlOverride
|
|
3147
|
+
intlOverride,
|
|
3148
|
+
cardRadius
|
|
3121
3149
|
},
|
|
3122
3150
|
o.offeringId
|
|
3123
3151
|
)) });
|
|
@@ -3130,14 +3158,10 @@ function PlanCard({
|
|
|
3130
3158
|
ctaTextProp,
|
|
3131
3159
|
featured,
|
|
3132
3160
|
onCtaClick,
|
|
3133
|
-
intlOverride
|
|
3161
|
+
intlOverride,
|
|
3162
|
+
cardRadius
|
|
3134
3163
|
}) {
|
|
3135
|
-
const price =
|
|
3136
|
-
offering.priceCents,
|
|
3137
|
-
offering.currency,
|
|
3138
|
-
locale,
|
|
3139
|
-
intlOverride
|
|
3140
|
-
);
|
|
3164
|
+
const { text: price, unitSuffix } = resolveDisplayPrice(offering, locale, intlOverride);
|
|
3141
3165
|
const isContactSales = price === "\u2014";
|
|
3142
3166
|
const planName = localizedName(offering);
|
|
3143
3167
|
const description = localizedDescription(offering);
|
|
@@ -3146,7 +3170,7 @@ function PlanCard({
|
|
|
3146
3170
|
display: "flex",
|
|
3147
3171
|
flexDirection: "column",
|
|
3148
3172
|
padding: 24,
|
|
3149
|
-
borderRadius:
|
|
3173
|
+
borderRadius: cardRadius,
|
|
3150
3174
|
border: featured ? `2px solid ${tokens.primary}` : `1px solid ${tokens.border}`,
|
|
3151
3175
|
background: tokens.bg,
|
|
3152
3176
|
color: tokens.text,
|
|
@@ -3158,7 +3182,7 @@ function PlanCard({
|
|
|
3158
3182
|
"div",
|
|
3159
3183
|
{
|
|
3160
3184
|
role: "group",
|
|
3161
|
-
"aria-label": `${planName}, ${price} per ${offering.billingCycle}`,
|
|
3185
|
+
"aria-label": `${planName}, ${price} per ${unitSuffix ?? offering.billingCycle}`,
|
|
3162
3186
|
className: `aforo-w-pc-card${featured ? " aforo-w-pc-card-featured" : ""}`,
|
|
3163
3187
|
style: cardStyle2,
|
|
3164
3188
|
children: [
|
|
@@ -3223,14 +3247,14 @@ function PlanCard({
|
|
|
3223
3247
|
children: price
|
|
3224
3248
|
}
|
|
3225
3249
|
),
|
|
3226
|
-
!isContactSales && offering.billingCycle ? /* @__PURE__ */ jsxs(
|
|
3250
|
+
!isContactSales && (unitSuffix || offering.billingCycle) ? /* @__PURE__ */ jsxs(
|
|
3227
3251
|
"span",
|
|
3228
3252
|
{
|
|
3229
3253
|
className: "aforo-w-pc-cycle",
|
|
3230
3254
|
style: { fontSize: 13, color: tokens.textMuted },
|
|
3231
3255
|
children: [
|
|
3232
3256
|
"/ ",
|
|
3233
|
-
humanCycle(offering.billingCycle)
|
|
3257
|
+
unitSuffix ?? humanCycle(offering.billingCycle)
|
|
3234
3258
|
]
|
|
3235
3259
|
}
|
|
3236
3260
|
) : null
|
|
@@ -3388,6 +3412,7 @@ function TableLayout({
|
|
|
3388
3412
|
/* @__PURE__ */ jsx("th", { scope: "col", style: { ...headerCellStyle, color: tokens.textMuted, fontSize: 12 }, children: /* @__PURE__ */ jsx("span", { className: "aforo-w-pc-sr-only", style: srOnlyStyle, children: "Feature" }) }),
|
|
3389
3413
|
offerings.map((o) => {
|
|
3390
3414
|
const featured = offeringIsFeatured(o, featuredOverride);
|
|
3415
|
+
const { text: tablePrice, unitSuffix: tableUnitSuffix } = resolveDisplayPrice(o, locale, intlOverride);
|
|
3391
3416
|
return /* @__PURE__ */ jsx(
|
|
3392
3417
|
"th",
|
|
3393
3418
|
{
|
|
@@ -3417,13 +3442,20 @@ function TableLayout({
|
|
|
3417
3442
|
children: "Most popular"
|
|
3418
3443
|
}
|
|
3419
3444
|
) : null,
|
|
3420
|
-
/* @__PURE__ */
|
|
3445
|
+
/* @__PURE__ */ jsxs("div", { style: { fontSize: 22, fontWeight: 700 }, children: [
|
|
3446
|
+
tablePrice,
|
|
3447
|
+
tableUnitSuffix ? /* @__PURE__ */ jsxs("span", { style: { fontSize: 12, fontWeight: 400, color: tokens.textMuted }, children: [
|
|
3448
|
+
" ",
|
|
3449
|
+
"/ ",
|
|
3450
|
+
tableUnitSuffix
|
|
3451
|
+
] }) : null
|
|
3452
|
+
] }),
|
|
3421
3453
|
/* @__PURE__ */ jsx(
|
|
3422
3454
|
"button",
|
|
3423
3455
|
{
|
|
3424
3456
|
type: "button",
|
|
3425
3457
|
onClick: () => onCtaClick(o),
|
|
3426
|
-
"aria-label": `${ctaLabel(o, ctaTextProp,
|
|
3458
|
+
"aria-label": `${ctaLabel(o, ctaTextProp, tablePrice === "\u2014")} for ${localizedName(o)}`,
|
|
3427
3459
|
style: {
|
|
3428
3460
|
inlineSize: "100%",
|
|
3429
3461
|
padding: "8px 12px",
|
|
@@ -3436,7 +3468,7 @@ function TableLayout({
|
|
|
3436
3468
|
cursor: "pointer",
|
|
3437
3469
|
fontFamily: tokens.fontFamily
|
|
3438
3470
|
},
|
|
3439
|
-
children: ctaLabel(o, ctaTextProp,
|
|
3471
|
+
children: ctaLabel(o, ctaTextProp, tablePrice === "\u2014")
|
|
3440
3472
|
}
|
|
3441
3473
|
)
|
|
3442
3474
|
] })
|
|
@@ -3488,7 +3520,8 @@ function cellAria(label, feature) {
|
|
|
3488
3520
|
function LoadingSkeleton({
|
|
3489
3521
|
layout,
|
|
3490
3522
|
tokens,
|
|
3491
|
-
prefersReducedMotion
|
|
3523
|
+
prefersReducedMotion,
|
|
3524
|
+
cardRadius
|
|
3492
3525
|
}) {
|
|
3493
3526
|
const shimmerStyle = prefersReducedMotion ? { background: tokens.border, opacity: 0.6 } : {
|
|
3494
3527
|
background: `linear-gradient(90deg, ${tokens.border} 0%, ${tokens.bg} 50%, ${tokens.border} 100%)`,
|
|
@@ -3521,7 +3554,7 @@ function LoadingSkeleton({
|
|
|
3521
3554
|
"aria-hidden": "true",
|
|
3522
3555
|
style: {
|
|
3523
3556
|
padding: 24,
|
|
3524
|
-
borderRadius:
|
|
3557
|
+
borderRadius: cardRadius,
|
|
3525
3558
|
border: `1px solid ${tokens.border}`,
|
|
3526
3559
|
background: tokens.bg,
|
|
3527
3560
|
minHeight: 280,
|
|
@@ -12153,7 +12186,7 @@ function ResultPanel({
|
|
|
12153
12186
|
}
|
|
12154
12187
|
|
|
12155
12188
|
// src/core/version.ts
|
|
12156
|
-
var VERSION = "1.0.
|
|
12189
|
+
var VERSION = "1.0.6";
|
|
12157
12190
|
|
|
12158
12191
|
// src/core/AforoEmbed.ts
|
|
12159
12192
|
var mountedElements = /* @__PURE__ */ new WeakMap();
|
package/dist/loader.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var AforoEmbedLoader=(function(exports){'use strict';var T="1.0.
|
|
1
|
+
var AforoEmbedLoader=(function(exports){'use strict';var T="1.0.6";var y=new WeakMap,c=new Map,f={},A=false;function h(){A||typeof window!="undefined"&&(window.addEventListener("message",e=>{let t=e.data;!t||typeof t!="object"||typeof t.type!="string"||t.type.startsWith("aforo.")&&$(t);}),A=true);}function $(e){let t=c.get(e.type);if(t)for(let o of t)try{o(e);}catch(i){}let n=c.get("*");if(n)for(let o of n)try{o(e);}catch(i){}}var p=new Map;function N(e,t){p.set(e,t);}function w(e){return typeof e=="object"&&e!==null&&typeof e.tagName=="string"}var b={version:T,configure(e){f={...f,...e};},getConfig(){return {...f}},mount(e,t){var r,l,u,s,d;if(!w(e)||y.has(e))return false;let n=t.widget,o=p.get(n);if(!o)return typeof console!="undefined"&&console.warn(`[aforo:embed] No mount handler registered for widget "${n}". Loader bundle may not have finished loading.`),false;let i={widget:n,tenantSlug:(l=(r=t.tenantSlug)!=null?r:f.tenantSlug)!=null?l:"",embedKey:(s=(u=t.embedKey)!=null?u:f.embedKey)!=null?s:"",bridgeToken:(d=t.bridgeToken)!=null?d:f.bridgeToken,layout:t.layout,themeOverrides:t.themeOverrides,config:t.config};if(!i.tenantSlug||!i.embedKey)return typeof console!="undefined"&&console.error(`[aforo:embed] Widget "${n}" requires tenantSlug + embedKey. Provide via AforoEmbed.configure() or data-* attributes.`),false;h();let a=o(e,i);return y.set(e,{element:e,widget:n,teardown:a}),true},unmount(e){if(!w(e))return false;let t=y.get(e);if(!t)return false;try{t.teardown();}catch(n){}return y.delete(e),true},on(e,t){h();let n=c.get(e);return n||(n=new Set,c.set(e,n)),n.add(t),()=>{let o=c.get(e);o&&(o.delete(t),o.size===0&&c.delete(e));}},_registerWidget:N,_registeredWidgetsForTesting(){return Array.from(p.keys())},_resetForTesting(){p.clear(),c.clear(),f={};}};function k(e){if(!e)return {};try{let t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t)){let n={},o=["primary","primaryContrast","text","textMuted","bg","border","radius","fontFamily"],i=t;for(let a of o){let r=i[a];typeof r=="string"&&r.length>0&&(n[a]=r);}return n}}catch(t){}return {}}var U=new Set(["pricing-card","subscribe-button","checkout-flow","subscription-manager","invoice-list","usage-meter","payment-method","upgrade-cancel"]),B="https://embed.aforo.ai/v1/widgets",g="[aforo:loader]";function D(){let e=typeof document!="undefined"?document.currentScript:null;if(e&&e.tagName==="SCRIPT")return e;if(typeof document!="undefined"){let t=document.getElementsByTagName("script");for(let n=t.length-1;n>=0;n--){let o=t[n];if(!o)continue;let i=o.getAttribute("src")||"";if(/(\/v1)?\/loader(\.umd)?\.js$/.test(i))return o}}return null}function G(e){let t=e==null?void 0:e.getAttribute("src");if(!t)return null;try{let n=typeof location!="undefined"?location.href:void 0,o=new URL(t,n),i=o.pathname.replace(/\/loader(\.umd)?\.js$/,"");return `${o.origin}${i}/widgets`}catch(n){return null}}function v(e,t){let n=e.getAttribute(t);if(n==null||n.trim()==="")return;let o=Number(n);return Number.isFinite(o)?o:void 0}function j(e,t){let n=e.getAttribute(t);if(n==null)return;let o=n.trim().toLowerCase();if(o==="true")return true;if(o==="false")return false}function V(e){let t=(e.getAttribute("data-aforo-widget")||"").trim(),n=e.getAttribute("data-tenant-slug")||e.getAttribute("data-tenant")||"",o=e.getAttribute("data-embed-key")||"",i=e.getAttribute("data-bridge-token")||void 0,a=e.getAttribute("data-layout")||void 0,r=k(e.getAttribute("data-theme-overrides")),l=e.getAttribute("data-offering-id")||void 0,u=e.getAttribute("data-subscription-id")||void 0,s=e.getAttribute("data-metric")||void 0,d=e.getAttribute("data-featured-offering-id")||void 0,m=e.getAttribute("data-mode")||void 0,M=e.getAttribute("data-return-url")||void 0,S=e.getAttribute("data-default-status")||void 0,F=e.getAttribute("data-render-mode")||void 0,_=e.getAttribute("data-locale")||void 0,C=v(e,"data-page-size"),O=v(e,"data-poll-interval-ms"),I=e.getAttribute("data-theme")||void 0,R=e.getAttribute("data-cart-type")||void 0,W=e.getAttribute("data-target-id")||void 0,H=e.getAttribute("data-cta-text")||void 0,x=e.getAttribute("data-cta-url")||void 0,P=v(e,"data-max-plans"),K=j(e,"data-show-features");return {widget:t,tenantSlug:n,embedKey:o,bridgeToken:i,layout:a,themeOverrides:r,config:{offeringId:l,subscriptionId:u,metricName:s,featuredOfferingId:d,mode:m,returnUrl:M,defaultStatus:S,renderMode:F,locale:_,pageSize:C,pollIntervalMs:O,theme:I,cartType:R,targetId:W,ctaText:H,ctaUrl:x,maxPlans:P,showFeatures:K}}}function z(e,t,n){return new Promise((o,i)=>{if(typeof document=="undefined")return i(new Error("no document"));let a=document.querySelector(`script[data-aforo-bundle="${e}"]`);if(a){if(a.dataset.aforoLoaded==="1")return o();a.addEventListener("load",()=>o()),a.addEventListener("error",()=>i(new Error(`bundle load failed: ${e}`)));return}let r=document.createElement("script");r.src=`${t}/${e}.js`,r.async=true,r.crossOrigin="anonymous",r.dataset.aforoBundle=e,n&&r.setAttribute("nonce",n),r.addEventListener("load",()=>{r.dataset.aforoLoaded="1",o();}),r.addEventListener("error",()=>i(new Error(`bundle load failed: ${e}`))),document.head.appendChild(r);})}function L(e){if(!e.__aforoEmbedReadyFired){e.__aforoEmbedReadyFired=true;try{typeof e.aforoEmbedReady=="function"&&e.aforoEmbedReady();}catch(t){typeof console!="undefined"&&console.error(`${g} aforoEmbedReady callback threw`,t);}if(typeof document!="undefined"&&typeof CustomEvent!="undefined")try{document.dispatchEvent(new CustomEvent("aforoEmbedReady"));}catch(t){}}}async function E(e){if(typeof window=="undefined"||typeof document=="undefined")return;let t=window;if(window.location.protocol!=="https:"&&window.location.hostname!=="localhost"){typeof console!="undefined"&&console.error(`${g} Refusing to mount Aforo widgets on a non-HTTPS page. Embed Plugin requires HTTPS (FR-TIER-12). Current origin: ${window.location.origin}`);return}if(t.__aforoEmbedLoaderInitialized){typeof console!="undefined"&&console.warn(`${g} Loader already initialised on this page \u2014 skipping duplicate run.`);return}t.__aforoEmbedLoaderInitialized=true,t.aforoEmbed||(t.aforoEmbed=b);let n=D(),o=(n==null?void 0:n.getAttribute("nonce"))||null,i=(e==null?void 0:e.bundleBaseUrl)||G(n)||B,a=Array.from(document.querySelectorAll("[data-aforo-widget]"));if(a.length===0){L(t);return}let r=new Map;for(let u of a){let s=(u.getAttribute("data-aforo-widget")||"").trim();if(!U.has(s)){typeof console!="undefined"&&console.warn(`${g} Unknown widget id "${s}" \u2014 skipping`);continue}let d=r.get(s);d||(d=[],r.set(s,d)),d.push(u);}let l=Array.from(r.entries()).map(async([u,s])=>{try{await z(u,i,o);for(let d of s){let m=V(d);if(!m.widget||!m.tenantSlug||!m.embedKey){typeof console!="undefined"&&console.error(`${g} Placeholder missing required attributes (data-tenant-slug + data-embed-key). Skipping element.`,d);continue}b.mount(d,m);}}catch(d){typeof console!="undefined"&&console.error(`${g} Failed to load bundle for "${u}"`,d);}});await Promise.all(l).catch(()=>{}),L(t);}typeof document!="undefined"&&document.readyState!=="loading"?Promise.resolve().then(()=>{E();}):typeof document!="undefined"&&document.addEventListener("DOMContentLoaded",()=>{E();});b._loader={bootstrap:E};
|
|
2
2
|
exports.AforoEmbed=b;exports.bootstrap=E;return exports;})({});//# sourceMappingURL=loader.js.map
|
|
3
3
|
//# sourceMappingURL=loader.js.map
|
package/dist/loader.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var T="1.0.
|
|
1
|
+
var T="1.0.6";var y=new WeakMap,c=new Map,f={},A=false;function h(){A||typeof window!="undefined"&&(window.addEventListener("message",e=>{let t=e.data;!t||typeof t!="object"||typeof t.type!="string"||t.type.startsWith("aforo.")&&$(t);}),A=true);}function $(e){let t=c.get(e.type);if(t)for(let o of t)try{o(e);}catch(i){}let n=c.get("*");if(n)for(let o of n)try{o(e);}catch(i){}}var p=new Map;function N(e,t){p.set(e,t);}function w(e){return typeof e=="object"&&e!==null&&typeof e.tagName=="string"}var b={version:T,configure(e){f={...f,...e};},getConfig(){return {...f}},mount(e,t){var r,l,u,s,d;if(!w(e)||y.has(e))return false;let n=t.widget,o=p.get(n);if(!o)return typeof console!="undefined"&&console.warn(`[aforo:embed] No mount handler registered for widget "${n}". Loader bundle may not have finished loading.`),false;let i={widget:n,tenantSlug:(l=(r=t.tenantSlug)!=null?r:f.tenantSlug)!=null?l:"",embedKey:(s=(u=t.embedKey)!=null?u:f.embedKey)!=null?s:"",bridgeToken:(d=t.bridgeToken)!=null?d:f.bridgeToken,layout:t.layout,themeOverrides:t.themeOverrides,config:t.config};if(!i.tenantSlug||!i.embedKey)return typeof console!="undefined"&&console.error(`[aforo:embed] Widget "${n}" requires tenantSlug + embedKey. Provide via AforoEmbed.configure() or data-* attributes.`),false;h();let a=o(e,i);return y.set(e,{element:e,widget:n,teardown:a}),true},unmount(e){if(!w(e))return false;let t=y.get(e);if(!t)return false;try{t.teardown();}catch(n){}return y.delete(e),true},on(e,t){h();let n=c.get(e);return n||(n=new Set,c.set(e,n)),n.add(t),()=>{let o=c.get(e);o&&(o.delete(t),o.size===0&&c.delete(e));}},_registerWidget:N,_registeredWidgetsForTesting(){return Array.from(p.keys())},_resetForTesting(){p.clear(),c.clear(),f={};}};function k(e){if(!e)return {};try{let t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t)){let n={},o=["primary","primaryContrast","text","textMuted","bg","border","radius","fontFamily"],i=t;for(let a of o){let r=i[a];typeof r=="string"&&r.length>0&&(n[a]=r);}return n}}catch(t){}return {}}var U=new Set(["pricing-card","subscribe-button","checkout-flow","subscription-manager","invoice-list","usage-meter","payment-method","upgrade-cancel"]),B="https://embed.aforo.ai/v1/widgets",g="[aforo:loader]";function D(){let e=typeof document!="undefined"?document.currentScript:null;if(e&&e.tagName==="SCRIPT")return e;if(typeof document!="undefined"){let t=document.getElementsByTagName("script");for(let n=t.length-1;n>=0;n--){let o=t[n];if(!o)continue;let i=o.getAttribute("src")||"";if(/(\/v1)?\/loader(\.umd)?\.js$/.test(i))return o}}return null}function G(e){let t=e==null?void 0:e.getAttribute("src");if(!t)return null;try{let n=typeof location!="undefined"?location.href:void 0,o=new URL(t,n),i=o.pathname.replace(/\/loader(\.umd)?\.js$/,"");return `${o.origin}${i}/widgets`}catch(n){return null}}function v(e,t){let n=e.getAttribute(t);if(n==null||n.trim()==="")return;let o=Number(n);return Number.isFinite(o)?o:void 0}function j(e,t){let n=e.getAttribute(t);if(n==null)return;let o=n.trim().toLowerCase();if(o==="true")return true;if(o==="false")return false}function V(e){let t=(e.getAttribute("data-aforo-widget")||"").trim(),n=e.getAttribute("data-tenant-slug")||e.getAttribute("data-tenant")||"",o=e.getAttribute("data-embed-key")||"",i=e.getAttribute("data-bridge-token")||void 0,a=e.getAttribute("data-layout")||void 0,r=k(e.getAttribute("data-theme-overrides")),l=e.getAttribute("data-offering-id")||void 0,u=e.getAttribute("data-subscription-id")||void 0,s=e.getAttribute("data-metric")||void 0,d=e.getAttribute("data-featured-offering-id")||void 0,m=e.getAttribute("data-mode")||void 0,M=e.getAttribute("data-return-url")||void 0,S=e.getAttribute("data-default-status")||void 0,F=e.getAttribute("data-render-mode")||void 0,_=e.getAttribute("data-locale")||void 0,C=v(e,"data-page-size"),O=v(e,"data-poll-interval-ms"),I=e.getAttribute("data-theme")||void 0,R=e.getAttribute("data-cart-type")||void 0,W=e.getAttribute("data-target-id")||void 0,H=e.getAttribute("data-cta-text")||void 0,x=e.getAttribute("data-cta-url")||void 0,P=v(e,"data-max-plans"),K=j(e,"data-show-features");return {widget:t,tenantSlug:n,embedKey:o,bridgeToken:i,layout:a,themeOverrides:r,config:{offeringId:l,subscriptionId:u,metricName:s,featuredOfferingId:d,mode:m,returnUrl:M,defaultStatus:S,renderMode:F,locale:_,pageSize:C,pollIntervalMs:O,theme:I,cartType:R,targetId:W,ctaText:H,ctaUrl:x,maxPlans:P,showFeatures:K}}}function z(e,t,n){return new Promise((o,i)=>{if(typeof document=="undefined")return i(new Error("no document"));let a=document.querySelector(`script[data-aforo-bundle="${e}"]`);if(a){if(a.dataset.aforoLoaded==="1")return o();a.addEventListener("load",()=>o()),a.addEventListener("error",()=>i(new Error(`bundle load failed: ${e}`)));return}let r=document.createElement("script");r.src=`${t}/${e}.js`,r.async=true,r.crossOrigin="anonymous",r.dataset.aforoBundle=e,n&&r.setAttribute("nonce",n),r.addEventListener("load",()=>{r.dataset.aforoLoaded="1",o();}),r.addEventListener("error",()=>i(new Error(`bundle load failed: ${e}`))),document.head.appendChild(r);})}function L(e){if(!e.__aforoEmbedReadyFired){e.__aforoEmbedReadyFired=true;try{typeof e.aforoEmbedReady=="function"&&e.aforoEmbedReady();}catch(t){typeof console!="undefined"&&console.error(`${g} aforoEmbedReady callback threw`,t);}if(typeof document!="undefined"&&typeof CustomEvent!="undefined")try{document.dispatchEvent(new CustomEvent("aforoEmbedReady"));}catch(t){}}}async function E(e){if(typeof window=="undefined"||typeof document=="undefined")return;let t=window;if(window.location.protocol!=="https:"&&window.location.hostname!=="localhost"){typeof console!="undefined"&&console.error(`${g} Refusing to mount Aforo widgets on a non-HTTPS page. Embed Plugin requires HTTPS (FR-TIER-12). Current origin: ${window.location.origin}`);return}if(t.__aforoEmbedLoaderInitialized){typeof console!="undefined"&&console.warn(`${g} Loader already initialised on this page \u2014 skipping duplicate run.`);return}t.__aforoEmbedLoaderInitialized=true,t.aforoEmbed||(t.aforoEmbed=b);let n=D(),o=(n==null?void 0:n.getAttribute("nonce"))||null,i=(e==null?void 0:e.bundleBaseUrl)||G(n)||B,a=Array.from(document.querySelectorAll("[data-aforo-widget]"));if(a.length===0){L(t);return}let r=new Map;for(let u of a){let s=(u.getAttribute("data-aforo-widget")||"").trim();if(!U.has(s)){typeof console!="undefined"&&console.warn(`${g} Unknown widget id "${s}" \u2014 skipping`);continue}let d=r.get(s);d||(d=[],r.set(s,d)),d.push(u);}let l=Array.from(r.entries()).map(async([u,s])=>{try{await z(u,i,o);for(let d of s){let m=V(d);if(!m.widget||!m.tenantSlug||!m.embedKey){typeof console!="undefined"&&console.error(`${g} Placeholder missing required attributes (data-tenant-slug + data-embed-key). Skipping element.`,d);continue}b.mount(d,m);}}catch(d){typeof console!="undefined"&&console.error(`${g} Failed to load bundle for "${u}"`,d);}});await Promise.all(l).catch(()=>{}),L(t);}typeof document!="undefined"&&document.readyState!=="loading"?Promise.resolve().then(()=>{E();}):typeof document!="undefined"&&document.addEventListener("DOMContentLoaded",()=>{E();});b._loader={bootstrap:E};
|
|
2
2
|
export{b as AforoEmbed,E as bootstrap};//# sourceMappingURL=loader.mjs.map
|
|
3
3
|
//# sourceMappingURL=loader.mjs.map
|
package/dist/sri.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
3
|
-
"generatedAt": "2026-08-
|
|
2
|
+
"version": "1.0.6",
|
|
3
|
+
"generatedAt": "2026-08-26T08:25:03.608Z",
|
|
4
4
|
"bundles": {
|
|
5
|
-
"loader.js": "sha384-
|
|
6
|
-
"widgets/checkout-flow.js": "sha384-
|
|
7
|
-
"widgets/invoice-list.js": "sha384-
|
|
8
|
-
"widgets/payment-method.js": "sha384-
|
|
9
|
-
"widgets/pricing-card.js": "sha384-
|
|
10
|
-
"widgets/subscribe-button.js": "sha384-
|
|
11
|
-
"widgets/subscription-manager.js": "sha384-
|
|
12
|
-
"widgets/upgrade-cancel.js": "sha384-
|
|
13
|
-
"widgets/usage-meter.js": "sha384-
|
|
5
|
+
"loader.js": "sha384-rX5O1gvlt56peSNtNEJduwPfDsM5oLSlw6AFh0nBuysuBTup7dH3cqK9aKLzewWN",
|
|
6
|
+
"widgets/checkout-flow.js": "sha384-3Rb+nizUBhxFhOh2VUu+i2l1QzX5bNJwjVdxG+VTnWrRzPGeU+8znz/I83Uqo6Lo",
|
|
7
|
+
"widgets/invoice-list.js": "sha384-R7ugqnPN9QzMwuv41eyYVIHvhWXT1l9MUqv3/lkwpWqeBimUGj4Jum97jgL6HwXA",
|
|
8
|
+
"widgets/payment-method.js": "sha384-gAMorea0TI66Sv1ygVCqyKriR+mDNgNNeHyTuTJADzSJi4wATSTzcAAUqz1JPEVK",
|
|
9
|
+
"widgets/pricing-card.js": "sha384-O0pOl4rPkd915RHmoW63fs1B4zng9WL1gtoJVb06qBC2QnTL6NO1aYNWBsDKLkql",
|
|
10
|
+
"widgets/subscribe-button.js": "sha384-rmG1ib5UoYVby5fSBNB6Omyu8j9beLzZSxmc97vaWrHhzsK/OKy8NM73URpS9wuF",
|
|
11
|
+
"widgets/subscription-manager.js": "sha384-Brhr0eLy2khBWGC1IWjmHdqMHlu5ul+TNEjk5iIJ+iwRf7qPWkcLU3Qw2+u3x2WT",
|
|
12
|
+
"widgets/upgrade-cancel.js": "sha384-9as15ROb0lsazumcF0NbPpAzCjWDE7NUFACSKzl5XC3bzzK7y1kNQukuqsNzlcaX",
|
|
13
|
+
"widgets/usage-meter.js": "sha384-vA74x194TdKa54vMuxJzdc/TWMNkLG+XGohe873qqFFILos6LaJVLG2iRZzcULEP"
|
|
14
14
|
}
|
|
15
15
|
}
|