summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/common/linking
diff options
context:
space:
mode:
authorrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
committerrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
commitbce557cc2dc767628bed6aac87301a1be7c5431b (patch)
treeb51a051228d01fe3306cd7626d4a96768aadb944 /node_modules/@jet-app/app-store/tmp/src/common/linking
init commit
Diffstat (limited to 'node_modules/@jet-app/app-store/tmp/src/common/linking')
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/common/linking/external-deep-link.js73
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/common/linking/os-update-links.js42
2 files changed, 115 insertions, 0 deletions
diff --git a/node_modules/@jet-app/app-store/tmp/src/common/linking/external-deep-link.js b/node_modules/@jet-app/app-store/tmp/src/common/linking/external-deep-link.js
new file mode 100644
index 0000000..00031e4
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/common/linking/external-deep-link.js
@@ -0,0 +1,73 @@
+import * as models from "../../api/models";
+import * as serverData from "../../foundation/json-parsing/server-data";
+import * as mediaAttributes from "../../foundation/media/attributes";
+import * as objects from "../../foundation/util/objects";
+import * as metricsHelpersClicks from "../metrics/helpers/clicks";
+/**
+ * "External Deep Link" feature description
+ *
+ * This feature is one where a particular offer will behave like a normal offer when the app is not openable, but in
+ * which the openable state for the offer actually deep links to the third party app in question. This deep link uses
+ * a universal link that is plumbed through by Media API; the deep link is submitted and approved through
+ * App Store Connect and will be interpreted by the third party app in accordance with the external action.
+ *
+ * This feature's name is prefixed by the term "external" to differentiate from deep linking into the App Store app
+ * itself (such as deep linking into the search tab via Siri or the user's purchases through a finance page).
+ */
+/// The query parameter name to use when attaching the external deep link to a product URL.
+export const externalDeepLinkQueryParameter = "externalDeepLinkUrl";
+/// Query parameter name to use when attaching eligibility information for cpp deep links.
+export const cppDeepLinkDisabledQueryParameter = "isCppDeepLinkDisabled";
+/// Query parameter name to use when attaching the aligned region deep link to a product URL.
+export const alignedRegionDeepLinkQueryParameter = "alignedRegionDeepLinkUrl";
+/**
+ * Pulls out the external deep link url from the given data.
+ * @param {Data} data The data for the app that has the deep link.
+ * @return {string | null} The external deep link url, if it exists.
+ */
+export function deepLinkUrlFromData(objectGraph, data) {
+ if (!serverData.isDefinedNonNull(data)) {
+ return null;
+ }
+ return mediaAttributes.attributeAsString(data, "customUrl");
+}
+/**
+ * Wraps an action in a state action that executes an external deep link when the app is openable.
+ * @param {Action} action The action for the product that is being deep linked into.
+ * @param {string | null} adamId The adam ID of the app.
+ * @param {string | null} bundleId The bundle ID of the app.
+ * @param {string | null} deepLinkUrl The url for the deep link action.
+ * @param {boolean} includeBetaApps Whether to include beta apps in the resulting action.
+ * @param metricsClickOptions The metrics click options for the action.
+ * @return {Action} The action to use for the app that is deep linked.
+ */
+export function deepLinkActionWrappingAction(objectGraph, action, adamId, bundleId, deepLinkUrl, includeBetaApps, metricsClickOptions) {
+ // Only wrap in OfferStateAction on devices that are supported when there's a deep link present.
+ if (!serverData.isDefinedNonNullNonEmpty(deepLinkUrl) && objectGraph.client.deviceType !== "mac") {
+ return action;
+ }
+ let openAction;
+ if (objectGraph.client.isiOS) {
+ const openAppAction = new models.OpenAppAction(adamId, "app");
+ openAction = new models.AppLaunchTrampolineAction(bundleId, deepLinkUrl, openAppAction);
+ }
+ else {
+ openAction = new models.ExternalUrlAction(deepLinkUrl);
+ }
+ const clickOptions = objects.shallowCopyOf(metricsClickOptions);
+ clickOptions.actionType = "open";
+ clickOptions.actionDetails = { actionUrl: deepLinkUrl };
+ metricsHelpersClicks.addClickEventToAction(objectGraph, openAction, clickOptions, true, "button");
+ if (action instanceof models.OfferStateAction) {
+ action.openAction = openAction;
+ action.includeBetaApps = includeBetaApps;
+ return action;
+ }
+ else {
+ const stateAction = new models.OfferStateAction(adamId, action);
+ stateAction.openAction = openAction;
+ stateAction.includeBetaApps = includeBetaApps;
+ return stateAction;
+ }
+}
+//# sourceMappingURL=external-deep-link.js.map \ No newline at end of file
diff --git a/node_modules/@jet-app/app-store/tmp/src/common/linking/os-update-links.js b/node_modules/@jet-app/app-store/tmp/src/common/linking/os-update-links.js
new file mode 100644
index 0000000..cce8e9d
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/common/linking/os-update-links.js
@@ -0,0 +1,42 @@
+/**
+ * Created by ls on 12/15/18.
+ *
+ * A home for building application URL links for jumping to other applications.
+ */
+// region System Preference: Updates
+/**
+ * Build an URL that links to software update pref pane on given platform.
+ * Optionally, supply an major OS version to signal Preferences to initiate download for given version if that is supported by the platform.
+ * @param {DeviceType} deviceType Device type to request the update url for.
+ * @param {string | null} majorOSBundle Optional major OS bundle identifier, e.g. com.apple.InstallAssistant.Catalina
+ * @returns {string | null} URL that links into the "Software Updates" settings for given platform. `null` for platforms that we don't currently link into.
+ * @note Currently, only MAS is supported by this function as it is the only platform linking to Preference > OS Update.
+ */
+export function osUpdateUrl(deviceType, majorOSBundle = null) {
+ switch (deviceType) {
+ case "mac":
+ return macOSUpdateUrl(majorOSBundle);
+ default:
+ return null;
+ }
+}
+/**
+ * Build an URL that links to software update pref pane on macOS.
+ * Optionally, supply an major OS version to signal Preferences to initiate download for given version.
+ * @param {string | null} majorOSBundle Optional major OS bundle identifier, e.g. com.apple.InstallAssistant.Catalina
+ * @returns {string | null} URL that links into the "Software Updates" settings for macOS.
+ */
+function macOSUpdateUrl(majorOSBundle) {
+ /**
+ * Workaround for <rdar://problem/47124330> Parsing and building URLs should follow unified spec
+ * Manually build url.
+ */
+ // Preference URLs have no authority component.
+ let updateUrl = `x-apple.systempreferences:com.apple.preferences.softwareupdate?client=AppStore&variant=CUSTOMER`;
+ if (majorOSBundle) {
+ updateUrl += `&installMajorOSBundle=${majorOSBundle}`;
+ }
+ return updateUrl;
+}
+// endregion
+//# sourceMappingURL=os-update-links.js.map \ No newline at end of file