onairos 0.1.342 → 0.1.345
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/components/GoogleButton.js +27 -23
- package/dist/onairos.bundle.js +1 -1
- package/dist/onairos.bundle.js.map +1 -1
- package/dist/onairos.js +14 -11
- package/dist/onairosButton.js +4 -6
- package/package.json +1 -1
- package/src/components/GoogleButton.js +27 -24
- package/src/onairos.jsx +11 -14
- package/src/onairosButton.jsx +4 -7
|
@@ -4,21 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = GoogleButton;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
8
|
var _sdk = require("@telegram-apps/sdk");
|
|
8
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
9
12
|
function GoogleButton(_ref) {
|
|
10
13
|
let {
|
|
11
14
|
onLoginSuccess
|
|
12
15
|
} = _ref;
|
|
13
|
-
const handleTelegramAuth = async () => {
|
|
14
|
-
if (!_sdk.miniApp.
|
|
15
|
-
console.error('Telegram Mini App not
|
|
16
|
+
const handleTelegramAuth = (0, _react.useCallback)(async () => {
|
|
17
|
+
if (!_sdk.miniApp.isInitialized) {
|
|
18
|
+
console.error('Telegram Mini App not initialized');
|
|
16
19
|
return;
|
|
17
20
|
}
|
|
18
21
|
try {
|
|
19
|
-
// Mount the Mini App
|
|
20
|
-
_sdk.miniApp.mount();
|
|
21
|
-
|
|
22
22
|
// Get Telegram Mini App data
|
|
23
23
|
const telegramAppUrl = _sdk.miniApp.initData;
|
|
24
24
|
const botUsername = 'OnairosMiniApp';
|
|
@@ -28,27 +28,31 @@ function GoogleButton(_ref) {
|
|
|
28
28
|
connectUrl.searchParams.append('tgAppUrl', encodeURIComponent(JSON.stringify(telegramAppUrl)));
|
|
29
29
|
connectUrl.searchParams.append('botUsername', botUsername);
|
|
30
30
|
|
|
31
|
-
// Open in browser
|
|
32
|
-
_sdk.
|
|
31
|
+
// Open in external browser
|
|
32
|
+
await (0, _sdk.openLink)(connectUrl.toString(), {
|
|
33
|
+
tryInstantView: false
|
|
34
|
+
});
|
|
33
35
|
|
|
34
|
-
// Listen for
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
// Listen for app becoming active again
|
|
37
|
+
const handleAppActive = () => {
|
|
38
|
+
const startParam = _sdk.miniApp.initDataUnsafe?.start_param;
|
|
39
|
+
if (startParam) {
|
|
40
|
+
try {
|
|
41
|
+
const authData = JSON.parse(decodeURIComponent(startParam));
|
|
42
|
+
if (authData) {
|
|
43
|
+
onLoginSuccess(authData);
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Error processing auth data:', error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
_sdk.miniApp.removeEvent('active', handleAppActive);
|
|
50
|
+
};
|
|
51
|
+
_sdk.miniApp.onEvent('active', handleAppActive);
|
|
48
52
|
} catch (error) {
|
|
49
53
|
console.error('Telegram auth flow failed:', error);
|
|
50
54
|
}
|
|
51
|
-
};
|
|
55
|
+
}, [onLoginSuccess]);
|
|
52
56
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
53
57
|
className: "flex flex-col items-center",
|
|
54
58
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
|