@wowlabtech/mini-app-adapter 0.2.7 → 0.2.81
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 +105 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -6
- package/dist/index.d.ts +13 -6
- package/dist/index.js +105 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -664,7 +664,9 @@ var BaseMiniAppAdapter = class {
|
|
|
664
664
|
return void 0;
|
|
665
665
|
}
|
|
666
666
|
getLaunchParams() {
|
|
667
|
-
return
|
|
667
|
+
return {
|
|
668
|
+
customLaunchParams: this.readCustomUrlParams()
|
|
669
|
+
};
|
|
668
670
|
}
|
|
669
671
|
decodeStartParam(_param) {
|
|
670
672
|
return void 0;
|
|
@@ -805,6 +807,34 @@ var BaseMiniAppAdapter = class {
|
|
|
805
807
|
registerDisposable(disposable) {
|
|
806
808
|
return this.disposables.add(disposable);
|
|
807
809
|
}
|
|
810
|
+
readCustomUrlParams(isServiceParam) {
|
|
811
|
+
if (typeof window === "undefined") {
|
|
812
|
+
return {};
|
|
813
|
+
}
|
|
814
|
+
const result = {};
|
|
815
|
+
const append = (source) => {
|
|
816
|
+
const keys = /* @__PURE__ */ new Set();
|
|
817
|
+
for (const [key] of source.entries()) {
|
|
818
|
+
keys.add(key);
|
|
819
|
+
}
|
|
820
|
+
for (const key of keys) {
|
|
821
|
+
if (isServiceParam?.(key)) {
|
|
822
|
+
continue;
|
|
823
|
+
}
|
|
824
|
+
const values = source.getAll(key);
|
|
825
|
+
if (!values.length) {
|
|
826
|
+
continue;
|
|
827
|
+
}
|
|
828
|
+
result[key] = values.length === 1 ? values[0] : values;
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
append(new URLSearchParams(window.location.search));
|
|
832
|
+
const hash = window.location.hash.startsWith("#") ? window.location.hash.slice(1) : window.location.hash;
|
|
833
|
+
if (hash && hash.includes("=")) {
|
|
834
|
+
append(new URLSearchParams(hash));
|
|
835
|
+
}
|
|
836
|
+
return result;
|
|
837
|
+
}
|
|
808
838
|
applyScrollGuards() {
|
|
809
839
|
if (typeof document === "undefined") {
|
|
810
840
|
return void 0;
|
|
@@ -889,7 +919,10 @@ var MaxMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
889
919
|
return this.initData;
|
|
890
920
|
}
|
|
891
921
|
getLaunchParams() {
|
|
892
|
-
return
|
|
922
|
+
return {
|
|
923
|
+
launchParams: this.initDataUnsafe,
|
|
924
|
+
customLaunchParams: this.readCustomUrlParams()
|
|
925
|
+
};
|
|
893
926
|
}
|
|
894
927
|
onBackButton(callback) {
|
|
895
928
|
const bridge2 = getMaxBridge();
|
|
@@ -1443,10 +1476,28 @@ var TelegramMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
1443
1476
|
}
|
|
1444
1477
|
}
|
|
1445
1478
|
getLaunchParams() {
|
|
1479
|
+
const customFromUrl = this.readCustomUrlParams((key) => key.toLowerCase().startsWith("tgwebapp"));
|
|
1480
|
+
let customFromStartParam = {};
|
|
1446
1481
|
try {
|
|
1447
|
-
|
|
1482
|
+
const launchParams = (0, import_sdk_react.retrieveLaunchParams)();
|
|
1483
|
+
const startParam = launchParams.tgWebAppStartParam;
|
|
1484
|
+
if (typeof startParam === "string" && startParam) {
|
|
1485
|
+
customFromStartParam = this.normalizeDecodedStartParam(startParam);
|
|
1486
|
+
}
|
|
1487
|
+
return {
|
|
1488
|
+
launchParams,
|
|
1489
|
+
customLaunchParams: {
|
|
1490
|
+
...customFromUrl,
|
|
1491
|
+
...customFromStartParam
|
|
1492
|
+
}
|
|
1493
|
+
};
|
|
1448
1494
|
} catch {
|
|
1449
|
-
return
|
|
1495
|
+
return {
|
|
1496
|
+
customLaunchParams: {
|
|
1497
|
+
...customFromUrl,
|
|
1498
|
+
...customFromStartParam
|
|
1499
|
+
}
|
|
1500
|
+
};
|
|
1450
1501
|
}
|
|
1451
1502
|
}
|
|
1452
1503
|
decodeStartParam(param) {
|
|
@@ -1795,6 +1846,42 @@ var TelegramMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
1795
1846
|
}
|
|
1796
1847
|
}
|
|
1797
1848
|
}
|
|
1849
|
+
normalizeDecodedStartParam(startParam) {
|
|
1850
|
+
let decoded;
|
|
1851
|
+
try {
|
|
1852
|
+
decoded = (0, import_sdk.decodeStartParam)(startParam);
|
|
1853
|
+
} catch {
|
|
1854
|
+
decoded = startParam;
|
|
1855
|
+
}
|
|
1856
|
+
if (decoded && typeof decoded === "object" && !Array.isArray(decoded)) {
|
|
1857
|
+
return { ...decoded };
|
|
1858
|
+
}
|
|
1859
|
+
if (typeof decoded === "string" && decoded) {
|
|
1860
|
+
const parsed = this.parseQueryString(decoded);
|
|
1861
|
+
if (Object.keys(parsed).length) {
|
|
1862
|
+
return parsed;
|
|
1863
|
+
}
|
|
1864
|
+
return { startParam: decoded };
|
|
1865
|
+
}
|
|
1866
|
+
return {};
|
|
1867
|
+
}
|
|
1868
|
+
parseQueryString(value) {
|
|
1869
|
+
const normalized = value.startsWith("?") ? value.slice(1) : value;
|
|
1870
|
+
const params = new URLSearchParams(normalized);
|
|
1871
|
+
const result = {};
|
|
1872
|
+
const keys = /* @__PURE__ */ new Set();
|
|
1873
|
+
for (const [key] of params.entries()) {
|
|
1874
|
+
keys.add(key);
|
|
1875
|
+
}
|
|
1876
|
+
for (const key of keys) {
|
|
1877
|
+
const values = params.getAll(key);
|
|
1878
|
+
if (!values.length) {
|
|
1879
|
+
continue;
|
|
1880
|
+
}
|
|
1881
|
+
result[key] = values.length === 1 ? values[0] : values;
|
|
1882
|
+
}
|
|
1883
|
+
return result;
|
|
1884
|
+
}
|
|
1798
1885
|
notifyViewRestore() {
|
|
1799
1886
|
for (const listener of this.viewRestoreListeners) {
|
|
1800
1887
|
try {
|
|
@@ -1958,11 +2045,22 @@ var VKMiniAppAdapter = class extends BaseMiniAppAdapter {
|
|
|
1958
2045
|
}
|
|
1959
2046
|
getLaunchParams() {
|
|
1960
2047
|
if (!this.launchParams) {
|
|
1961
|
-
return
|
|
2048
|
+
return {
|
|
2049
|
+
customLaunchParams: this.readCustomUrlParams((key) => {
|
|
2050
|
+
const normalized = key.toLowerCase();
|
|
2051
|
+
return normalized.startsWith("vk_") || normalized === "sign";
|
|
2052
|
+
})
|
|
2053
|
+
};
|
|
1962
2054
|
}
|
|
1963
2055
|
return {
|
|
1964
|
-
launchParams:
|
|
1965
|
-
|
|
2056
|
+
launchParams: {
|
|
2057
|
+
bridge: this.launchParams,
|
|
2058
|
+
query: this.queryParams
|
|
2059
|
+
},
|
|
2060
|
+
customLaunchParams: this.readCustomUrlParams((key) => {
|
|
2061
|
+
const normalized = key.toLowerCase();
|
|
2062
|
+
return normalized.startsWith("vk_") || normalized === "sign";
|
|
2063
|
+
})
|
|
1966
2064
|
};
|
|
1967
2065
|
}
|
|
1968
2066
|
async openExternalLink(url) {
|