onairos 0.1.355 → 0.1.357
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.
|
@@ -5,33 +5,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = TestTelegramButton;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
8
|
+
var _sdkReact = require("@telegram-apps/sdk-react");
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
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
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; }
|
|
12
12
|
function TestTelegramButton() {
|
|
13
13
|
const [error, setError] = (0, _react.useState)(null);
|
|
14
|
-
const [
|
|
15
|
-
|
|
14
|
+
const [logs, setLogs] = (0, _react.useState)([]);
|
|
15
|
+
(0, _react.useEffect)(() => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
(0, _sdkReact.init)();
|
|
18
|
+
addLog('Telegram SDK initialized successfully');
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error('Failed to initialize Telegram SDK:', error);
|
|
21
|
+
addLog('Failed to initialize Telegram SDK: ' + error.message);
|
|
22
|
+
setError('Failed to initialize Telegram SDK: ' + error.message);
|
|
23
|
+
}
|
|
24
|
+
}, []);
|
|
25
|
+
const addLog = message => {
|
|
26
|
+
setLogs(prevLogs => [...prevLogs, message]);
|
|
27
|
+
};
|
|
28
|
+
const handleClick = () => {
|
|
29
|
+
try {
|
|
30
|
+
addLog('Opening external browser...');
|
|
25
31
|
const testUrl = 'https://onairos.uk/test-page';
|
|
26
32
|
|
|
27
|
-
// Use
|
|
28
|
-
|
|
29
|
-
try_instant_view: false,
|
|
30
|
-
open_in_browser: true
|
|
31
|
-
});
|
|
33
|
+
// Use standard JavaScript to open the link in a new tab
|
|
34
|
+
window.open(testUrl, '_blank');
|
|
32
35
|
} catch (error) {
|
|
33
|
-
console.error('
|
|
34
|
-
|
|
36
|
+
console.error('Failed to open link:', error);
|
|
37
|
+
addLog(`Failed to open link: ${error.message}`);
|
|
38
|
+
setError(`Failed to open link: ${error.message}`);
|
|
35
39
|
}
|
|
36
40
|
};
|
|
37
41
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
@@ -39,13 +43,22 @@ function TestTelegramButton() {
|
|
|
39
43
|
children: [error && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
40
44
|
className: "bg-red-100 border border-red-400 text-red-700 px-4 py-2 rounded mb-4",
|
|
41
45
|
children: error
|
|
42
|
-
}), debug && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
43
|
-
className: "bg-blue-100 border border-blue-400 text-blue-700 px-4 py-2 rounded mb-4",
|
|
44
|
-
children: debug
|
|
45
46
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
46
47
|
onClick: handleClick,
|
|
47
48
|
className: "bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600",
|
|
48
|
-
children: "Test
|
|
49
|
+
children: "Test External Browser"
|
|
50
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
51
|
+
className: "mt-4 w-full max-w-md",
|
|
52
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
|
|
53
|
+
className: "text-lg font-semibold mb-2",
|
|
54
|
+
children: "Logs:"
|
|
55
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
56
|
+
className: "bg-gray-100 border border-gray-300 text-gray-800 px-4 py-2 rounded overflow-y-auto max-h-40",
|
|
57
|
+
children: logs.map((log, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
58
|
+
className: "text-sm",
|
|
59
|
+
children: log
|
|
60
|
+
}, index))
|
|
61
|
+
})]
|
|
49
62
|
})]
|
|
50
63
|
});
|
|
51
64
|
}
|