Skip to content

Commit

Permalink
SwG release 0.1.22.166 (#34444)
Browse files Browse the repository at this point in the history
  • Loading branch information
qidonna committed May 19, 2021
1 parent 829d4b1 commit 5338f93
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 16 deletions.
2 changes: 1 addition & 1 deletion third_party/subscriptions-project/config.js
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Version: 0.1.22.165 */
/** Version: 0.1.22.166 */
/**
* Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion third_party/subscriptions-project/swg-gaa.js
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Version: 0.1.22.165 */
/** Version: 0.1.22.166 */
/**
* Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.
*
Expand Down
118 changes: 104 additions & 14 deletions third_party/subscriptions-project/swg.js
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Version: 0.1.22.165 */
/** Version: 0.1.22.166 */
/**
* Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.
*
Expand Down Expand Up @@ -4511,7 +4511,7 @@ function feCached(url) {
*/
function feArgs(args) {
return Object.assign(args, {
'_client': 'SwG 0.1.22.165',
'_client': 'SwG 0.1.22.166',
});
}

Expand Down Expand Up @@ -5309,7 +5309,7 @@ class OffersFlow {
}

/**
* Shows "no subscription/contribution found" on activity iFrame view.
* Shows "no subscription found" on activity iFrame view.
*/
showNoEntitlementFoundToast() {
if (this.activityIframeView_) {
Expand Down Expand Up @@ -5725,7 +5725,7 @@ class ActivityPorts$1 {
'analyticsContext': context.toArray(),
'publicationId': pageConfig.getPublicationId(),
'productId': pageConfig.getProductId(),
'_client': 'SwG 0.1.22.165',
'_client': 'SwG 0.1.22.166',
'supportsEventManager': true,
},
args || {}
Expand Down Expand Up @@ -6571,7 +6571,7 @@ class AnalyticsService {
context.setTransactionId(getUuid());
}
context.setReferringOrigin(parseUrl(this.getReferrer_()).origin);
context.setClientVersion('SwG 0.1.22.165');
context.setClientVersion('SwG 0.1.22.166');
context.setUrl(getCanonicalUrl(this.doc_));

const utmParams = parseQueryString(this.getQueryString_());
Expand Down Expand Up @@ -7214,6 +7214,9 @@ class ButtonApi {
if (options['lang']) {
button.setAttribute('lang', options['lang']);
}
if (options['enable']) {
button.disabled = false;
}
button./*OK*/ innerHTML = BUTTON_INNER_HTML.replace(
'$theme$',
theme
Expand Down Expand Up @@ -7247,6 +7250,9 @@ class ButtonApi {
if (options['lang']) {
button.setAttribute('lang', options['lang']);
}
if (options['enable']) {
button.disabled = false;
}
button./*OK*/ innerHTML = BUTTON_INNER_HTML.replace(
'$theme$',
theme
Expand Down Expand Up @@ -7763,6 +7769,23 @@ class ExplicitDismissalConfig {
}
}

/**
* Predicates of whether or not to show button and prompt.
*/
class UiPredicates {
/**
* @param {boolean|undefined} canDisplayAutoPrompt
* @param {boolean|undefined} canDisplayButton
*/
constructor(canDisplayAutoPrompt, canDisplayButton) {
/** @const {boolean|undefined} */
this.canDisplayAutoPrompt = canDisplayAutoPrompt;

/** @const {boolean|undefined} */
this.canDisplayButton = canDisplayButton;
}
}

/**
* Copyright 2021 The Subscribe with Google Authors. All Rights Reserved.
*
Expand All @@ -7787,8 +7810,14 @@ class ClientConfig {
* @param {!./auto-prompt-config.AutoPromptConfig=} autoPromptConfig
* @param {string=} paySwgVersion
* @param {boolean=} useUpdatedOfferFlows
* @param {./auto-prompt-config.UiPredicates=} uiPredicates
*/
constructor(autoPromptConfig, paySwgVersion, useUpdatedOfferFlows) {
constructor(
autoPromptConfig,
paySwgVersion,
useUpdatedOfferFlows,
uiPredicates
) {
/** @const {!./auto-prompt-config.AutoPromptConfig|undefined} */
this.autoPromptConfig = autoPromptConfig;

Expand All @@ -7797,6 +7826,9 @@ class ClientConfig {

/** @const {boolean} */
this.useUpdatedOfferFlows = useUpdatedOfferFlows || false;

/** @const {./auto-prompt-config.UiPredicates|undefined} */
this.uiPredicates = uiPredicates;
}
}

Expand Down Expand Up @@ -7917,6 +7949,31 @@ class ClientConfigManager {
return this.clientOptions_.theme || ClientTheme.LIGHT;
}

/**
* Determines whether a subscription or contribution button should be disabled.
* @returns {!Promise<boolean|undefined>}
*/
shouldEnableButton() {
// Disable button if disableButton is set to be true in clientOptions.
// If disableButton is set to be false or not set, then always enable button.
// This is for testing purpose.
if (this.clientOptions_.disableButton) {
return Promise.resolve(false);
}

if (!this.responsePromise_) {
this.fetchClientConfig();
}
// UI predicates decides whether to enable button.
return this.responsePromise_.then((clientConfig) => {
if (clientConfig.uiPredicates?.canDisplayButton) {
return true;
} else {
return false;
}
});
}

/**
* Fetches the client config from the server.
* @return {!Promise<!ClientConfig>}
Expand Down Expand Up @@ -7955,10 +8012,21 @@ class ClientConfigManager {
autoPromptConfigJson.explicitDismissalConfig?.maxDismissalsResultingHideSeconds
);
}

const uiPredicatesJson = json['uiPredicates'];
let uiPredicates = undefined;
if (uiPredicatesJson) {
uiPredicates = new UiPredicates(
uiPredicatesJson.canDisplayAutoPrompt,
uiPredicatesJson.canDisplayButton
);
}

return new ClientConfig(
autoPromptConfig,
paySwgVersion,
json['useUpdatedOfferFlows']
json['useUpdatedOfferFlows'],
uiPredicates
);
}
}
Expand Down Expand Up @@ -8006,6 +8074,8 @@ class ContributionsFlow {
/** @private @const {!../components/dialog-manager.DialogManager} */
this.dialogManager_ = deps.dialogManager();

this.activityIframeView_ = null;

const isClosable = (options && options.isClosable) || true;

/** @private @const {!Promise<!ActivityIframeView>} */
Expand Down Expand Up @@ -8083,8 +8153,8 @@ class ContributionsFlow {
this.handleLinkRequest_.bind(this)
);
activityIframeView.on(SkuSelectedResponse, this.startPayFlow_.bind(this));

return this.dialogManager_.openView(activityIframeView);
this.activityIframeView_ = activityIframeView;
return this.dialogManager_.openView(this.activityIframeView_);
});
}

Expand All @@ -8102,6 +8172,15 @@ class ContributionsFlow {
}
});
}

/**
* Shows "no contribution found" on activity iFrame view.
*/
showNoEntitlementFoundToast() {
if (this.activityIframeView_) {
this.activityIframeView_.execute(new EntitlementsResponse());
}
}
}

