bento-get 2.7.7 → 3.0.0-beta.643.1
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/app/AuthGuard.mjs +35 -45
- package/dist/app/AuthGuard.mjs.map +1 -1
- package/dist/app/AuthGuard.native.js +37 -47
- package/dist/app/AuthGuard.native.js.map +1 -1
- package/dist/app/handle-global-keypress.mjs +93 -98
- package/dist/app/handle-global-keypress.mjs.map +1 -1
- package/dist/app/handle-global-keypress.native.js +105 -110
- package/dist/app/handle-global-keypress.native.js.map +1 -1
- package/dist/cli-components/SearchBar.mjs +39 -37
- package/dist/cli-components/SearchBar.mjs.map +1 -1
- package/dist/cli-components/SearchBar.native.js +42 -41
- package/dist/cli-components/SearchBar.native.js.map +1 -1
- package/dist/cli-components/index.mjs +137 -135
- package/dist/cli-components/index.mjs.map +1 -1
- package/dist/cli-components/index.native.js +155 -153
- package/dist/cli-components/index.native.js.map +1 -1
- package/dist/cli.mjs +4 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/cli.native.js +4 -2
- package/dist/cli.native.js.map +1 -1
- package/dist/commands/add.mjs +9 -6
- package/dist/commands/add.mjs.map +1 -1
- package/dist/commands/add.native.js +10 -7
- package/dist/commands/add.native.js.map +1 -1
- package/dist/commands/index.mjs +133 -135
- package/dist/commands/index.mjs.map +1 -1
- package/dist/commands/index.native.js +145 -147
- package/dist/commands/index.native.js.map +1 -1
- package/dist/components.mjs +1470 -1228
- package/dist/components.mjs.map +1 -1
- package/dist/components.native.js +1470 -1228
- package/dist/components.native.js.map +1 -1
- package/dist/constants.mjs +1 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/constants.native.js +1 -0
- package/dist/constants.native.js.map +1 -1
- package/dist/data/AppContext.mjs +43 -43
- package/dist/data/AppContext.mjs.map +1 -1
- package/dist/data/AppContext.native.js +44 -44
- package/dist/data/AppContext.native.js.map +1 -1
- package/dist/hooks/useFetchComponent.mjs +64 -76
- package/dist/hooks/useFetchComponent.mjs.map +1 -1
- package/dist/hooks/useFetchComponent.native.js +88 -102
- package/dist/hooks/useFetchComponent.native.js.map +1 -1
- package/dist/hooks/useInstallComponent.mjs +130 -138
- package/dist/hooks/useInstallComponent.mjs.map +1 -1
- package/dist/hooks/useInstallComponent.native.js +186 -198
- package/dist/hooks/useInstallComponent.native.js.map +1 -1
- package/dist/install-direct.mjs +110 -120
- package/dist/install-direct.mjs.map +1 -1
- package/dist/install-direct.native.js +179 -195
- package/dist/install-direct.native.js.map +1 -1
- package/dist/screens/CodeAuthScreen.mjs +114 -106
- package/dist/screens/CodeAuthScreen.mjs.map +1 -1
- package/dist/screens/CodeAuthScreen.native.js +116 -108
- package/dist/screens/CodeAuthScreen.native.js.map +1 -1
- package/dist/screens/InstallConfirmScreen.mjs +91 -83
- package/dist/screens/InstallConfirmScreen.mjs.map +1 -1
- package/dist/screens/InstallConfirmScreen.native.js +99 -91
- package/dist/screens/InstallConfirmScreen.native.js.map +1 -1
- package/dist/screens/SearchScreen.mjs +9 -5
- package/dist/screens/SearchScreen.mjs.map +1 -1
- package/dist/screens/SearchScreen.native.js +11 -7
- package/dist/screens/SearchScreen.native.js.map +1 -1
- package/package.json +6 -21
package/dist/app/AuthGuard.mjs
CHANGED
|
@@ -1,52 +1,42 @@
|
|
|
1
1
|
import { Alert } from "@inkjs/ui";
|
|
2
2
|
import { Box } from "ink";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { debugLog, redact } from "../commands/index.
|
|
5
|
-
import { AppContext } from "../data/AppContext.
|
|
6
|
-
import { useInstallComponent } from "../hooks/useInstallComponent.
|
|
4
|
+
import { debugLog, redact } from "../commands/index.mjs";
|
|
5
|
+
import { AppContext } from "../data/AppContext.mjs";
|
|
6
|
+
import { useInstallComponent } from "../hooks/useInstallComponent.mjs";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return /* @__PURE__ */jsxs(Box, {
|
|
40
|
-
flexDirection: "column",
|
|
41
|
-
children: [/* @__PURE__ */jsxs(Alert, {
|
|
42
|
-
variant: "error",
|
|
43
|
-
children: ["Error installing component: ", JSON.stringify(error, null, 2)]
|
|
44
|
-
}), children]
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
return /* @__PURE__ */jsx(Fragment, {
|
|
48
|
-
children
|
|
49
|
-
});
|
|
8
|
+
|
|
9
|
+
const AuthGuard = ({ children }) => {
|
|
10
|
+
const { error } = useInstallComponent();
|
|
11
|
+
const { tokenStore, setAccessToken, setIsLoggedIn } = React.useContext(AppContext);
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
const token = tokenStore.get("accessToken");
|
|
14
|
+
if (token) {
|
|
15
|
+
setAccessToken(token);
|
|
16
|
+
setIsLoggedIn(true);
|
|
17
|
+
debugLog("Token found, setting isLoggedIn to true");
|
|
18
|
+
debugLog({ token: redact(token) });
|
|
19
|
+
} else {
|
|
20
|
+
setIsLoggedIn(false);
|
|
21
|
+
}
|
|
22
|
+
}, []);
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
debugLog({
|
|
25
|
+
errorStatus: error?.status,
|
|
26
|
+
useInstallComponentError: error
|
|
27
|
+
});
|
|
28
|
+
}, [error]);
|
|
29
|
+
if (error && error.status !== 401) {
|
|
30
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
31
|
+
flexDirection: "column",
|
|
32
|
+
children: [/* @__PURE__ */ jsxs(Alert, {
|
|
33
|
+
variant: "error",
|
|
34
|
+
children: ["Error installing component: ", JSON.stringify(error, null, 2)]
|
|
35
|
+
}), children]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
50
39
|
};
|
|
40
|
+
|
|
51
41
|
export { AuthGuard };
|
|
52
42
|
//# sourceMappingURL=AuthGuard.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"file":"AuthGuard.js","names":[],"sources":["app/AuthGuard.js"],"sourcesContent":["import { Alert } from \"@inkjs/ui\";\nimport { Box } from \"ink\";\nimport React from \"react\";\nimport { debugLog, redact } from \"../commands/index.js\";\nimport { AppContext } from \"../data/AppContext.js\";\nimport { useInstallComponent } from \"../hooks/useInstallComponent.js\";\nimport { Fragment, jsx, jsxs } from \"react/jsx-runtime\";\nconst AuthGuard = ({ children }) => {\n const { error } = useInstallComponent();\n const { tokenStore, setAccessToken, setIsLoggedIn } = React.useContext(AppContext);\n React.useEffect(() => {\n const token = tokenStore.get(\"accessToken\");\n if (token) {\n setAccessToken(token);\n setIsLoggedIn(true);\n debugLog(\"Token found, setting isLoggedIn to true\");\n debugLog({ token: redact(token) });\n } else {\n setIsLoggedIn(false);\n }\n }, []);\n React.useEffect(() => {\n debugLog({\n errorStatus: error?.status,\n useInstallComponentError: error\n });\n }, [error]);\n if (error && error.status !== 401) {\n return /* @__PURE__ */ jsxs(Box, { flexDirection: \"column\", children: [\n /* @__PURE__ */ jsxs(Alert, { variant: \"error\", children: [\n \"Error installing component: \",\n JSON.stringify(error, null, 2)\n ] }),\n children\n ] });\n }\n return /* @__PURE__ */ jsx(Fragment, { children });\n};\nexport {\n AuthGuard\n};\n//# sourceMappingURL=AuthGuard.js.map\n"],"mappings":";;;;;;;;;AAOA,MAAM,aAAa,EAAE,eAAe;CAClC,MAAM,EAAE,UAAU,oBAAoB;CACtC,MAAM,EAAE,YAAY,gBAAgB,kBAAkB,MAAM,WAAW,UAAU;CACjF,MAAM,gBAAgB;EACpB,MAAM,QAAQ,WAAW,IAAI,aAAa;EAC1C,IAAI,OAAO;GACT,eAAe,KAAK;GACpB,cAAc,IAAI;GAClB,SAAS,yCAAyC;GAClD,SAAS,EAAE,OAAO,OAAO,KAAK,EAAE,CAAC;EACnC,OAAO;GACL,cAAc,KAAK;EACrB;CACF,GAAG,CAAC,CAAC;CACL,MAAM,gBAAgB;EACpB,SAAS;GACP,aAAa,OAAO;GACpB,0BAA0B;EAC5B,CAAC;CACH,GAAG,CAAC,KAAK,CAAC;CACV,IAAI,SAAS,MAAM,WAAW,KAAK;EACjC,OAAuB,qBAAK,KAAK;GAAE,eAAe;GAAU,UAAU,CACpD,qBAAK,OAAO;IAAE,SAAS;IAAS,UAAU,CACxD,gCACA,KAAK,UAAU,OAAO,MAAM,CAAC,CAC/B;GAAE,CAAC,GACH,QACF;EAAE,CAAC;CACL;CACA,OAAuB,oBAAI,UAAU,EAAE,SAAS,CAAC;AACnD"}
|
|
@@ -1,53 +1,43 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Alert } from "@inkjs/ui";
|
|
3
3
|
import { Box } from "ink";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import { debugLog, redact } from "../commands/index.js";
|
|
6
|
-
import { AppContext } from "../data/AppContext.js";
|
|
7
|
-
import { useInstallComponent } from "../hooks/useInstallComponent.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return /* @__PURE__ */_jsxs(Box, {
|
|
41
|
-
flexDirection: "column",
|
|
42
|
-
children: [/* @__PURE__ */_jsxs(Alert, {
|
|
43
|
-
variant: "error",
|
|
44
|
-
children: ["Error installing component: ", JSON.stringify(error, null, 2)]
|
|
45
|
-
}), children]
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return /* @__PURE__ */_jsx(_Fragment, {
|
|
49
|
-
children
|
|
50
|
-
});
|
|
5
|
+
import { debugLog, redact } from "../commands/index.native.js";
|
|
6
|
+
import { AppContext } from "../data/AppContext.native.js";
|
|
7
|
+
import { useInstallComponent } from "../hooks/useInstallComponent.native.js";
|
|
8
|
+
|
|
9
|
+
var AuthGuard = function(param) {
|
|
10
|
+
var { children } = param;
|
|
11
|
+
var { error } = useInstallComponent();
|
|
12
|
+
var { tokenStore, setAccessToken, setIsLoggedIn } = React.useContext(AppContext);
|
|
13
|
+
React.useEffect(function() {
|
|
14
|
+
var token = tokenStore.get("accessToken");
|
|
15
|
+
if (token) {
|
|
16
|
+
setAccessToken(token);
|
|
17
|
+
setIsLoggedIn(true);
|
|
18
|
+
debugLog("Token found, setting isLoggedIn to true");
|
|
19
|
+
debugLog({ token: redact(token) });
|
|
20
|
+
} else {
|
|
21
|
+
setIsLoggedIn(false);
|
|
22
|
+
}
|
|
23
|
+
}, []);
|
|
24
|
+
React.useEffect(function() {
|
|
25
|
+
debugLog({
|
|
26
|
+
errorStatus: error === null || error === void 0 ? void 0 : error.status,
|
|
27
|
+
useInstallComponentError: error
|
|
28
|
+
});
|
|
29
|
+
}, [error]);
|
|
30
|
+
if (error && error.status !== 401) {
|
|
31
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
32
|
+
flexDirection: "column",
|
|
33
|
+
children: [/* @__PURE__ */ jsxs(Alert, {
|
|
34
|
+
variant: "error",
|
|
35
|
+
children: ["Error installing component: ", JSON.stringify(error, null, 2)]
|
|
36
|
+
}), children]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
51
40
|
};
|
|
41
|
+
|
|
52
42
|
export { AuthGuard };
|
|
53
43
|
//# sourceMappingURL=AuthGuard.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"AuthGuard.native.js","names":["_Fragment"],"sources":["app/AuthGuard.native.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { Alert } from \"@inkjs/ui\";\nimport { Box } from \"ink\";\nimport React from \"react\";\nimport { debugLog, redact } from \"../commands/index.js\";\nimport { AppContext } from \"../data/AppContext.js\";\nimport { useInstallComponent } from \"../hooks/useInstallComponent.js\";\nvar AuthGuard = function(param) {\n var { children } = param;\n var { error } = useInstallComponent();\n var { tokenStore, setAccessToken, setIsLoggedIn } = React.useContext(AppContext);\n React.useEffect(function() {\n var token = tokenStore.get(\"accessToken\");\n if (token) {\n setAccessToken(token);\n setIsLoggedIn(true);\n debugLog(\"Token found, setting isLoggedIn to true\");\n debugLog({\n token: redact(token)\n });\n } else {\n setIsLoggedIn(false);\n }\n }, []);\n React.useEffect(function() {\n debugLog({\n errorStatus: error === null || error === void 0 ? void 0 : error.status,\n useInstallComponentError: error\n });\n }, [\n error\n ]);\n if (error && error.status !== 401) {\n return /* @__PURE__ */ _jsxs(Box, {\n flexDirection: \"column\",\n children: [\n /* @__PURE__ */ _jsxs(Alert, {\n variant: \"error\",\n children: [\n \"Error installing component: \",\n JSON.stringify(error, null, 2)\n ]\n }),\n children\n ]\n });\n }\n return /* @__PURE__ */ _jsx(_Fragment, {\n children\n });\n};\nexport {\n AuthGuard\n};\n//# sourceMappingURL=AuthGuard.js.map\n"],"mappings":";;;;;;;;;AAOA,IAAI,YAAY,SAAS,OAAO;CAC9B,IAAI,EAAE,aAAa;CACnB,IAAI,EAAE,UAAU,oBAAoB;CACpC,IAAI,EAAE,YAAY,gBAAgB,kBAAkB,MAAM,WAAW,UAAU;CAC/E,MAAM,UAAU,WAAW;EACzB,IAAI,QAAQ,WAAW,IAAI,aAAa;EACxC,IAAI,OAAO;GACT,eAAe,KAAK;GACpB,cAAc,IAAI;GAClB,SAAS,yCAAyC;GAClD,SAAS,EACP,OAAO,OAAO,KAAK,EACrB,CAAC;EACH,OAAO;GACL,cAAc,KAAK;EACrB;CACF,GAAG,CAAC,CAAC;CACL,MAAM,UAAU,WAAW;EACzB,SAAS;GACP,aAAa,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;GACjE,0BAA0B;EAC5B,CAAC;CACH,GAAG,CACD,KACF,CAAC;CACD,IAAI,SAAS,MAAM,WAAW,KAAK;EACjC,OAAuB,qBAAM,KAAK;GAChC,eAAe;GACf,UAAU,CACQ,qBAAM,OAAO;IAC3B,SAAS;IACT,UAAU,CACR,gCACA,KAAK,UAAU,OAAO,MAAM,CAAC,CAC/B;GACF,CAAC,GACD,QACF;EACF,CAAC;CACH;CACA,OAAuB,oBAAKA,UAAW,EACrC,SACF,CAAC;AACH"}
|
|
@@ -1,105 +1,100 @@
|
|
|
1
1
|
import open from "open";
|
|
2
|
-
import { debugLog } from "../commands/index.
|
|
2
|
+
import { debugLog } from "../commands/index.mjs";
|
|
3
|
+
|
|
3
4
|
const apiBase = process.env.API_BASE || "https://tamagui.dev";
|
|
4
5
|
const ACCESS_TOKEN_URL = `${apiBase}/account`;
|
|
5
6
|
const handleGlobalKeyPress = (key, modifier, appContext, navigate, location) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
debugLog("Installing component", searchResults[selectedResultIndex]?.item);
|
|
99
|
-
navigate(`/install-confirm/${fileName}`);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
7
|
+
const { selectedResultIndex, setSelectedResultIndex, setInstallState, searchResults, setCopyingToClipboard, setConfirmationPending } = appContext;
|
|
8
|
+
debugLog({
|
|
9
|
+
modifier,
|
|
10
|
+
key
|
|
11
|
+
});
|
|
12
|
+
if (modifier.ctrl && key === "d") {
|
|
13
|
+
appContext.tokenStore.clear();
|
|
14
|
+
appContext.setAccessToken(null);
|
|
15
|
+
appContext.setIsLoggedIn(false);
|
|
16
|
+
console.warn("Cleared Auth Token");
|
|
17
|
+
return navigate("/");
|
|
18
|
+
}
|
|
19
|
+
if (key === "c" && appContext.installState.shouldOpenBrowser) {
|
|
20
|
+
setCopyingToClipboard(true);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (location.pathname.includes("/install-confirm")) {
|
|
24
|
+
if (key === "y") {
|
|
25
|
+
setConfirmationPending(false);
|
|
26
|
+
navigate("/search");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (key === "n") {
|
|
30
|
+
setConfirmationPending(true);
|
|
31
|
+
navigate("/search");
|
|
32
|
+
setSelectedResultIndex(-1);
|
|
33
|
+
setInstallState((prev) => ({
|
|
34
|
+
...prev,
|
|
35
|
+
componentToInstall: null,
|
|
36
|
+
installingComponent: null
|
|
37
|
+
}));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (modifier.escape && location.pathname.includes("/auth")) {
|
|
43
|
+
return navigate("/search");
|
|
44
|
+
}
|
|
45
|
+
if (modifier.escape && appContext.installState.isTokenInstalled) {
|
|
46
|
+
appContext.setInstallState((prev) => ({
|
|
47
|
+
...prev,
|
|
48
|
+
installingComponent: null,
|
|
49
|
+
isTokenInstalled: false
|
|
50
|
+
}));
|
|
51
|
+
return navigate("/search");
|
|
52
|
+
}
|
|
53
|
+
if (modifier.escape && appContext.installState.installingComponent !== null && !appContext.installState.installingComponent?.isOSS) {
|
|
54
|
+
appContext.setInstallState((prev) => ({
|
|
55
|
+
...prev,
|
|
56
|
+
installingComponent: null,
|
|
57
|
+
shouldOpenBrowser: false
|
|
58
|
+
}));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (modifier.escape) {
|
|
62
|
+
if (location.pathname.includes("/install-confirm")) {
|
|
63
|
+
navigate("/search");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
appContext.exitApp();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (appContext.installState.installingComponent && (modifier.upArrow || modifier.downArrow)) return;
|
|
70
|
+
if (modifier.ctrl && modifier.return && !appContext.installState.installingComponent?.isOSS && appContext.installState.shouldOpenBrowser && location.pathname.includes("/auth")) {
|
|
71
|
+
return open(ACCESS_TOKEN_URL);
|
|
72
|
+
}
|
|
73
|
+
if (modifier.upArrow) {
|
|
74
|
+
selectedResultIndex > -1 && setSelectedResultIndex(selectedResultIndex - 1);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (modifier.downArrow) {
|
|
78
|
+
selectedResultIndex < appContext.searchResults.length - 1 && setSelectedResultIndex(selectedResultIndex + 1);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (modifier.return) {
|
|
82
|
+
if (location.pathname.includes("/search")) {
|
|
83
|
+
setInstallState((prev) => ({
|
|
84
|
+
...prev,
|
|
85
|
+
installingComponent: searchResults[selectedResultIndex]?.item
|
|
86
|
+
}));
|
|
87
|
+
const fileName = searchResults?.[selectedResultIndex]?.item.fileName;
|
|
88
|
+
if (!fileName) {
|
|
89
|
+
console.error("No component found");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
debugLog("Installing component", searchResults[selectedResultIndex]?.item);
|
|
93
|
+
navigate(`/install-confirm/${fileName}`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
103
97
|
};
|
|
98
|
+
|
|
104
99
|
export { handleGlobalKeyPress };
|
|
105
100
|
//# sourceMappingURL=handle-global-keypress.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"handle-global-keypress.js","names":[],"sources":["app/handle-global-keypress.js"],"sourcesContent":["import open from \"open\";\nimport { debugLog } from \"../commands/index.js\";\nconst apiBase = process.env.API_BASE || \"https://tamagui.dev\";\nconst ACCESS_TOKEN_URL = `${apiBase}/account`;\nconst handleGlobalKeyPress = (key, modifier, appContext, navigate, location) => {\n const {\n selectedResultIndex,\n setSelectedResultIndex,\n setInstallState,\n searchResults,\n setCopyingToClipboard,\n setConfirmationPending\n } = appContext;\n debugLog({\n modifier,\n key\n });\n if (modifier.ctrl && key === \"d\") {\n appContext.tokenStore.clear();\n appContext.setAccessToken(null);\n appContext.setIsLoggedIn(false);\n console.warn(\"Cleared Auth Token\");\n return navigate(\"/\");\n }\n if (key === \"c\" && appContext.installState.shouldOpenBrowser) {\n setCopyingToClipboard(true);\n return;\n }\n if (location.pathname.includes(\"/install-confirm\")) {\n if (key === \"y\") {\n setConfirmationPending(false);\n navigate(\"/search\");\n return;\n }\n if (key === \"n\") {\n setConfirmationPending(true);\n navigate(\"/search\");\n setSelectedResultIndex(-1);\n setInstallState((prev) => ({\n ...prev,\n componentToInstall: null,\n installingComponent: null\n }));\n return;\n }\n return;\n }\n if (modifier.escape && location.pathname.includes(\"/auth\")) {\n return navigate(\"/search\");\n }\n if (modifier.escape && appContext.installState.isTokenInstalled) {\n appContext.setInstallState((prev) => ({\n ...prev,\n installingComponent: null,\n isTokenInstalled: false\n }));\n return navigate(\"/search\");\n }\n if (modifier.escape && appContext.installState.installingComponent !== null && !appContext.installState.installingComponent?.isOSS) {\n appContext.setInstallState((prev) => ({\n ...prev,\n installingComponent: null,\n shouldOpenBrowser: false\n }));\n return;\n }\n if (modifier.escape) {\n if (location.pathname.includes(\"/install-confirm\")) {\n navigate(\"/search\");\n return;\n }\n appContext.exitApp();\n return;\n }\n if (appContext.installState.installingComponent && (modifier.upArrow || modifier.downArrow))\n return;\n if (modifier.ctrl && modifier.return && !appContext.installState.installingComponent?.isOSS && appContext.installState.shouldOpenBrowser && location.pathname.includes(\"/auth\")) {\n return open(ACCESS_TOKEN_URL);\n }\n if (modifier.upArrow) {\n selectedResultIndex > -1 && setSelectedResultIndex(selectedResultIndex - 1);\n return;\n }\n if (modifier.downArrow) {\n selectedResultIndex < appContext.searchResults.length - 1 && setSelectedResultIndex(selectedResultIndex + 1);\n return;\n }\n if (modifier.return) {\n if (location.pathname.includes(\"/search\")) {\n setInstallState((prev) => ({\n ...prev,\n installingComponent: searchResults[selectedResultIndex]?.item\n }));\n const fileName = searchResults?.[selectedResultIndex]?.item.fileName;\n if (!fileName) {\n console.error(\"No component found\");\n return;\n }\n debugLog(\"Installing component\", searchResults[selectedResultIndex]?.item);\n navigate(`/install-confirm/${fileName}`);\n return;\n }\n }\n};\nexport {\n handleGlobalKeyPress\n};\n//# sourceMappingURL=handle-global-keypress.js.map\n"],"mappings":";;;;AAEA,MAAM,UAAU,QAAQ,IAAI,YAAY;AACxC,MAAM,mBAAmB,GAAG,QAAQ;AACpC,MAAM,wBAAwB,KAAK,UAAU,YAAY,UAAU,aAAa;CAC9E,MAAM,EACJ,qBACA,wBACA,iBACA,eACA,uBACA,2BACE;CACJ,SAAS;EACP;EACA;CACF,CAAC;CACD,IAAI,SAAS,QAAQ,QAAQ,KAAK;EAChC,WAAW,WAAW,MAAM;EAC5B,WAAW,eAAe,IAAI;EAC9B,WAAW,cAAc,KAAK;EAC9B,QAAQ,KAAK,oBAAoB;EACjC,OAAO,SAAS,GAAG;CACrB;CACA,IAAI,QAAQ,OAAO,WAAW,aAAa,mBAAmB;EAC5D,sBAAsB,IAAI;EAC1B;CACF;CACA,IAAI,SAAS,SAAS,SAAS,kBAAkB,GAAG;EAClD,IAAI,QAAQ,KAAK;GACf,uBAAuB,KAAK;GAC5B,SAAS,SAAS;GAClB;EACF;EACA,IAAI,QAAQ,KAAK;GACf,uBAAuB,IAAI;GAC3B,SAAS,SAAS;GAClB,uBAAuB,CAAC,CAAC;GACzB,iBAAiB,UAAU;IACzB,GAAG;IACH,oBAAoB;IACpB,qBAAqB;GACvB,EAAE;GACF;EACF;EACA;CACF;CACA,IAAI,SAAS,UAAU,SAAS,SAAS,SAAS,OAAO,GAAG;EAC1D,OAAO,SAAS,SAAS;CAC3B;CACA,IAAI,SAAS,UAAU,WAAW,aAAa,kBAAkB;EAC/D,WAAW,iBAAiB,UAAU;GACpC,GAAG;GACH,qBAAqB;GACrB,kBAAkB;EACpB,EAAE;EACF,OAAO,SAAS,SAAS;CAC3B;CACA,IAAI,SAAS,UAAU,WAAW,aAAa,wBAAwB,QAAQ,CAAC,WAAW,aAAa,qBAAqB,OAAO;EAClI,WAAW,iBAAiB,UAAU;GACpC,GAAG;GACH,qBAAqB;GACrB,mBAAmB;EACrB,EAAE;EACF;CACF;CACA,IAAI,SAAS,QAAQ;EACnB,IAAI,SAAS,SAAS,SAAS,kBAAkB,GAAG;GAClD,SAAS,SAAS;GAClB;EACF;EACA,WAAW,QAAQ;EACnB;CACF;CACA,IAAI,WAAW,aAAa,wBAAwB,SAAS,WAAW,SAAS,YAC/E;CACF,IAAI,SAAS,QAAQ,SAAS,UAAU,CAAC,WAAW,aAAa,qBAAqB,SAAS,WAAW,aAAa,qBAAqB,SAAS,SAAS,SAAS,OAAO,GAAG;EAC/K,OAAO,KAAK,gBAAgB;CAC9B;CACA,IAAI,SAAS,SAAS;EACpB,sBAAsB,CAAC,KAAK,uBAAuB,sBAAsB,CAAC;EAC1E;CACF;CACA,IAAI,SAAS,WAAW;EACtB,sBAAsB,WAAW,cAAc,SAAS,KAAK,uBAAuB,sBAAsB,CAAC;EAC3G;CACF;CACA,IAAI,SAAS,QAAQ;EACnB,IAAI,SAAS,SAAS,SAAS,SAAS,GAAG;GACzC,iBAAiB,UAAU;IACzB,GAAG;IACH,qBAAqB,cAAc,sBAAsB;GAC3D,EAAE;GACF,MAAM,WAAW,gBAAgB,sBAAsB,KAAK;GAC5D,IAAI,CAAC,UAAU;IACb,QAAQ,MAAM,oBAAoB;IAClC;GACF;GACA,SAAS,wBAAwB,cAAc,sBAAsB,IAAI;GACzE,SAAS,oBAAoB,UAAU;GACvC;EACF;CACF;AACF"}
|