@wowlabtech/mini-app-adapter 0.2.8 → 0.2.82
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 +62 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -16
- package/dist/index.d.ts +9 -16
- package/dist/index.js +62 -86
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -60,7 +60,8 @@ interface MiniAppViewportState {
|
|
|
60
60
|
height: number;
|
|
61
61
|
stableHeight: number;
|
|
62
62
|
}
|
|
63
|
-
interface
|
|
63
|
+
interface MiniAppLaunchParams {
|
|
64
|
+
launchParams?: Record<string, unknown>;
|
|
64
65
|
customLaunchParams: Record<string, unknown>;
|
|
65
66
|
}
|
|
66
67
|
interface MiniAppInitOptions {
|
|
@@ -200,11 +201,7 @@ interface MiniAppAdapter {
|
|
|
200
201
|
/**
|
|
201
202
|
* Reads platform launch parameters, if available.
|
|
202
203
|
*/
|
|
203
|
-
getLaunchParams?():
|
|
204
|
-
/**
|
|
205
|
-
* Returns custom launch parameters that are not part of platform service fields.
|
|
206
|
-
*/
|
|
207
|
-
getCustomLaunchParams(): MiniAppCustomLaunchParams;
|
|
204
|
+
getLaunchParams?(): MiniAppLaunchParams | undefined;
|
|
208
205
|
/**
|
|
209
206
|
* Decodes platform specific start parameter.
|
|
210
207
|
*/
|
|
@@ -351,8 +348,7 @@ declare abstract class BaseMiniAppAdapter implements MiniAppAdapter {
|
|
|
351
348
|
setBackButtonVisibility(_visible: boolean): void;
|
|
352
349
|
onAppearanceChange(callback: (appearance: 'dark' | 'light' | undefined) => void): () => void;
|
|
353
350
|
getInitData(): string | undefined;
|
|
354
|
-
getLaunchParams():
|
|
355
|
-
getCustomLaunchParams(): MiniAppCustomLaunchParams;
|
|
351
|
+
getLaunchParams(): MiniAppLaunchParams | undefined;
|
|
356
352
|
decodeStartParam(_param: string): unknown;
|
|
357
353
|
requestFullscreen(): void;
|
|
358
354
|
onViewportChange(callback: (state: {
|
|
@@ -386,6 +382,7 @@ declare abstract class BaseMiniAppAdapter implements MiniAppAdapter {
|
|
|
386
382
|
protected notifyEnvironmentChanged(): void;
|
|
387
383
|
protected onDestroy(): void;
|
|
388
384
|
protected registerDisposable(disposable: Disposable): () => void;
|
|
385
|
+
protected readCustomUrlParams(isServiceParam?: (key: string) => boolean): Record<string, unknown>;
|
|
389
386
|
private applyScrollGuards;
|
|
390
387
|
}
|
|
391
388
|
|
|
@@ -397,7 +394,7 @@ declare class MaxMiniAppAdapter extends BaseMiniAppAdapter {
|
|
|
397
394
|
init(_options?: MiniAppInitOptions): Promise<void>;
|
|
398
395
|
supports(capability: MiniAppCapability): boolean;
|
|
399
396
|
getInitData(): string | undefined;
|
|
400
|
-
getLaunchParams():
|
|
397
|
+
getLaunchParams(): MiniAppLaunchParams | undefined;
|
|
401
398
|
onBackButton(callback: () => void): () => void;
|
|
402
399
|
setBackButtonVisibility(visible: boolean): void;
|
|
403
400
|
openExternalLink(url: string): Promise<void>;
|
|
@@ -451,8 +448,7 @@ declare class TelegramMiniAppAdapter extends BaseMiniAppAdapter {
|
|
|
451
448
|
scanQRCode(options?: MiniAppQrScanOptions): Promise<string | null>;
|
|
452
449
|
closeApp(): Promise<void>;
|
|
453
450
|
getInitData(): string | undefined;
|
|
454
|
-
getLaunchParams():
|
|
455
|
-
getCustomLaunchParams(): MiniAppCustomLaunchParams;
|
|
451
|
+
getLaunchParams(): MiniAppLaunchParams | undefined;
|
|
456
452
|
decodeStartParam(param: string): unknown;
|
|
457
453
|
requestFullscreen(): void;
|
|
458
454
|
getViewportInsets(): MiniAppViewportInsets | undefined;
|
|
@@ -482,7 +478,6 @@ declare class TelegramMiniAppAdapter extends BaseMiniAppAdapter {
|
|
|
482
478
|
private stableHeightFromSdk;
|
|
483
479
|
private notifyViewHide;
|
|
484
480
|
private normalizeDecodedStartParam;
|
|
485
|
-
private readCustomUrlParams;
|
|
486
481
|
private parseQueryString;
|
|
487
482
|
private notifyViewRestore;
|
|
488
483
|
protected onDestroy(): void;
|
|
@@ -509,10 +504,8 @@ declare class VKMiniAppAdapter extends BaseMiniAppAdapter {
|
|
|
509
504
|
background?: string;
|
|
510
505
|
}): Promise<void>;
|
|
511
506
|
getEnvironment(): MiniAppEnvironmentInfo;
|
|
512
|
-
getLaunchParams():
|
|
513
|
-
getCustomLaunchParams(): MiniAppCustomLaunchParams;
|
|
507
|
+
getLaunchParams(): MiniAppLaunchParams | undefined;
|
|
514
508
|
openExternalLink(url: string): Promise<void>;
|
|
515
|
-
private readCustomUrlParams;
|
|
516
509
|
supports(capability: MiniAppCapability): Promise<boolean>;
|
|
517
510
|
requestPhone(): Promise<string | null>;
|
|
518
511
|
requestNotificationsPermission(): Promise<boolean>;
|
|
@@ -603,4 +596,4 @@ declare function trackPixelEvent(event: string, payload?: Record<string, unknown
|
|
|
603
596
|
|
|
604
597
|
declare function getPlatform(): MiniAppPlatform;
|
|
605
598
|
|
|
606
|
-
export { AdapterProvider, BaseMiniAppAdapter, type CreateAdapterOptions, MaxMiniAppAdapter, type MiniAppAdapter, type MiniAppCapability, type
|
|
599
|
+
export { AdapterProvider, BaseMiniAppAdapter, type CreateAdapterOptions, MaxMiniAppAdapter, type MiniAppAdapter, type MiniAppCapability, type MiniAppEnvironmentInfo, type MiniAppInitOptions, type MiniAppLaunchParams, type MiniAppPlatform, type MiniAppPopupOptions, type MiniAppQrScanOptions, type MiniAppShareStoryOptions, type MiniAppViewportState, ShellMiniAppAdapter, TelegramMiniAppAdapter, VKMiniAppAdapter, WebMiniAppAdapter, configureVkPixel, createAdapter, createShellAPI, detectPlatform, getActiveAdapter, getPlatform, isShell, isShellAndroid, isShellIOS, readShellPlatform, requestShellPushPermission, shell, storeShellToken, trackConversionEvent, trackPixelEvent, useAdapterTheme, useMiniAppAdapter, useSafeArea };
|
package/dist/index.d.ts
CHANGED
|
@@ -60,7 +60,8 @@ interface MiniAppViewportState {
|
|
|
60
60
|
height: number;
|
|
61
61
|
stableHeight: number;
|
|
62
62
|
}
|
|
63
|
-
interface
|
|
63
|
+
interface MiniAppLaunchParams {
|
|
64
|
+
launchParams?: Record<string, unknown>;
|
|
64
65
|
customLaunchParams: Record<string, unknown>;
|
|
65
66
|
}
|
|
66
67
|
interface MiniAppInitOptions {
|
|
@@ -200,11 +201,7 @@ interface MiniAppAdapter {
|
|
|
200
201
|
/**
|
|
201
202
|
* Reads platform launch parameters, if available.
|
|
202
203
|
*/
|
|
203
|
-
getLaunchParams?():
|
|
204
|
-
/**
|
|
205
|
-
* Returns custom launch parameters that are not part of platform service fields.
|
|
206
|
-
*/
|
|
207
|
-
getCustomLaunchParams(): MiniAppCustomLaunchParams;
|
|
204
|
+
getLaunchParams?(): MiniAppLaunchParams | undefined;
|
|
208
205
|
/**
|
|
209
206
|
* Decodes platform specific start parameter.
|
|
210
207
|
*/
|
|
@@ -351,8 +348,7 @@ declare abstract class BaseMiniAppAdapter implements MiniAppAdapter {
|
|
|
351
348
|
setBackButtonVisibility(_visible: boolean): void;
|
|
352
349
|
onAppearanceChange(callback: (appearance: 'dark' | 'light' | undefined) => void): () => void;
|
|
353
350
|
getInitData(): string | undefined;
|
|
354
|
-
getLaunchParams():
|
|
355
|
-
getCustomLaunchParams(): MiniAppCustomLaunchParams;
|
|
351
|
+
getLaunchParams(): MiniAppLaunchParams | undefined;
|
|
356
352
|
decodeStartParam(_param: string): unknown;
|
|
357
353
|
requestFullscreen(): void;
|
|
358
354
|
onViewportChange(callback: (state: {
|
|
@@ -386,6 +382,7 @@ declare abstract class BaseMiniAppAdapter implements MiniAppAdapter {
|
|
|
386
382
|
protected notifyEnvironmentChanged(): void;
|
|
387
383
|
protected onDestroy(): void;
|
|
388
384
|
protected registerDisposable(disposable: Disposable): () => void;
|
|
385
|
+
protected readCustomUrlParams(isServiceParam?: (key: string) => boolean): Record<string, unknown>;
|
|
389
386
|
private applyScrollGuards;
|
|
390
387
|
}
|
|
391
388
|
|
|
@@ -397,7 +394,7 @@ declare class MaxMiniAppAdapter extends BaseMiniAppAdapter {
|
|
|
397
394
|
init(_options?: MiniAppInitOptions): Promise<void>;
|
|
398
395
|
supports(capability: MiniAppCapability): boolean;
|
|
399
396
|
getInitData(): string | undefined;
|
|
400
|
-
getLaunchParams():
|
|
397
|
+
getLaunchParams(): MiniAppLaunchParams | undefined;
|
|
401
398
|
onBackButton(callback: () => void): () => void;
|
|
402
399
|
setBackButtonVisibility(visible: boolean): void;
|
|
403
400
|
openExternalLink(url: string): Promise<void>;
|
|
@@ -451,8 +448,7 @@ declare class TelegramMiniAppAdapter extends BaseMiniAppAdapter {
|
|
|
451
448
|
scanQRCode(options?: MiniAppQrScanOptions): Promise<string | null>;
|
|
452
449
|
closeApp(): Promise<void>;
|
|
453
450
|
getInitData(): string | undefined;
|
|
454
|
-
getLaunchParams():
|
|
455
|
-
getCustomLaunchParams(): MiniAppCustomLaunchParams;
|
|
451
|
+
getLaunchParams(): MiniAppLaunchParams | undefined;
|
|
456
452
|
decodeStartParam(param: string): unknown;
|
|
457
453
|
requestFullscreen(): void;
|
|
458
454
|
getViewportInsets(): MiniAppViewportInsets | undefined;
|
|
@@ -482,7 +478,6 @@ declare class TelegramMiniAppAdapter extends BaseMiniAppAdapter {
|
|
|
482
478
|
private stableHeightFromSdk;
|
|
483
479
|
private notifyViewHide;
|
|
484
480
|
private normalizeDecodedStartParam;
|
|
485
|
-
private readCustomUrlParams;
|
|
486
481
|
private parseQueryString;
|
|
487
482
|
private notifyViewRestore;
|
|
488
483
|
protected onDestroy(): void;
|
|
@@ -509,10 +504,8 @@ declare class VKMiniAppAdapter extends BaseMiniAppAdapter {
|
|
|
509
504
|
background?: string;
|
|
510
505
|
}): Promise<void>;
|
|
511
506
|
getEnvironment(): MiniAppEnvironmentInfo;
|
|
512
|
-
getLaunchParams():
|
|
513
|
-
getCustomLaunchParams(): MiniAppCustomLaunchParams;
|
|
507
|
+
getLaunchParams(): MiniAppLaunchParams | undefined;
|
|
514
508
|
openExternalLink(url: string): Promise<void>;
|
|
515
|
-
private readCustomUrlParams;
|
|
516
509
|
supports(capability: MiniAppCapability): Promise<boolean>;
|
|
517
510
|
requestPhone(): Promise<string | null>;
|
|
518
511
|
requestNotificationsPermission(): Promise<boolean>;
|
|
@@ -603,4 +596,4 @@ declare function trackPixelEvent(event: string, payload?: Record<string, unknown
|
|
|
603
596
|
|
|
604
597
|
declare function getPlatform(): MiniAppPlatform;
|
|
605
598
|
|
|
606
|
-
export { AdapterProvider, BaseMiniAppAdapter, type CreateAdapterOptions, MaxMiniAppAdapter, type MiniAppAdapter, type MiniAppCapability, type
|
|
599
|
+
export { AdapterProvider, BaseMiniAppAdapter, type CreateAdapterOptions, MaxMiniAppAdapter, type MiniAppAdapter, type MiniAppCapability, type MiniAppEnvironmentInfo, type MiniAppInitOptions, type MiniAppLaunchParams, type MiniAppPlatform, type MiniAppPopupOptions, type MiniAppQrScanOptions, type MiniAppShareStoryOptions, type MiniAppViewportState, ShellMiniAppAdapter, TelegramMiniAppAdapter, VKMiniAppAdapter, WebMiniAppAdapter, configureVkPixel, createAdapter, createShellAPI, detectPlatform, getActiveAdapter, getPlatform, isShell, isShellAndroid, isShellIOS, readShellPlatform, requestShellPushPermission, shell, storeShellToken, trackConversionEvent, trackPixelEvent, useAdapterTheme, useMiniAppAdapter, useSafeArea };
|
package/dist/index.js
CHANGED
|
@@ -606,10 +606,9 @@ var BaseMiniAppAdapter = class {
|
|
|
606
606
|
return void 0;
|
|
607
607
|
}
|
|
608
608
|
getLaunchParams() {
|
|
609
|
-
return
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
return { customLaunchParams: {} };
|
|
609
|
+
return {
|
|
610
|
+
customLaunchParams: this.readCustomUrlParams()
|
|
611
|
+
};
|
|
613
612
|
}
|
|
614
613
|
decodeStartParam(_param) {
|
|
615
614
|
return void 0;
|
|
@@ -750,6 +749,34 @@ var BaseMiniAppAdapter = class {
|
|
|
750
749
|
registerDisposable(disposable) {
|
|
751
750
|
return this.disposables.add(disposable);
|
|
752
751
|
}
|
|
752
|
+
readCustomUrlParams(isServiceParam) {
|
|
753
|
+
if (typeof window === "undefined") {
|
|
754
|
+
return {};
|
|
755
|
+
}
|
|
756
|
+
const result = {};
|
|
757
|
+
const append = (source) => {
|
|
758
|
+
const keys = /* @__PURE__ */ new Set();
|
|
759
|
+
for (const [key] of source.entries()) {
|
|
760
|
+
keys.add(key);
|
|
761
|
+
}
|
|
762
|
+
for (const key of keys) {
|
|
763
|
+
if (isServiceParam?.(key)) {
|
|
764
|
+
continue;
|
|
765
|
+
}
|
|
766
|
+
const values = source.getAll(key);
|
|
767
|
+
if (!values.length) {
|
|
768
|
+
continue;
|
|
769
|
+
}
|
|
770
|
+
result[key] = values.length === 1 ? values[0] : values;
|
|
771
|
+
}
|
|
772
|
+
};
|
|
773
|
+
append(new URLSearchParams(window.location.search));
|
|
774
|
+
const hash = window.location.hash.startsWith("#") ? window.location.hash.slice(1) : window.location.hash;
|
|
775
|
+
if (hash && hash.includes("=")) {
|
|
776
|
+
append(new URLSearchParams(hash));
|
|
777
|
+
}
|
|
778
|
+
return result;
|
|
779
|
+
}
|
|
753
780
|
applyScrollGuards() {
|
|
754
781
|
if (typeof document === "undefined") {
|
|
755
782
|
return void 0;
|
|
@@ -834,7 +861,10 @@ var MaxMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
834
861
|
return this.initData;
|
|
835
862
|
}
|
|
836
863
|
getLaunchParams() {
|
|
837
|
-
return
|
|
864
|
+
return {
|
|
865
|
+
launchParams: this.initDataUnsafe,
|
|
866
|
+
customLaunchParams: this.readCustomUrlParams()
|
|
867
|
+
};
|
|
838
868
|
}
|
|
839
869
|
onBackButton(callback) {
|
|
840
870
|
const bridge2 = getMaxBridge();
|
|
@@ -1419,13 +1449,6 @@ var TelegramMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
1419
1449
|
}
|
|
1420
1450
|
}
|
|
1421
1451
|
getLaunchParams() {
|
|
1422
|
-
try {
|
|
1423
|
-
return retrieveLaunchParams();
|
|
1424
|
-
} catch {
|
|
1425
|
-
return void 0;
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
getCustomLaunchParams() {
|
|
1429
1452
|
const customFromUrl = this.readCustomUrlParams((key) => key.toLowerCase().startsWith("tgwebapp"));
|
|
1430
1453
|
let customFromStartParam = {};
|
|
1431
1454
|
try {
|
|
@@ -1434,14 +1457,21 @@ var TelegramMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
1434
1457
|
if (typeof startParam === "string" && startParam) {
|
|
1435
1458
|
customFromStartParam = this.normalizeDecodedStartParam(startParam);
|
|
1436
1459
|
}
|
|
1460
|
+
return {
|
|
1461
|
+
launchParams,
|
|
1462
|
+
customLaunchParams: {
|
|
1463
|
+
...customFromUrl,
|
|
1464
|
+
...customFromStartParam
|
|
1465
|
+
}
|
|
1466
|
+
};
|
|
1437
1467
|
} catch {
|
|
1468
|
+
return {
|
|
1469
|
+
customLaunchParams: {
|
|
1470
|
+
...customFromUrl,
|
|
1471
|
+
...customFromStartParam
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1438
1474
|
}
|
|
1439
|
-
return {
|
|
1440
|
-
customLaunchParams: {
|
|
1441
|
-
...customFromUrl,
|
|
1442
|
-
...customFromStartParam
|
|
1443
|
-
}
|
|
1444
|
-
};
|
|
1445
1475
|
}
|
|
1446
1476
|
decodeStartParam(param) {
|
|
1447
1477
|
try {
|
|
@@ -1808,34 +1838,6 @@ var TelegramMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
1808
1838
|
}
|
|
1809
1839
|
return {};
|
|
1810
1840
|
}
|
|
1811
|
-
readCustomUrlParams(isServiceParam) {
|
|
1812
|
-
if (typeof window === "undefined") {
|
|
1813
|
-
return {};
|
|
1814
|
-
}
|
|
1815
|
-
const result = {};
|
|
1816
|
-
const append = (source) => {
|
|
1817
|
-
const keys = /* @__PURE__ */ new Set();
|
|
1818
|
-
for (const [key] of source.entries()) {
|
|
1819
|
-
keys.add(key);
|
|
1820
|
-
}
|
|
1821
|
-
for (const key of keys) {
|
|
1822
|
-
if (isServiceParam(key)) {
|
|
1823
|
-
continue;
|
|
1824
|
-
}
|
|
1825
|
-
const values = source.getAll(key);
|
|
1826
|
-
if (!values.length) {
|
|
1827
|
-
continue;
|
|
1828
|
-
}
|
|
1829
|
-
result[key] = values.length === 1 ? values[0] : values;
|
|
1830
|
-
}
|
|
1831
|
-
};
|
|
1832
|
-
append(new URLSearchParams(window.location.search));
|
|
1833
|
-
const hash = window.location.hash.startsWith("#") ? window.location.hash.slice(1) : window.location.hash;
|
|
1834
|
-
if (hash && hash.includes("=")) {
|
|
1835
|
-
append(new URLSearchParams(hash));
|
|
1836
|
-
}
|
|
1837
|
-
return result;
|
|
1838
|
-
}
|
|
1839
1841
|
parseQueryString(value) {
|
|
1840
1842
|
const normalized = value.startsWith("?") ? value.slice(1) : value;
|
|
1841
1843
|
const params = new URLSearchParams(normalized);
|
|
@@ -2018,16 +2020,22 @@ var VKMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
2018
2020
|
}
|
|
2019
2021
|
getLaunchParams() {
|
|
2020
2022
|
if (!this.launchParams) {
|
|
2021
|
-
return
|
|
2023
|
+
return {
|
|
2024
|
+
customLaunchParams: this.readCustomUrlParams((key) => {
|
|
2025
|
+
const normalized = key.toLowerCase();
|
|
2026
|
+
return normalized.startsWith("vk_") || normalized === "sign";
|
|
2027
|
+
})
|
|
2028
|
+
};
|
|
2022
2029
|
}
|
|
2023
2030
|
return {
|
|
2024
|
-
launchParams:
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
+
launchParams: {
|
|
2032
|
+
bridge: this.launchParams,
|
|
2033
|
+
query: this.queryParams
|
|
2034
|
+
},
|
|
2035
|
+
customLaunchParams: this.readCustomUrlParams((key) => {
|
|
2036
|
+
const normalized = key.toLowerCase();
|
|
2037
|
+
return normalized.startsWith("vk_") || normalized === "sign";
|
|
2038
|
+
})
|
|
2031
2039
|
};
|
|
2032
2040
|
}
|
|
2033
2041
|
async openExternalLink(url) {
|
|
@@ -2040,38 +2048,6 @@ var VKMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
2040
2048
|
a.click();
|
|
2041
2049
|
a.remove();
|
|
2042
2050
|
}
|
|
2043
|
-
readCustomUrlParams() {
|
|
2044
|
-
if (typeof window === "undefined") {
|
|
2045
|
-
return {};
|
|
2046
|
-
}
|
|
2047
|
-
const result = {};
|
|
2048
|
-
const isServiceParam = (key) => {
|
|
2049
|
-
const normalized = key.toLowerCase();
|
|
2050
|
-
return normalized.startsWith("vk_") || normalized === "sign";
|
|
2051
|
-
};
|
|
2052
|
-
const append = (source) => {
|
|
2053
|
-
const keys = /* @__PURE__ */ new Set();
|
|
2054
|
-
for (const [key] of source.entries()) {
|
|
2055
|
-
keys.add(key);
|
|
2056
|
-
}
|
|
2057
|
-
for (const key of keys) {
|
|
2058
|
-
if (isServiceParam(key)) {
|
|
2059
|
-
continue;
|
|
2060
|
-
}
|
|
2061
|
-
const values = source.getAll(key);
|
|
2062
|
-
if (!values.length) {
|
|
2063
|
-
continue;
|
|
2064
|
-
}
|
|
2065
|
-
result[key] = values.length === 1 ? values[0] : values;
|
|
2066
|
-
}
|
|
2067
|
-
};
|
|
2068
|
-
append(new URLSearchParams(window.location.search));
|
|
2069
|
-
const hash = window.location.hash.startsWith("#") ? window.location.hash.slice(1) : window.location.hash;
|
|
2070
|
-
if (hash && hash.includes("=")) {
|
|
2071
|
-
append(new URLSearchParams(hash));
|
|
2072
|
-
}
|
|
2073
|
-
return result;
|
|
2074
|
-
}
|
|
2075
2051
|
async supports(capability) {
|
|
2076
2052
|
switch (capability) {
|
|
2077
2053
|
case "haptics": {
|