/**
Expand Down Expand Up @@ -8274,7 +8353,7 @@ class DeferredAccountFlow {
}
}

const CSS$1 = "body{padding:0;margin:0}swg-container,swg-loading,swg-loading-animate,swg-loading-image{display:block}swg-loading-container{width:100%!important;display:-ms-flexbox!important;display:flex!important;-ms-flex-align:center!important;align-items:center!important;-ms-flex-pack:center!important;justify-content:center!important;min-height:148px!important;height:100%!important;bottom:0!important;margin-top:5px!important;z-index:2147483647!important}@media (min-height:630px), (min-width:630px){swg-loading-container{width:560px!important;margin-left:35px!important;border-top-left-radius:8px!important;border-top-right-radius:8px!important;background-color:#fff!important;box-shadow:0 1px 1px rgba(60,64,67,.3),0 1px 4px 1px rgba(60,64,67,.15)!important}}swg-loading{z-index:2147483647!important;width:36px;height:36px;overflow:hidden;animation:mspin-rotate 1568.63ms linear infinite}swg-loading-animate{animation:mspin-revrot 5332ms steps(4) infinite}swg-loading-image{background-image:url(https://news.google.com/swg/js/v1/loader.svg);background-size:100%;width:11664px;height:36px;animation:swg-loading-film 5332ms steps(324) infinite}@keyframes swg-loading-film{0%{transform:translateX(0)}to{transform:translateX(-11664px)}}@keyframes mspin-rotate{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes mspin-revrot{0%{transform:rotate(0deg)}to{transform:rotate(-1turn)}}\n/*# sourceURL=/./src/ui/ui.css*/";
const CSS$1 = "body{margin:0;padding:0}swg-container,swg-loading,swg-loading-animate,swg-loading-image{display:block}swg-loading-container{-ms-flex-align:center!important;-ms-flex-pack:center!important;align-items:center!important;bottom:0!important;display:-ms-flexbox!important;display:flex!important;height:100%!important;justify-content:center!important;margin-top:5px!important;min-height:148px!important;width:100%!important;z-index:2147483647!important}@media (min-height:630px),(min-width:630px){swg-loading-container{background-color:#fff!important;border-top-left-radius:8px!important;border-top-right-radius:8px!important;box-shadow:0 1px 1px rgba(60,64,67,.3),0 1px 4px 1px rgba(60,64,67,.15)!important;margin-left:35px!important;width:560px!important}}swg-loading{animation:mspin-rotate 1568.63ms linear infinite;height:36px;overflow:hidden;width:36px;z-index:2147483647!important}swg-loading-animate{animation:mspin-revrot 5332ms steps(4) infinite}swg-loading-image{animation:swg-loading-film 5332ms steps(324) infinite;background-image:url(https://news.google.com/swg/js/v1/loader.svg);background-size:100%;height:36px;width:11664px}@keyframes swg-loading-film{0%{transform:translateX(0)}to{transform:translateX(-11664px)}}@keyframes mspin-rotate{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes mspin-revrot{0%{transform:rotate(0deg)}to{transform:rotate(-1turn)}}\n/*# sourceURL=/./src/ui/ui.css*/";

