@wowlabtech/mini-app-adapter 0.2.3 → 0.2.4
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/dist/index.cjs +124 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -4
- package/dist/index.d.ts +38 -4
- package/dist/index.js +124 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -638,7 +638,8 @@ var BaseMiniAppAdapter = class {
|
|
|
638
638
|
async openExternalLink(url) {
|
|
639
639
|
window.open(url, "_blank", "noopener,noreferrer");
|
|
640
640
|
}
|
|
641
|
-
async openInternalLink(
|
|
641
|
+
async openInternalLink(url) {
|
|
642
|
+
window.open(url, "_self", "noopener,noreferrer");
|
|
642
643
|
}
|
|
643
644
|
async closeApp() {
|
|
644
645
|
if (window.history.length > 1) {
|
|
@@ -864,6 +865,10 @@ var MaxMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
864
865
|
return Boolean(bridge2?.BackButton?.onClick);
|
|
865
866
|
case "backButtonVisibility":
|
|
866
867
|
return Boolean(bridge2?.BackButton?.show && bridge2.BackButton.hide);
|
|
868
|
+
case "openInternalLink":
|
|
869
|
+
return typeof bridge2?.openMaxLink === "function";
|
|
870
|
+
case "downloadFile":
|
|
871
|
+
return typeof bridge2?.downloadFile === "function";
|
|
867
872
|
case "requestPhone":
|
|
868
873
|
if (!bridge2) {
|
|
869
874
|
return false;
|
|
@@ -918,6 +923,14 @@ var MaxMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
918
923
|
}
|
|
919
924
|
await super.openExternalLink(url);
|
|
920
925
|
}
|
|
926
|
+
async openInternalLink(url) {
|
|
927
|
+
const bridge2 = getMaxBridge();
|
|
928
|
+
if (bridge2?.openMaxLink) {
|
|
929
|
+
bridge2.openMaxLink(url);
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
await super.openInternalLink(url);
|
|
933
|
+
}
|
|
921
934
|
async closeApp() {
|
|
922
935
|
const bridge2 = getMaxBridge();
|
|
923
936
|
if (bridge2?.close) {
|
|
@@ -1314,6 +1327,30 @@ var TelegramMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
1314
1327
|
return import_sdk_react.backButton.hide.isSupported();
|
|
1315
1328
|
case "bindCssVariables":
|
|
1316
1329
|
return true;
|
|
1330
|
+
case "openInternalLink":
|
|
1331
|
+
return true;
|
|
1332
|
+
case "requestFullscreen":
|
|
1333
|
+
return Boolean(
|
|
1334
|
+
typeof import_sdk.viewport.requestFullscreen === "function" || import_sdk_react.viewport.requestFullscreen?.isAvailable?.()
|
|
1335
|
+
);
|
|
1336
|
+
case "verticalSwipes":
|
|
1337
|
+
return Boolean(
|
|
1338
|
+
import_sdk.swipeBehavior.enableVertical.isAvailable() || import_sdk.swipeBehavior.disableVertical.isAvailable()
|
|
1339
|
+
);
|
|
1340
|
+
case "viewVisibility":
|
|
1341
|
+
return true;
|
|
1342
|
+
case "shareUrl":
|
|
1343
|
+
return typeof import_sdk.shareURL === "function";
|
|
1344
|
+
case "shareStory":
|
|
1345
|
+
return typeof import_sdk.shareStory === "function";
|
|
1346
|
+
case "copyTextToClipboard":
|
|
1347
|
+
return typeof import_sdk.copyTextToClipboard === "function";
|
|
1348
|
+
case "downloadFile":
|
|
1349
|
+
return typeof import_sdk.downloadFile === "function";
|
|
1350
|
+
case "addToHomeScreen":
|
|
1351
|
+
return typeof import_sdk.addToHomeScreen?.isAvailable === "function" ? import_sdk.addToHomeScreen.isAvailable() : typeof import_sdk.addToHomeScreen === "function";
|
|
1352
|
+
case "checkHomeScreenStatus":
|
|
1353
|
+
return typeof import_sdk.checkHomeScreenStatus === "function";
|
|
1317
1354
|
case "requestPhone": {
|
|
1318
1355
|
return Boolean(isFeatureAvailable(import_sdk.requestPhoneAccess) || isFeatureAvailable(import_sdk.requestContact));
|
|
1319
1356
|
}
|
|
@@ -1559,7 +1596,15 @@ var TelegramMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
1559
1596
|
await super.downloadFile(url, filename);
|
|
1560
1597
|
}
|
|
1561
1598
|
async shareStory(mediaUrl, options) {
|
|
1562
|
-
|
|
1599
|
+
const text = options?.telegram?.text ?? options?.text;
|
|
1600
|
+
const widgetLink = options?.telegram?.widgetLink ?? (options?.link ? {
|
|
1601
|
+
url: options.link.url,
|
|
1602
|
+
...options.link.name ? { name: options.link.name } : {}
|
|
1603
|
+
} : void 0);
|
|
1604
|
+
(0, import_sdk.shareStory)(mediaUrl, {
|
|
1605
|
+
...text ? { text } : {},
|
|
1606
|
+
...widgetLink ? { widgetLink } : {}
|
|
1607
|
+
});
|
|
1563
1608
|
}
|
|
1564
1609
|
async addToHomeScreen() {
|
|
1565
1610
|
const isAvailable = typeof import_sdk.addToHomeScreen?.isAvailable === "function" ? import_sdk.addToHomeScreen.isAvailable() : true;
|
|
@@ -1914,17 +1959,41 @@ var VKMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
1914
1959
|
};
|
|
1915
1960
|
}
|
|
1916
1961
|
async supports(capability) {
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1962
|
+
switch (capability) {
|
|
1963
|
+
case "haptics": {
|
|
1964
|
+
const [impact, notification, selection] = await Promise.all([
|
|
1965
|
+
this.supportsBridgeMethod("VKWebAppTapticImpactOccurred"),
|
|
1966
|
+
this.supportsBridgeMethod("VKWebAppTapticNotificationOccurred"),
|
|
1967
|
+
this.supportsBridgeMethod("VKWebAppTapticSelectionChanged")
|
|
1968
|
+
]);
|
|
1969
|
+
return impact || notification || selection;
|
|
1970
|
+
}
|
|
1971
|
+
case "qrScanner":
|
|
1972
|
+
return this.supportsBridgeMethod("VKWebAppOpenCodeReader");
|
|
1973
|
+
case "requestPhone": {
|
|
1974
|
+
const [supportsPhoneNumber, supportsPersonalCard] = await Promise.all([
|
|
1975
|
+
this.supportsBridgeMethod("VKWebAppGetPhoneNumber"),
|
|
1976
|
+
this.supportsBridgeMethod("VKWebAppGetPersonalCard")
|
|
1977
|
+
]);
|
|
1978
|
+
return supportsPhoneNumber || supportsPersonalCard;
|
|
1979
|
+
}
|
|
1980
|
+
case "notifications":
|
|
1981
|
+
return this.supportsBridgeMethod("VKWebAppAllowNotifications");
|
|
1982
|
+
case "shareUrl":
|
|
1983
|
+
return this.supportsBridgeMethod("VKWebAppShare");
|
|
1984
|
+
case "shareStory":
|
|
1985
|
+
return this.supportsBridgeMethod("VKWebAppShowStoryBox");
|
|
1986
|
+
case "downloadFile":
|
|
1987
|
+
return this.supportsBridgeMethod("VKWebAppDownloadFile");
|
|
1988
|
+
case "addToHomeScreen":
|
|
1989
|
+
return this.supportsBridgeMethod("VKWebAppAddToHomeScreen");
|
|
1990
|
+
case "denyNotifications":
|
|
1991
|
+
return this.supportsBridgeMethod("VKWebAppDenyNotifications");
|
|
1992
|
+
case "viewVisibility":
|
|
1993
|
+
return true;
|
|
1994
|
+
default:
|
|
1995
|
+
return await super.supports(capability);
|
|
1926
1996
|
}
|
|
1927
|
-
return await super.supports(capability);
|
|
1928
1997
|
}
|
|
1929
1998
|
async requestPhone() {
|
|
1930
1999
|
const [supportsPhoneNumber, supportsPersonalCard] = await Promise.all([
|
|
@@ -2026,9 +2095,34 @@ var VKMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
2026
2095
|
};
|
|
2027
2096
|
}
|
|
2028
2097
|
async shareStory(mediaUrl, _options) {
|
|
2098
|
+
const options = _options;
|
|
2099
|
+
const vkOptions = options?.vk;
|
|
2100
|
+
const fallbackAttachment = options?.link ? {
|
|
2101
|
+
type: "url",
|
|
2102
|
+
text: "open",
|
|
2103
|
+
url: options.link.url
|
|
2104
|
+
} : void 0;
|
|
2105
|
+
const fallbackStickers = options?.text ? [{
|
|
2106
|
+
sticker_type: "native",
|
|
2107
|
+
sticker: {
|
|
2108
|
+
action_type: "text",
|
|
2109
|
+
action: {
|
|
2110
|
+
text: options.text,
|
|
2111
|
+
style: "classic",
|
|
2112
|
+
background_style: "none"
|
|
2113
|
+
},
|
|
2114
|
+
transform: {
|
|
2115
|
+
gravity: "center_bottom",
|
|
2116
|
+
translation_y: -0.2
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
}] : void 0;
|
|
2029
2120
|
const bridgeOptions = {
|
|
2030
|
-
background_type: "image",
|
|
2031
|
-
url: mediaUrl
|
|
2121
|
+
background_type: vkOptions?.backgroundType ?? "image",
|
|
2122
|
+
url: mediaUrl,
|
|
2123
|
+
locked: vkOptions?.locked ?? true,
|
|
2124
|
+
...vkOptions?.attachment ?? fallbackAttachment ? { attachment: vkOptions?.attachment ?? fallbackAttachment } : {},
|
|
2125
|
+
...vkOptions?.stickers ?? fallbackStickers ? { stickers: vkOptions?.stickers ?? fallbackStickers } : {}
|
|
2032
2126
|
};
|
|
2033
2127
|
await import_vk_bridge.default.send("VKWebAppShowStoryBox", bridgeOptions);
|
|
2034
2128
|
}
|
|
@@ -2417,6 +2511,22 @@ var WebMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
2417
2511
|
});
|
|
2418
2512
|
}
|
|
2419
2513
|
}
|
|
2514
|
+
supports(capability) {
|
|
2515
|
+
switch (capability) {
|
|
2516
|
+
case "copyTextToClipboard":
|
|
2517
|
+
return typeof navigator !== "undefined" && Boolean(navigator.clipboard?.writeText);
|
|
2518
|
+
case "downloadFile":
|
|
2519
|
+
return typeof document !== "undefined";
|
|
2520
|
+
case "shareUrl":
|
|
2521
|
+
return typeof navigator !== "undefined" && (Boolean(navigator.share) || Boolean(navigator.clipboard?.writeText));
|
|
2522
|
+
case "addToHomeScreen":
|
|
2523
|
+
return /android/i.test(navigator.userAgent) && Boolean(this.deferredPrompt);
|
|
2524
|
+
case "checkHomeScreenStatus":
|
|
2525
|
+
return true;
|
|
2526
|
+
default:
|
|
2527
|
+
return super.supports(capability);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2420
2530
|
async downloadFile(url, filename) {
|
|
2421
2531
|
try {
|
|
2422
2532
|
await triggerFileDownload(url, filename, { preferBlob: true });
|