bento-get 1.109.6 → 1.109.8
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/package.json +2 -2
- package/dist/hooks/useGetComponent.js +0 -53
- package/dist/hooks/useGetComponent.js.map +0 -6
- package/dist/hooks/useGetComponent.mjs +0 -72
- package/dist/hooks/useGetComponent.mjs.map +0 -1
- package/dist/hooks/useGetComponent.native.js +0 -259
- package/dist/hooks/useGetComponent.native.js.map +0 -6
- package/types/components/index.d.ts +0 -21
- package/types/hooks/useFetchComponentFromGithub.d.ts +0 -6
- package/types/hooks/useGetComponent.d.ts +0 -6
- package/types/hooks/useGetComponent.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bento-get",
|
|
3
|
-
"version": "1.109.
|
|
3
|
+
"version": "1.109.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": "dist/cli.js",
|
|
6
6
|
"type": "module",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"zod": "^3.22.4"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@tamagui/build": "1.109.
|
|
60
|
+
"@tamagui/build": "1.109.8",
|
|
61
61
|
"@types/copy-paste": "^1.1.33",
|
|
62
62
|
"@types/react": "npm:@types/react@18.2.55"
|
|
63
63
|
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import fetch from "node-fetch";
|
|
3
|
-
import querystring from "node:querystring";
|
|
4
|
-
import { Octokit } from "octokit";
|
|
5
|
-
import useSWR from "swr";
|
|
6
|
-
import { AppContext } from "../commands/index.js";
|
|
7
|
-
import { installComponent } from "./useInstallComponent.js";
|
|
8
|
-
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
9
|
-
const useGetComponent = () => {
|
|
10
|
-
const forceUpdate = useForceUpdate(), { install, tokenStore, setInstall } = React.useContext(AppContext), { access_token } = tokenStore.get?.("token") ?? {}, [githubData, setGithubData] = React.useState(null);
|
|
11
|
-
React.useEffect(() => {
|
|
12
|
-
if (!access_token)
|
|
13
|
-
return;
|
|
14
|
-
const octokit = new Octokit({
|
|
15
|
-
auth: access_token
|
|
16
|
-
});
|
|
17
|
-
(async () => {
|
|
18
|
-
const { data: data2 } = await octokit.rest.users.getAuthenticated();
|
|
19
|
-
setGithubData(data2);
|
|
20
|
-
})();
|
|
21
|
-
}, [access_token, install.installingComponent]);
|
|
22
|
-
const fetcher = async (url) => {
|
|
23
|
-
const res = await fetch(url, {
|
|
24
|
-
headers: {
|
|
25
|
-
"Content-Type": "application/json",
|
|
26
|
-
Authorization: `Bearer ${access_token || ""}`
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
if (!res.ok) {
|
|
30
|
-
const error2 = new Error("An error occurred while fetching the data.");
|
|
31
|
-
throw error2.info = await res.json(), error2.status = res.status, error2;
|
|
32
|
-
}
|
|
33
|
-
return await res.text();
|
|
34
|
-
}, query = install.installingComponent?.category && install.installingComponent?.categorySection && querystring.stringify({
|
|
35
|
-
section: install.installingComponent?.category,
|
|
36
|
-
part: install.installingComponent?.categorySection,
|
|
37
|
-
fileName: install.installingComponent?.fileName,
|
|
38
|
-
userGithubId: githubData?.node_id || ""
|
|
39
|
-
}), codePath = query ? `https://tamagui.dev/api/bento/code?${query}` : "", { data, error, isLoading } = useSWR(
|
|
40
|
-
install.installingComponent ? codePath : null,
|
|
41
|
-
fetcher,
|
|
42
|
-
{
|
|
43
|
-
loadingTimeout: 3e3
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
return React.useEffect(() => {
|
|
47
|
-
data && installComponent({ component: data, setInstall, install });
|
|
48
|
-
}, [data]), { data, error, isLoading };
|
|
49
|
-
};
|
|
50
|
-
export {
|
|
51
|
-
useGetComponent
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=useGetComponent.js.map
|
|
@@ -1,6 +0,0 @@
|
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AAqB;AAAA,IACtC,MAAM,QAAQ,qBAAqB;AAAA,IACnC,UAAU,QAAQ,qBAAqB;AAAA,IACvC,cAAc,YAAY,WAAW;AAAA,EACvC,CAAC,GAEG,WAAW,QAAQ,sCAAsC,KAAK,KAAK,IAEnE,EAAE,MAAM,OAAO,UAAU,IAAI;AAAA,IACjC,QAAQ,sBAAsB,WAAW;AAAA,IACzC;AAAA,IACA;AAAA,MACE,gBAAgB;AAAA,IAClB;AAAA,EACF;AASA,eAAM,UAAU,MAAM;AACpB,IAAI,QACF,iBAAiB,EAAE,WAAW,MAAM,YAAY,QAAQ,CAAC;AAAA,EAE7D,GAAG,CAAC,IAAI,CAAC,GAEF,EAAE,MAAM,OAAO,UAAU;AAClC;",
|
|
5
|
-
"names": ["data", "error"]
|
|
6
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import fetch from "node-fetch";
|
|
3
|
-
import querystring from "node:querystring";
|
|
4
|
-
import { Octokit } from "octokit";
|
|
5
|
-
import useSWR from "swr";
|
|
6
|
-
import { AppContext } from "../commands/index.js";
|
|
7
|
-
import { installComponent } from "./useInstallComponent.js";
|
|
8
|
-
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
9
|
-
const useGetComponent = () => {
|
|
10
|
-
const forceUpdate = useForceUpdate(),
|
|
11
|
-
{
|
|
12
|
-
install,
|
|
13
|
-
tokenStore,
|
|
14
|
-
setInstall
|
|
15
|
-
} = React.useContext(AppContext),
|
|
16
|
-
{
|
|
17
|
-
access_token
|
|
18
|
-
} = tokenStore.get?.("token") ?? {},
|
|
19
|
-
[githubData, setGithubData] = React.useState(null);
|
|
20
|
-
React.useEffect(() => {
|
|
21
|
-
if (!access_token) return;
|
|
22
|
-
const octokit = new Octokit({
|
|
23
|
-
auth: access_token
|
|
24
|
-
});
|
|
25
|
-
(async () => {
|
|
26
|
-
const {
|
|
27
|
-
data: data2
|
|
28
|
-
} = await octokit.rest.users.getAuthenticated();
|
|
29
|
-
setGithubData(data2);
|
|
30
|
-
})();
|
|
31
|
-
}, [access_token, install.installingComponent]);
|
|
32
|
-
const fetcher = async url => {
|
|
33
|
-
const res = await fetch(url, {
|
|
34
|
-
headers: {
|
|
35
|
-
"Content-Type": "application/json",
|
|
36
|
-
Authorization: `Bearer ${access_token || ""}`
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
if (!res.ok) {
|
|
40
|
-
const error2 = new Error("An error occurred while fetching the data.");
|
|
41
|
-
throw error2.info = await res.json(), error2.status = res.status, error2;
|
|
42
|
-
}
|
|
43
|
-
return await res.text();
|
|
44
|
-
},
|
|
45
|
-
query = install.installingComponent?.category && install.installingComponent?.categorySection && querystring.stringify({
|
|
46
|
-
section: install.installingComponent?.category,
|
|
47
|
-
part: install.installingComponent?.categorySection,
|
|
48
|
-
fileName: install.installingComponent?.fileName,
|
|
49
|
-
userGithubId: githubData?.node_id || ""
|
|
50
|
-
}),
|
|
51
|
-
codePath = query ? `https://tamagui.dev/api/bento/code?${query}` : "",
|
|
52
|
-
{
|
|
53
|
-
data,
|
|
54
|
-
error,
|
|
55
|
-
isLoading
|
|
56
|
-
} = useSWR(install.installingComponent ? codePath : null, fetcher, {
|
|
57
|
-
loadingTimeout: 3e3
|
|
58
|
-
});
|
|
59
|
-
return React.useEffect(() => {
|
|
60
|
-
data && installComponent({
|
|
61
|
-
component: data,
|
|
62
|
-
setInstall,
|
|
63
|
-
install
|
|
64
|
-
});
|
|
65
|
-
}, [data]), {
|
|
66
|
-
data,
|
|
67
|
-
error,
|
|
68
|
-
isLoading
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
export { useGetComponent };
|
|
72
|
-
//# sourceMappingURL=useGetComponent.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","fetch","querystring","Octokit","useSWR","AppContext","installComponent","useForceUpdate","useGetComponent","forceUpdate","install","tokenStore","setInstall","useContext","access_token","get","githubData","setGithubData","useState","useEffect","octokit","auth","data","data2","rest","users","getAuthenticated","installingComponent","fetcher","url","res","headers","Authorization","ok","error2","Error","info","json","status","text","query","category","categorySection","stringify","section","part","fileName","userGithubId","node_id","codePath","error","isLoading","loadingTimeout","component"],"sources":["../../src/hooks/useGetComponent.tsx"],"sourcesContent":[null],"mappings":"AACA,OAAOA,KAAA,MAAW;AAClB,OAAOC,KAAA,MAAW;AAClB,OAAOC,WAAA,MAAiB;AACxB,SAASC,OAAA,QAAe;AAExB,OAAOC,MAAA,MAAY;AACnB,SAASC,UAAA,QAAkB;AAC3B,SAASC,gBAAA,QAAwB;AACjC,SAASC,cAAA,QAAsB;AAExB,MAAMC,eAAA,GAAkBA,CAAA,KAAM;EACnC,MAAMC,WAAA,GAAcF,cAAA,CAAe;IAC7B;MAAEG,OAAA;MAASC,UAAA;MAAYC;IAAW,IAAIZ,KAAA,CAAMa,UAAA,CAAWR,UAAU;IACjE;MAAES;IAAa,IAAIH,UAAA,CAAWI,GAAA,GAAM,OAAO,KAAK,CAAC;IACjD,CAACC,UAAA,EAAYC,aAAa,IAAIjB,KAAA,CAAMkB,QAAA,CAAS,IAAI;EAEvDlB,KAAA,CAAMmB,SAAA,CAAU,MAAM;IACpB,IAAI,CAACL,YAAA,EACH;IAEF,MAAMM,OAAA,GAAU,IAAIjB,OAAA,CAAQ;MAC1BkB,IAAA,EAAMP;IACR,CAAC;IAKD,CAJwB,YAAY;MAClC,MAAM;QAAEQ,IAAA,EAAAC;MAAK,IAAI,MAAMH,OAAA,CAAQI,IAAA,CAAKC,KAAA,CAAMC,gBAAA,CAAiB;MAC3DT,aAAA,CAAcM,KAAI;IACpB,GACgB;EAClB,GAAG,CAACT,YAAA,EAAcJ,OAAA,CAAQiB,mBAAmB,CAAC;EAE9C,MAAMC,OAAA,GAAU,MAAOC,GAAA,IAAQ;MAC7B,MAAMC,GAAA,GAAM,MAAM7B,KAAA,CAAM4B,GAAA,EAAK;QAC3BE,OAAA,EAAS;UACP,gBAAgB;UAChBC,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
|
-
import fetch from "node-fetch";
|
|
3
|
-
import querystring from "node:querystring";
|
|
4
|
-
import { Octokit } from "octokit";
|
|
5
|
-
import useSWR from "swr";
|
|
6
|
-
import { AppContext } from "../commands/index.js";
|
|
7
|
-
import { installComponent } from "./useInstallComponent.js";
|
|
8
|
-
import { useForceUpdate } from "@tamagui/use-force-update";
|
|
9
|
-
function _array_like_to_array(arr, len) {
|
|
10
|
-
(len == null || len > arr.length) && (len = arr.length);
|
|
11
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
12
|
-
return arr2;
|
|
13
|
-
}
|
|
14
|
-
function _array_with_holes(arr) {
|
|
15
|
-
if (Array.isArray(arr)) return arr;
|
|
16
|
-
}
|
|
17
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
18
|
-
try {
|
|
19
|
-
var info = gen[key](arg), value = info.value;
|
|
20
|
-
} catch (error) {
|
|
21
|
-
reject(error);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw);
|
|
25
|
-
}
|
|
26
|
-
function _async_to_generator(fn) {
|
|
27
|
-
return function() {
|
|
28
|
-
var self = this, args = arguments;
|
|
29
|
-
return new Promise(function(resolve, reject) {
|
|
30
|
-
var gen = fn.apply(self, args);
|
|
31
|
-
function _next(value) {
|
|
32
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
33
|
-
}
|
|
34
|
-
function _throw(err) {
|
|
35
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
36
|
-
}
|
|
37
|
-
_next(void 0);
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function _iterable_to_array_limit(arr, i) {
|
|
42
|
-
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
43
|
-
if (_i != null) {
|
|
44
|
-
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
45
|
-
try {
|
|
46
|
-
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
47
|
-
;
|
|
48
|
-
} catch (err) {
|
|
49
|
-
_d = !0, _e = err;
|
|
50
|
-
} finally {
|
|
51
|
-
try {
|
|
52
|
-
!_n && _i.return != null && _i.return();
|
|
53
|
-
} finally {
|
|
54
|
-
if (_d) throw _e;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return _arr;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function _non_iterable_rest() {
|
|
61
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
62
|
-
}
|
|
63
|
-
function _sliced_to_array(arr, i) {
|
|
64
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
65
|
-
}
|
|
66
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
67
|
-
if (o) {
|
|
68
|
-
if (typeof o == "string") return _array_like_to_array(o, minLen);
|
|
69
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
70
|
-
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set") return Array.from(n);
|
|
71
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function _ts_generator(thisArg, body) {
|
|
75
|
-
var f, y, t, g, _ = {
|
|
76
|
-
label: 0,
|
|
77
|
-
sent: function() {
|
|
78
|
-
if (t[0] & 1) throw t[1];
|
|
79
|
-
return t[1];
|
|
80
|
-
},
|
|
81
|
-
trys: [],
|
|
82
|
-
ops: []
|
|
83
|
-
};
|
|
84
|
-
return g = {
|
|
85
|
-
next: verb(0),
|
|
86
|
-
throw: verb(1),
|
|
87
|
-
return: verb(2)
|
|
88
|
-
}, typeof Symbol == "function" && (g[Symbol.iterator] = function() {
|
|
89
|
-
return this;
|
|
90
|
-
}), g;
|
|
91
|
-
function verb(n) {
|
|
92
|
-
return function(v) {
|
|
93
|
-
return step([
|
|
94
|
-
n,
|
|
95
|
-
v
|
|
96
|
-
]);
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function step(op) {
|
|
100
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
101
|
-
for (; _; ) try {
|
|
102
|
-
if (f = 1, y && (t = op[0] & 2 ? y.return : op[0] ? y.throw || ((t = y.return) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
103
|
-
switch (y = 0, t && (op = [
|
|
104
|
-
op[0] & 2,
|
|
105
|
-
t.value
|
|
106
|
-
]), op[0]) {
|
|
107
|
-
case 0:
|
|
108
|
-
case 1:
|
|
109
|
-
t = op;
|
|
110
|
-
break;
|
|
111
|
-
case 4:
|
|
112
|
-
return _.label++, {
|
|
113
|
-
value: op[1],
|
|
114
|
-
done: !1
|
|
115
|
-
};
|
|
116
|
-
case 5:
|
|
117
|
-
_.label++, y = op[1], op = [
|
|
118
|
-
0
|
|
119
|
-
];
|
|
120
|
-
continue;
|
|
121
|
-
case 7:
|
|
122
|
-
op = _.ops.pop(), _.trys.pop();
|
|
123
|
-
continue;
|
|
124
|
-
default:
|
|
125
|
-
if (t = _.trys, !(t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
126
|
-
_ = 0;
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
130
|
-
_.label = op[1];
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
134
|
-
_.label = t[1], t = op;
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
if (t && _.label < t[2]) {
|
|
138
|
-
_.label = t[2], _.ops.push(op);
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
t[2] && _.ops.pop(), _.trys.pop();
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
op = body.call(thisArg, _);
|
|
145
|
-
} catch (e) {
|
|
146
|
-
op = [
|
|
147
|
-
6,
|
|
148
|
-
e
|
|
149
|
-
], y = 0;
|
|
150
|
-
} finally {
|
|
151
|
-
f = t = 0;
|
|
152
|
-
}
|
|
153
|
-
if (op[0] & 5) throw op[1];
|
|
154
|
-
return {
|
|
155
|
-
value: op[0] ? op[1] : void 0,
|
|
156
|
-
done: !0
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
var useGetComponent = function() {
|
|
161
|
-
var _tokenStore_get, _install_installingComponent, _install_installingComponent1, _install_installingComponent2, _install_installingComponent3, _install_installingComponent4, forceUpdate = useForceUpdate(), _React_useContext = React.useContext(AppContext), install = _React_useContext.install, tokenStore = _React_useContext.tokenStore, setInstall = _React_useContext.setInstall, _tokenStore_get1, access_token = ((_tokenStore_get1 = (_tokenStore_get = tokenStore.get) === null || _tokenStore_get === void 0 ? void 0 : _tokenStore_get.call(tokenStore, "token")) !== null && _tokenStore_get1 !== void 0 ? _tokenStore_get1 : {}).access_token, _React_useState = _sliced_to_array(React.useState(null), 2), githubData = _React_useState[0], setGithubData = _React_useState[1];
|
|
162
|
-
React.useEffect(function() {
|
|
163
|
-
if (access_token) {
|
|
164
|
-
var octokit = new Octokit({
|
|
165
|
-
auth: access_token
|
|
166
|
-
}), fetchGithubData = function() {
|
|
167
|
-
var _ref = _async_to_generator(function() {
|
|
168
|
-
var data2;
|
|
169
|
-
return _ts_generator(this, function(_state) {
|
|
170
|
-
switch (_state.label) {
|
|
171
|
-
case 0:
|
|
172
|
-
return [
|
|
173
|
-
4,
|
|
174
|
-
octokit.rest.users.getAuthenticated()
|
|
175
|
-
];
|
|
176
|
-
case 1:
|
|
177
|
-
return data2 = _state.sent().data, setGithubData(data2), [
|
|
178
|
-
2
|
|
179
|
-
];
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
return function() {
|
|
184
|
-
return _ref.apply(this, arguments);
|
|
185
|
-
};
|
|
186
|
-
}();
|
|
187
|
-
fetchGithubData();
|
|
188
|
-
}
|
|
189
|
-
}, [
|
|
190
|
-
access_token,
|
|
191
|
-
install.installingComponent
|
|
192
|
-
]);
|
|
193
|
-
var fetcher = function() {
|
|
194
|
-
var _ref = _async_to_generator(function(url) {
|
|
195
|
-
var res, error2, result;
|
|
196
|
-
return _ts_generator(this, function(_state) {
|
|
197
|
-
switch (_state.label) {
|
|
198
|
-
case 0:
|
|
199
|
-
return [
|
|
200
|
-
4,
|
|
201
|
-
fetch(url, {
|
|
202
|
-
headers: {
|
|
203
|
-
"Content-Type": "application/json",
|
|
204
|
-
Authorization: "Bearer ".concat(access_token || "")
|
|
205
|
-
}
|
|
206
|
-
})
|
|
207
|
-
];
|
|
208
|
-
case 1:
|
|
209
|
-
return res = _state.sent(), res.ok ? [
|
|
210
|
-
3,
|
|
211
|
-
3
|
|
212
|
-
] : (error2 = new Error("An error occurred while fetching the data."), [
|
|
213
|
-
4,
|
|
214
|
-
res.json()
|
|
215
|
-
]);
|
|
216
|
-
case 2:
|
|
217
|
-
throw error2.info = _state.sent(), error2.status = res.status, error2;
|
|
218
|
-
case 3:
|
|
219
|
-
return [
|
|
220
|
-
4,
|
|
221
|
-
res.text()
|
|
222
|
-
];
|
|
223
|
-
case 4:
|
|
224
|
-
return result = _state.sent(), [
|
|
225
|
-
2,
|
|
226
|
-
result
|
|
227
|
-
];
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
return function(url) {
|
|
232
|
-
return _ref.apply(this, arguments);
|
|
233
|
-
};
|
|
234
|
-
}(), query = ((_install_installingComponent = install.installingComponent) === null || _install_installingComponent === void 0 ? void 0 : _install_installingComponent.category) && ((_install_installingComponent1 = install.installingComponent) === null || _install_installingComponent1 === void 0 ? void 0 : _install_installingComponent1.categorySection) && querystring.stringify({
|
|
235
|
-
section: (_install_installingComponent2 = install.installingComponent) === null || _install_installingComponent2 === void 0 ? void 0 : _install_installingComponent2.category,
|
|
236
|
-
part: (_install_installingComponent3 = install.installingComponent) === null || _install_installingComponent3 === void 0 ? void 0 : _install_installingComponent3.categorySection,
|
|
237
|
-
fileName: (_install_installingComponent4 = install.installingComponent) === null || _install_installingComponent4 === void 0 ? void 0 : _install_installingComponent4.fileName,
|
|
238
|
-
userGithubId: (githubData == null ? void 0 : githubData.node_id) || ""
|
|
239
|
-
}), codePath = query ? "https://tamagui.dev/api/bento/code?".concat(query) : "", _useSWR = useSWR(install.installingComponent ? codePath : null, fetcher, {
|
|
240
|
-
loadingTimeout: 3e3
|
|
241
|
-
}), data = _useSWR.data, error = _useSWR.error, isLoading = _useSWR.isLoading;
|
|
242
|
-
return React.useEffect(function() {
|
|
243
|
-
data && installComponent({
|
|
244
|
-
component: data,
|
|
245
|
-
setInstall,
|
|
246
|
-
install
|
|
247
|
-
});
|
|
248
|
-
}, [
|
|
249
|
-
data
|
|
250
|
-
]), {
|
|
251
|
-
data,
|
|
252
|
-
error,
|
|
253
|
-
isLoading
|
|
254
|
-
};
|
|
255
|
-
};
|
|
256
|
-
export {
|
|
257
|
-
useGetComponent
|
|
258
|
-
};
|
|
259
|
-
//# sourceMappingURL=useGetComponent.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/hooks/Users/n8/tamagui/code/packages/bento-get/src/hooks/useGetComponent.tsx"],
|
|
4
|
-
"mappings": "AACA,OAAOA,WAAW;AAClB,OAAOC,WAAW;AAClB,OAAOC,iBAAiB;AACxB,SAASC,eAAe;AAExB,OAAOC,YAAY;AACnB,SAASC,kBAAkB;AAC3B,SAASC,wBAAwB;AACjC,SAASC,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C;",
|
|
5
|
-
"names": ["React", "fetch", "querystring", "Octokit", "useSWR", "AppContext", "installComponent", "useForceUpdate", "useGetComponent", "tokenStore", "install", "forceUpdate", "useContext", "setInstall", "access_token", "get", "useState", "githubData", "setGithubData", "useEffect", "octokit", "auth", "fetchGithubData", "data", "rest", "users", "getAuthenticated", "installingComponent", "fetcher", "url", "res", "error", "result", "headers", "Authorization", "ok", "Error", "json", "info", "status", "text", "query", "category", "categorySection", "stringify", "section", "part", "fileName", "userGithubId", "node_id", "codePath", "loadingTimeout", "isLoading", "component"]
|
|
6
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare const ResultsContainer: () => import("react/jsx-runtime").JSX.Element;
|
|
2
|
-
export declare const Footer: () => import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
export declare const InstalledBadge: ({ item }: {
|
|
4
|
-
item: ComponentSchema;
|
|
5
|
-
}) => any;
|
|
6
|
-
export declare const ResultCard: ({ result, isSelected, }: {
|
|
7
|
-
result: {
|
|
8
|
-
item: ComponentSchema;
|
|
9
|
-
};
|
|
10
|
-
isSelected: boolean;
|
|
11
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export declare const CategorySectionBadge: ({ item }: {
|
|
13
|
-
item: ComponentSchema;
|
|
14
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export declare const ComponentAccessType: ({ item }: {
|
|
16
|
-
item: ComponentSchema;
|
|
17
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
export declare const ResultsCounter: () => import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
export declare const InstallingSpinnerLabel: () => import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
export declare const UsageBanner: () => import("react/jsx-runtime").JSX.Element;
|
|
21
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useGetComponent.d.ts","sourceRoot":"","sources":["../../src/hooks/useGetComponent.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,eAAe;;;;CA0E3B,CAAA"}
|