/**
* Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.
Expand Down Expand Up @@ -16145,7 +16224,7 @@ class Propensity {
}
}

const CSS = ".swg-dialog,.swg-toast{box-sizing:border-box;background-color:#fff!important}.swg-toast{position:fixed!important;bottom:0!important;max-height:46px!important;z-index:2147483647!important;border:none!important}@media (max-height:640px), (max-width:640px){.swg-dialog,.swg-toast{width:480px!important;left:-240px!important;margin-left:50vw!important;border-top-left-radius:8px!important;border-top-right-radius:8px!important;box-shadow:0 1px 1px rgba(60,64,67,.3),0 1px 4px 1px rgba(60,64,67,.15)!important}}@media (min-width:640px) and (min-height:640px){.swg-dialog{width:630px!important;left:-315px!important;margin-left:50vw!important;background-color:transparent!important;border:none!important}.swg-toast{left:0!important}}@media (max-width:480px){.swg-dialog,.swg-toast{width:100%!important;left:0!important;right:0!important;margin-left:0!important}}\n/*# sourceURL=/./src/components/dialog.css*/";
const CSS = ".swg-dialog,.swg-toast{background-color:#fff!important;box-sizing:border-box}.swg-toast{border:none!important;bottom:0!important;max-height:46px!important;position:fixed!important;z-index:2147483647!important}@media (max-height:640px),(max-width:640px){.swg-dialog,.swg-toast{border-top-left-radius:8px!important;border-top-right-radius:8px!important;box-shadow:0 1px 1px rgba(60,64,67,.3),0 1px 4px 1px rgba(60,64,67,.15)!important;left:-240px!important;margin-left:50vw!important;width:480px!important}}@media (min-width:640px) and (min-height:640px){.swg-dialog{background-color:transparent!important;border:none!important;left:-315px!important;margin-left:50vw!important;width:630px!important}.swg-toast{left:0!important}}@media (max-width:480px){.swg-dialog,.swg-toast{left:0!important;margin-left:0!important;right:0!important;width:100%!important}}\n/*# sourceURL=/./src/components/dialog.css*/";

/**
* Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.
Expand Down Expand Up @@ -16425,6 +16504,9 @@ class ConfiguredRuntime {
/** @private {?OffersFlow} */
this.lastOffersFlow_ = null;

/** @private {?ContributionsFlow} */
this.lastContributionsFlow_ = null;

// Start listening to Google Analytics events, if applicable.
if (integr.enableGoogleAnalytics) {
/** @private @const {!GoogleAnalyticsEventListener} */
Expand Down Expand Up @@ -16730,11 +16812,19 @@ class ConfiguredRuntime {
/** @override */
showContributionOptions(options) {
return this.documentParsed_.then(() => {
const flow = new ContributionsFlow(this, options);
return flow.start();
this.lastContributionsFlow_ = new ContributionsFlow(this, options);
return this.lastContributionsFlow_.start();
});
}

/**
* Get the last contribution offers flow.
* @return {?ContributionsFlow}
*/
getLastContributionsFlow() {
return this.lastContributionsFlow_;
}

/** @override */
waitForSubscriptionLookup(accountPromise) {
return this.documentParsed_.then(() => {
Expand Down Expand Up @@ -16908,7 +16998,7 @@ class ConfiguredRuntime {
}

/**
* Get the last offers flow.
* Get the last subscription offers flow.
* @return {?OffersFlow}
*/
getLastOffersFlow() {
Expand Down

0 comments on commit 5338f93

Please sign in to comment.