@@ -168497,8 +168497,9 @@ define("services/EntitlementsManager", function (require, exports, module) {
168497168497
168498168498 /**
168499168499 * Get the plan details from entitlements with fallback to free plan defaults. If the user is
168500- * in pro trial(isInProTrial API), then paidSubscriber will always be true as we need to treat user as paid.
168501- * you should use isInProTrial API to check if user is in pro trial if some trial-related logic needs to be done.
168500+ * in pro trial(isInProTrial API), then isSubscriber will always be true as we need to treat
168501+ * user as subcriber. you should use isInProTrial API to check if user is in pro trial if some
168502+ * trial-related logic needs to be done.
168502168503 * @returns {Promise<Object>} Plan details object
168503168504 */
168504168505 async function getPlanDetails() {
@@ -168511,14 +168512,15 @@ define("services/EntitlementsManager", function (require, exports, module) {
168511168512 // Fallback to free plan defaults
168512168513 const currentDate = Date.now();
168513168514 return {
168515+ isSubscriber: false,
168514168516 paidSubscriber: false,
168515168517 name: Strings.USER_FREE_PLAN_NAME_DO_NOT_TRANSLATE,
168516168518 validTill: currentDate + (FREE_PLAN_VALIDITY_DAYS * MS_IN_DAY)
168517168519 };
168518168520 }
168519168521
168520168522 /**
168521- * Check if user is in a pro trial. IF the user is in pro trail, then `plan.paidSubscriber ` will always be true.
168523+ * Check if user is in a pro trial. IF the user is in pro trail, then `plan.isSubscriber ` will always be true.
168522168524 * @returns {Promise<boolean>} True if user is in pro trial, false otherwise
168523168525 */
168524168526 async function isInProTrial() {
@@ -170246,16 +170248,20 @@ define("services/login-service", function (require, exports, module) {
170246170248 // Debounced trigger for entitlements changed
170247170249 let entitlementsChangedTimer = null;
170248170250
170251+ const ENTITLEMENT_CHANGED_DEBOUNCE_WINDOW = Phoenix.isTestWindow ? 100 : 1000;
170252+
170249170253 function _debounceEntitlementsChanged() {
170250170254 if (entitlementsChangedTimer) {
170251170255 // already scheduled, skip
170252170256 return;
170253170257 }
170254170258
170259+ // atmost 1 entitlement changed event will be triggered in this window to prevent too many entitlment changed
170260+ // events firing.
170255170261 entitlementsChangedTimer = setTimeout(() => {
170256170262 LoginService.trigger(EVENT_ENTITLEMENTS_CHANGED);
170257170263 entitlementsChangedTimer = null;
170258- }, 1000); // atmost 1 entitlement changed event will be triggered in a second
170264+ }, ENTITLEMENT_CHANGED_DEBOUNCE_WINDOW);
170259170265 }
170260170266
170261170267
@@ -170627,6 +170633,7 @@ define("services/login-service", function (require, exports, module) {
170627170633 if(entitlements.plan && (!entitlements.plan.validTill || currentDate > entitlements.plan.validTill)) {
170628170634 entitlements.plan = {
170629170635 ...entitlements.plan,
170636+ isSubscriber: false,
170630170637 paidSubscriber: false,
170631170638 name: Strings.USER_FREE_PLAN_NAME_DO_NOT_TRANSLATE,
170632170639 fullName: Strings.USER_FREE_PLAN_NAME_DO_NOT_TRANSLATE,
@@ -170664,7 +170671,8 @@ define("services/login-service", function (require, exports, module) {
170664170671 * ```javascript
170665170672 * {
170666170673 * plan: {
170667- * paidSubscriber: true, // Always true for trial users
170674+ * isSubscriber: true, // Always true for trial users
170675+ * paidSubscriber: false, // if the user is a paid for the plan, or is it an unpaid promo
170668170676 * name: "Phoenix Pro"
170669170677 * fullName: "Phoenix Pro" // this can be deceptive name like "Phoenix Pro For Education" to use in
170670170678 * // profile popup, not main branding
@@ -170680,11 +170688,12 @@ define("services/login-service", function (require, exports, module) {
170680170688 * ```
170681170689 *
170682170690 * **For logged-in trial users:**
170683- * - If remote response has `plan.paidSubscriber : false`, injects `paidSubscriber : true`
170691+ * - If remote response has `plan.isSubscriber : false`, injects `isSubscriber : true`
170684170692 * - Adds `isInProTrial: true` and `trialDaysRemaining`
170685170693 * - Injects `entitlements.liveEdit.activated: true`
170686- * - Note: Trial users may not be actual paid subscribers, but `paidSubscriber: true` is set
170687- * so all Phoenix code treats them as paid subscribers
170694+ * - Note: Trial users may not be actual paid subscribers, but `isSubscriber: true` is set
170695+ * so all Phoenix code treats them as subscribers. to check if they actually paid or not, use
170696+ * `paidSubscriber` field.
170688170697 *
170689170698 * **For logged-in users (full remote response):**
170690170699 * ```javascript
@@ -170695,6 +170704,7 @@ define("services/login-service", function (require, exports, module) {
170695170704 * name: "Phoenix Pro",
170696170705 * fullName: "Phoenix Pro" // this can be deceptive name like "Phoenix Pro For Education" to use in
170697170706 * // profile popup, not main branding
170707+ * isSubscriber: boolean,
170698170708 * paidSubscriber: boolean,
170699170709 * validTill: number // Timestamp
170700170710 * },
@@ -170740,7 +170750,7 @@ define("services/login-service", function (require, exports, module) {
170740170750 *
170741170751 * // Get current entitlements
170742170752 * const entitlements = await LoginService.getEffectiveEntitlements();
170743- * if (entitlements?.plan?.paidSubscriber ) {
170753+ * if (entitlements?.plan?.isSubscriber ) {
170744170754 * // Enable pro features
170745170755 * }
170746170756 * if (entitlements?.entitlements?.liveEdit?.activated) {
@@ -170763,8 +170773,8 @@ define("services/login-service", function (require, exports, module) {
170763170773 // now we need to grant trial, as user is entitled to trial if he is here.
170764170774 // User has active server plan(either with login or device license)
170765170775 if (serverEntitlements && serverEntitlements.plan) {
170766- if (serverEntitlements.plan.paidSubscriber ) {
170767- // Already a paid subscriber(or has device license), return as-is
170776+ if (serverEntitlements.plan.isSubscriber ) {
170777+ // Already a subscriber(or has device license), return as-is
170768170778 // never inject trail data in this case.
170769170779 return serverEntitlements;
170770170780 }
@@ -170774,7 +170784,8 @@ define("services/login-service", function (require, exports, module) {
170774170784 ...serverEntitlements,
170775170785 plan: {
170776170786 ...serverEntitlements.plan,
170777- paidSubscriber: true,
170787+ isSubscriber: true,
170788+ paidSubscriber: serverEntitlements.plan.paidSubscriber || false,
170778170789 name: brackets.config.main_pro_plan,
170779170790 fullName: brackets.config.main_pro_plan,
170780170791 validTill: dateNowFn() + trialDaysRemaining * MS_IN_DAY
@@ -170798,7 +170809,8 @@ define("services/login-service", function (require, exports, module) {
170798170809 // Non-logged-in, non licensed user with trial - return synthetic entitlements
170799170810 return {
170800170811 plan: {
170801- paidSubscriber: true,
170812+ isSubscriber: true,
170813+ paidSubscriber: false,
170802170814 name: brackets.config.main_pro_plan,
170803170815 fullName: brackets.config.main_pro_plan,
170804170816 validTill: dateNowFn() + trialDaysRemaining * MS_IN_DAY
@@ -171028,7 +171040,10 @@ define("services/login-utils", function (require, exports, module) {
171028171040 // Check paidSubscriber changes
171029171041 const currentPaidSub = current.plan && current.plan.paidSubscriber;
171030171042 const lastPaidSub = last.plan && last.plan.paidSubscriber;
171031- if (currentPaidSub !== lastPaidSub) {
171043+ // Check isSubscriber changes
171044+ const currentIsSubscriber = current.plan && current.plan.isSubscriber;
171045+ const lastIsSubscriber = last.plan && last.plan.isSubscriber;
171046+ if (currentIsSubscriber !== lastIsSubscriber || currentPaidSub !== lastPaidSub) {
171032171047 return true;
171033171048 }
171034171049
@@ -172061,7 +172076,7 @@ define("services/profile-menu", function (require, exports, module) {
172061172076 <i class="fa-solid fa-feather" style="margin-left: 3px;"></i>
172062172077 </span>
172063172078 </div>`;
172064- } else if (effectiveEntitlements.plan && effectiveEntitlements.plan.paidSubscriber ) {
172079+ } else if (effectiveEntitlements.plan && effectiveEntitlements.plan.isSubscriber ) {
172065172080 // Device-licensed user: show Phoenix Pro branding
172066172081 const planName = effectiveEntitlements.plan.fullName || brackets.config.main_pro_plan;
172067172082 proInfoHtml = `<div class="trial-plan-info">
@@ -172116,21 +172131,21 @@ define("services/profile-menu", function (require, exports, module) {
172116172131 // Phoenix.pro is only for display purposes and should not be used to gate features.
172117172132 // Use kernal mode apis for trusted check of pro features.
172118172133 Phoenix.pro.plan = {
172119- paidSubscriber : false,
172134+ isSubscriber : false,
172120172135 name: Strings.USER_FREE_PLAN_NAME_DO_NOT_TRANSLATE,
172121172136 fullName: Strings.USER_FREE_PLAN_NAME_DO_NOT_TRANSLATE
172122172137 };
172123172138 }
172124172139
172125172140 if (entitlements && entitlements.plan){
172126172141 Phoenix.pro.plan = {
172127- paidSubscriber : entitlements.plan.paidSubscriber ,
172142+ isSubscriber : entitlements.plan.isSubscriber ,
172128172143 name: entitlements.plan.name,
172129172144 fullName: entitlements.plan.fullName,
172130172145 validTill: entitlements.plan.validTill
172131172146 };
172132172147 }
172133- if (entitlements && entitlements.plan && entitlements.plan.paidSubscriber ) {
172148+ if (entitlements && entitlements.plan && entitlements.plan.isSubscriber ) {
172134172149 // Pro user (paid subscriber or trial): show short name branding with `name feather icon`(not full name)
172135172150 let displayName = entitlements.plan.name || brackets.config.main_pro_plan;
172136172151 if (entitlements.isInProTrial) {
@@ -172266,7 +172281,7 @@ define("services/profile-menu", function (require, exports, module) {
172266172281 // Update plan class and content based on paid subscriber status
172267172282 $planName.removeClass('user-plan-free user-plan-paid');
172268172283
172269- if (entitlements.plan.paidSubscriber ) {
172284+ if (entitlements.plan.isSubscriber ) {
172270172285 // Use pro styling with feather icon for pro users (paid or trial)
172271172286 if (entitlements.isInProTrial) {
172272172287 // For trial users: separate "Phoenix Pro" with icon from "(X days left)" text
@@ -172478,7 +172493,7 @@ define("services/profile-menu", function (require, exports, module) {
172478172493 const effectiveEntitlements = await KernalModeTrust.loginService.getEffectiveEntitlements();
172479172494 return effectiveEntitlements &&
172480172495 (effectiveEntitlements.isInProTrial ||
172481- (effectiveEntitlements.plan && effectiveEntitlements.plan.paidSubscriber ));
172496+ (effectiveEntitlements.plan && effectiveEntitlements.plan.isSubscriber ));
172482172497 } catch (error) {
172483172498 console.error('Failed to check Pro access status:', error);
172484172499 return false;
@@ -172493,7 +172508,7 @@ define("services/profile-menu", function (require, exports, module) {
172493172508 const effectiveEntitlements = await KernalModeTrust.loginService.getEffectiveEntitlements();
172494172509 if (effectiveEntitlements &&
172495172510 (effectiveEntitlements.isInProTrial ||
172496- (effectiveEntitlements.plan && effectiveEntitlements.plan.paidSubscriber ))) {
172511+ (effectiveEntitlements.plan && effectiveEntitlements.plan.isSubscriber ))) {
172497172512 console.log('Profile Menu: Found Pro entitlements (trial or device license), updating branding...');
172498172513 _updateBranding(effectiveEntitlements);
172499172514 } else {
@@ -172800,7 +172815,7 @@ define("services/promotions", function (require, exports, module) {
172800172815
172801172816 // getEntitlements() returns null if not logged in
172802172817 const entitlements = await LoginService.getEntitlements();
172803- return entitlements && entitlements.plan && entitlements.plan.paidSubscriber === true;
172818+ return entitlements && entitlements.plan && entitlements.plan.isSubscriber === true;
172804172819 } catch (error) {
172805172820 console.error("Error checking pro subscription:", error);
172806172821 return false;
0 commit comments