@aixnn/aixautots 0.6.12 → 0.6.13
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/{automation-queue-CvrWEOw2.d.ts → automation-queue-BFWqw32O.d.ts} +2 -2
- package/dist/{chunk-PUEKOYSH.js → chunk-2KPZSPV6.js} +131 -3
- package/dist/{chunk-UH5OYPXE.js → chunk-7BJPVSEZ.js} +205 -18
- package/dist/{chunk-LR5LJJNM.js → chunk-HMDUSVQ3.js} +4 -4
- package/dist/{chunk-E7WMHM63.js → chunk-MBBVYSPD.js} +7 -0
- package/dist/{chunk-ROOOAG3E.js → chunk-Q5I63UYT.js} +30 -387
- package/dist/{chunk-7IXBWJHB.js → chunk-QEK25NUA.js} +5 -5
- package/dist/chunk-QFGMQLRB.js +405 -0
- package/dist/{chunk-LO3XD4T5.js → chunk-QRIWTPN3.js} +114 -4
- package/dist/{chunk-D7J4EQTA.js → chunk-S5N4EOCP.js} +1 -1
- package/dist/{chunk-QZLUQSLA.js → chunk-SKI7TINK.js} +349 -420
- package/dist/{chunk-SL6M6CC6.js → chunk-T6X6TWHK.js} +3 -3
- package/dist/{chunk-XCYGBYFC.js → chunk-U4QW45MB.js} +208 -126
- package/dist/{chunk-SKTL6ACT.js → chunk-VMA3QOYR.js} +3 -3
- package/dist/chunk-ZCTAYVPK.js +1 -0
- package/dist/{config-BUH2EYHO.d.ts → config-UmU2_q5M.d.ts} +173 -2
- package/dist/core/index.d.ts +29 -11
- package/dist/core/index.js +2 -2
- package/dist/{device-normalize-DzuVemCy.d.ts → device-normalize-CWJFr_sf.d.ts} +7 -4
- package/dist/device-session-3XK2SZDF.js +1 -0
- package/dist/i18n/index.js +1 -1
- package/dist/{mirror-session-D2YY9mKf.d.ts → mirror-session-Cy20lIHP.d.ts} +14 -4
- package/dist/react/index.d.ts +9 -9
- package/dist/react/index.js +3 -3
- package/dist/{script-debugger-Csm4CrfY.d.ts → script-debugger-F5UGUq5t.d.ts} +1 -1
- package/dist/{task-agent-runner-C4WfT77g.d.ts → task-agent-runner-Cj_u-3DS.d.ts} +3 -3
- package/dist/{types-BfIeUpsU.d.ts → types-BvrppNIZ.d.ts} +34 -2
- package/dist/ui/billing.d.ts +2 -2
- package/dist/ui/billing.js +14 -8
- package/dist/ui/device-create.d.ts +1 -1
- package/dist/ui/device-create.js +8 -7
- package/dist/ui/device-mirror.js +7 -7
- package/dist/ui/devices.d.ts +5 -5
- package/dist/ui/devices.js +12 -11
- package/dist/ui/editor.d.ts +2 -2
- package/dist/ui/editor.js +7 -7
- package/dist/ui/index.d.ts +5 -4
- package/dist/ui/index.js +9 -7
- package/dist/ui/inspector.js +5 -5
- package/dist/ui/ip-commerce.d.ts +26 -0
- package/dist/ui/ip-commerce.js +8 -0
- package/dist/ui/market.js +4 -4
- package/dist/ui/mirror.d.ts +5 -4
- package/dist/ui/mirror.js +1 -1
- package/dist/ui/primitives/index.js +1 -1
- package/dist/ui/script-studio.js +6 -6
- package/dist/ui/scripts.d.ts +1 -1
- package/dist/ui/scripts.js +5 -5
- package/dist/ui/tasks.js +12 -11
- package/package.json +6 -2
- package/dist/device-session-7MKEJTIA.js +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { IosDeviceDiagnostics } from './chunk-
|
|
1
|
+
import { IosDeviceDiagnostics } from './chunk-T6X6TWHK.js';
|
|
2
|
+
import { IpCommercePanel } from './chunk-QFGMQLRB.js';
|
|
2
3
|
import { canConnectPhysicalDevice } from './chunk-ZB5ET67B.js';
|
|
3
|
-
import { useAixT } from './chunk-
|
|
4
|
-
import { cn, Select, Dialog, Button, Input, Badge } from './chunk-
|
|
5
|
-
import { useNodes, useClient, useDevices } from './chunk-
|
|
4
|
+
import { useAixT } from './chunk-QRIWTPN3.js';
|
|
5
|
+
import { cn, Select, Dialog, Button, Input, Badge } from './chunk-VMA3QOYR.js';
|
|
6
|
+
import { useNodes, useClient, useDevices } from './chunk-QEK25NUA.js';
|
|
6
7
|
import { useState, useEffect, useMemo, useCallback, useRef } from 'react';
|
|
7
8
|
import { Server, RefreshCw, Smartphone, Usb, Wifi, Info } from 'lucide-react';
|
|
8
9
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -31,7 +32,7 @@ var CURRENCY_SYMBOL = { CNY: "\xA5", USD: "$" };
|
|
|
31
32
|
function nodeMetric(n) {
|
|
32
33
|
if (n.is_platform) {
|
|
33
34
|
if (n.starting_price == null) return "\u5E73\u53F0\u8282\u70B9";
|
|
34
|
-
const sym = CURRENCY_SYMBOL[n.price_currency ?? "
|
|
35
|
+
const sym = CURRENCY_SYMBOL[n.price_currency ?? "USD"] ?? "";
|
|
35
36
|
return `${sym}${Number(n.starting_price)}/\u5C0F\u65F6 \u8D77`;
|
|
36
37
|
}
|
|
37
38
|
return `${n.device_count} devices`;
|
|
@@ -964,367 +965,6 @@ function ProxySpoofStep({ spec, onChange, isReal, showProxy = !isReal }) {
|
|
|
964
965
|
] });
|
|
965
966
|
}
|
|
966
967
|
|
|
967
|
-
// src/ui/device-create/managed-creation-state.ts
|
|
968
|
-
var creationStorageKey = (baseUrl, owner, project) => `aix-managed-creation:v1:${JSON.stringify([baseUrl, owner, project])}`;
|
|
969
|
-
function readCreationRequest(key) {
|
|
970
|
-
if (!key) return null;
|
|
971
|
-
try {
|
|
972
|
-
const value = JSON.parse(localStorage.getItem(key) ?? "null");
|
|
973
|
-
return value && typeof value.request_id === "string" && typeof value.quote_id === "string" && Number.isSafeInteger(value.authorized_total_minor) && value.authorized_total_minor >= 0 && value.currency === "CNY" ? value : null;
|
|
974
|
-
} catch {
|
|
975
|
-
return null;
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
function validCreationQuote(quote) {
|
|
979
|
-
return !!quote && typeof quote.id === "string" && typeof quote.owner_user_id === "string" && typeof quote.project_id === "string" && Number.isSafeInteger(quote.total_minor) && quote.total_minor >= 0 && quote.currency === "CNY" && !!quote.product && quote.product.currency === "CNY" && quote.product.billing_mode === "one_time" && quote.product.auto_renew === false && quote.product.refund_policy === "no_refund_after_allocation" && Number.isSafeInteger(quote.product.fixed_cost_minor) && (quote.product.fixed_cost_minor ?? -1) >= 0 && Number.isSafeInteger(quote.product.quota_value) && quote.product.quota_value >= 0 && Number.isFinite(quote.product.rate_minor_per_gib) && (quote.product.rate_minor_per_gib ?? -1) >= 0 && quote.product.budget_accounting === "reserved_upper_bound" && (quote.product.reservation_bytes ?? 0) > 0 && (quote.product.handshake_reservation_bytes ?? 0) > 0 && !!quote.device_billing && ["personal_free", "metered"].includes(quote.device_billing.kind) && typeof quote.device_billing.rate_per_hour === "string" && Number.isFinite(Number(quote.device_billing.rate_per_hour)) && Number(quote.device_billing.rate_per_hour) >= 0 && typeof quote.device_billing.currency === "string" && Number.isFinite(Date.parse(quote.expires_at));
|
|
980
|
-
}
|
|
981
|
-
function creationReady(receipt) {
|
|
982
|
-
return receipt?.creation_status === "ready" && receipt.proxy_order.status === "fulfilled" && receipt.proxy_order.apply_status === "applied";
|
|
983
|
-
}
|
|
984
|
-
function creationRejected(error) {
|
|
985
|
-
return error?.requestState === "rejected";
|
|
986
|
-
}
|
|
987
|
-
var money = (minor) => `\xA5${(minor / 100).toFixed(2)}`;
|
|
988
|
-
function ManagedCreationPanel(props) {
|
|
989
|
-
const client = useClient();
|
|
990
|
-
const t = useAixT();
|
|
991
|
-
const translate = useRef(t);
|
|
992
|
-
translate.current = t;
|
|
993
|
-
const epoch = useRef(0);
|
|
994
|
-
const [catalog, setCatalog] = useState(null);
|
|
995
|
-
const [identity, setIdentity] = useState(null);
|
|
996
|
-
const [request, setRequest] = useState(null);
|
|
997
|
-
const [receipt, setReceipt] = useState(null);
|
|
998
|
-
const [quote, setQuote] = useState(null);
|
|
999
|
-
const [productId, setProductId] = useState("");
|
|
1000
|
-
const [region, setRegion] = useState("");
|
|
1001
|
-
const [kind, setKind] = useState("static");
|
|
1002
|
-
const [error, setError] = useState("");
|
|
1003
|
-
const [busy, setBusy] = useState(false);
|
|
1004
|
-
const [loaded, setLoaded] = useState(false);
|
|
1005
|
-
const [fresh, setFresh] = useState(false);
|
|
1006
|
-
const [now, setNow] = useState(Date.now());
|
|
1007
|
-
const active = useRef(true);
|
|
1008
|
-
const inFlight = useRef(false);
|
|
1009
|
-
const pollInFlight = useRef(null);
|
|
1010
|
-
const requestRef = useRef(request);
|
|
1011
|
-
const storageRef = useRef(null);
|
|
1012
|
-
const identityClient = useRef(null);
|
|
1013
|
-
const controllers = useRef(/* @__PURE__ */ new Set());
|
|
1014
|
-
const propsRef = useRef(props);
|
|
1015
|
-
propsRef.current = props;
|
|
1016
|
-
const setPending = (value) => {
|
|
1017
|
-
requestRef.current = value;
|
|
1018
|
-
setRequest(value);
|
|
1019
|
-
};
|
|
1020
|
-
const scopeKey = identity ? creationStorageKey(client.cfg.baseUrl, identity.owner_user_id, identity.project_id) : null;
|
|
1021
|
-
storageRef.current = scopeKey;
|
|
1022
|
-
const run = useCallback(async (operation) => {
|
|
1023
|
-
const controller = new AbortController();
|
|
1024
|
-
controllers.current.add(controller);
|
|
1025
|
-
const timer = setTimeout(() => controller.abort(), 3e4);
|
|
1026
|
-
try {
|
|
1027
|
-
return await operation(controller.signal);
|
|
1028
|
-
} finally {
|
|
1029
|
-
clearTimeout(timer);
|
|
1030
|
-
controllers.current.delete(controller);
|
|
1031
|
-
}
|
|
1032
|
-
}, []);
|
|
1033
|
-
const refresh = useCallback(async () => {
|
|
1034
|
-
const generation = epoch.current;
|
|
1035
|
-
if (pollInFlight.current === generation) return;
|
|
1036
|
-
pollInFlight.current = generation;
|
|
1037
|
-
try {
|
|
1038
|
-
const context = await run((signal) => client.proxies.creations({ signal }));
|
|
1039
|
-
if (!active.current || generation !== epoch.current) return;
|
|
1040
|
-
if (!context || typeof context.owner_user_id !== "string" || typeof context.project_id !== "string" || !Array.isArray(context.items)) throw new Error(translate.current("creation.invalidService"));
|
|
1041
|
-
const key = creationStorageKey(client.cfg.baseUrl, context.owner_user_id, context.project_id);
|
|
1042
|
-
if (storageRef.current && storageRef.current !== key) {
|
|
1043
|
-
controllers.current.forEach((controller) => controller.abort());
|
|
1044
|
-
setQuote(null);
|
|
1045
|
-
setReceipt(null);
|
|
1046
|
-
setError("");
|
|
1047
|
-
setBusy(false);
|
|
1048
|
-
}
|
|
1049
|
-
storageRef.current = key;
|
|
1050
|
-
identityClient.current = client;
|
|
1051
|
-
setIdentity(context);
|
|
1052
|
-
setFresh(true);
|
|
1053
|
-
let pending = readCreationRequest(key);
|
|
1054
|
-
let found = pending ? context.items.find((item) => item.request_id === pending.request_id) : context.items[0];
|
|
1055
|
-
if (pending && !found) {
|
|
1056
|
-
try {
|
|
1057
|
-
found = await run((signal) => client.proxies.creationByRequest(pending.request_id, { signal }));
|
|
1058
|
-
} catch {
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
if (!active.current || generation !== epoch.current) return;
|
|
1062
|
-
if (found && (!pending || pending.request_id === found.request_id)) {
|
|
1063
|
-
if (!pending) {
|
|
1064
|
-
pending = { request_id: found.request_id, quote_id: found.quote_id, authorized_total_minor: found.proxy_order.total_minor, currency: "CNY", uncertain: true };
|
|
1065
|
-
localStorage.setItem(key, JSON.stringify(pending));
|
|
1066
|
-
}
|
|
1067
|
-
setReceipt(found);
|
|
1068
|
-
} else setReceipt((previous) => previous?.request_id === pending?.request_id ? previous : null);
|
|
1069
|
-
setPending(pending);
|
|
1070
|
-
propsRef.current.onPendingChange(!!pending);
|
|
1071
|
-
} catch (e) {
|
|
1072
|
-
if (active.current && generation === epoch.current) {
|
|
1073
|
-
setFresh(false);
|
|
1074
|
-
setError(e.message);
|
|
1075
|
-
}
|
|
1076
|
-
} finally {
|
|
1077
|
-
if (pollInFlight.current === generation) pollInFlight.current = null;
|
|
1078
|
-
if (active.current && generation === epoch.current) setLoaded(true);
|
|
1079
|
-
}
|
|
1080
|
-
}, [client, run]);
|
|
1081
|
-
useEffect(() => {
|
|
1082
|
-
active.current = true;
|
|
1083
|
-
const generation = ++epoch.current;
|
|
1084
|
-
storageRef.current = null;
|
|
1085
|
-
identityClient.current = null;
|
|
1086
|
-
setIdentity(null);
|
|
1087
|
-
setFresh(false);
|
|
1088
|
-
setQuote(null);
|
|
1089
|
-
setReceipt(null);
|
|
1090
|
-
setPending(null);
|
|
1091
|
-
setLoaded(false);
|
|
1092
|
-
setBusy(false);
|
|
1093
|
-
propsRef.current.onPendingChange(false);
|
|
1094
|
-
let timer;
|
|
1095
|
-
const poll = async () => {
|
|
1096
|
-
if (!document.hidden) await refresh();
|
|
1097
|
-
if (active.current && generation === epoch.current) timer = setTimeout(() => void poll(), requestRef.current ? 3e3 : 3e4);
|
|
1098
|
-
};
|
|
1099
|
-
void run((signal) => client.proxies.catalog({ signal })).then((value) => {
|
|
1100
|
-
if (!value || typeof value.enabled !== "boolean" || !Array.isArray(value.products)) throw new Error(translate.current("creation.invalidService"));
|
|
1101
|
-
if (active.current && generation === epoch.current) setCatalog(value);
|
|
1102
|
-
}).catch((e) => {
|
|
1103
|
-
if (active.current && generation === epoch.current) setError(e.message);
|
|
1104
|
-
});
|
|
1105
|
-
void poll();
|
|
1106
|
-
const clock = setInterval(() => setNow(Date.now()), 1e3);
|
|
1107
|
-
const visible = () => {
|
|
1108
|
-
if (!document.hidden) void refresh();
|
|
1109
|
-
};
|
|
1110
|
-
const storage = (event) => {
|
|
1111
|
-
if (event.key === storageRef.current) void refresh();
|
|
1112
|
-
};
|
|
1113
|
-
document.addEventListener("visibilitychange", visible);
|
|
1114
|
-
window.addEventListener("storage", storage);
|
|
1115
|
-
return () => {
|
|
1116
|
-
active.current = false;
|
|
1117
|
-
epoch.current++;
|
|
1118
|
-
clearTimeout(timer);
|
|
1119
|
-
clearInterval(clock);
|
|
1120
|
-
controllers.current.forEach((c) => c.abort());
|
|
1121
|
-
document.removeEventListener("visibilitychange", visible);
|
|
1122
|
-
window.removeEventListener("storage", storage);
|
|
1123
|
-
};
|
|
1124
|
-
}, [client, refresh, run]);
|
|
1125
|
-
const specKey = JSON.stringify(props.spec);
|
|
1126
|
-
useEffect(() => {
|
|
1127
|
-
setQuote(null);
|
|
1128
|
-
}, [specKey, productId, kind, region, props.quantity, props.supported, scopeKey]);
|
|
1129
|
-
const regions = [...new Set(catalog?.products.map((product) => product.region) ?? [])];
|
|
1130
|
-
const selectedRegion = regions.includes(region) ? region : regions[0] ?? "";
|
|
1131
|
-
const products = catalog?.products.filter((product) => product.kind === kind && product.region === selectedRegion) ?? [];
|
|
1132
|
-
const selected = products.find((product) => product.id === productId) ?? products[0];
|
|
1133
|
-
const disabled = !props.supported || props.quantity !== 1 || !catalog?.enabled || !identity || identityClient.current !== client || !loaded || !fresh || busy || !!request;
|
|
1134
|
-
const expired = quote ? Date.parse(quote.expires_at) <= now : true;
|
|
1135
|
-
const getQuote = async () => {
|
|
1136
|
-
if (disabled || !selected || inFlight.current) return;
|
|
1137
|
-
inFlight.current = true;
|
|
1138
|
-
setBusy(true);
|
|
1139
|
-
setError("");
|
|
1140
|
-
setQuote(null);
|
|
1141
|
-
const inputSnapshot = specKey;
|
|
1142
|
-
const generation = epoch.current;
|
|
1143
|
-
const key = scopeKey;
|
|
1144
|
-
try {
|
|
1145
|
-
const value = await run((signal) => client.proxies.creationQuote({ spec: props.spec, product_id: selected.id }, { signal }));
|
|
1146
|
-
if (!active.current || generation !== epoch.current || storageRef.current !== key || JSON.stringify(propsRef.current.spec) !== inputSnapshot) return;
|
|
1147
|
-
if (!validCreationQuote(value) || value.owner_user_id !== identity.owner_user_id || value.project_id !== identity.project_id || value.node_id !== props.spec.node_id || value.product.id !== selected.id) throw new Error(t("creation.invalidQuote"));
|
|
1148
|
-
setQuote(value);
|
|
1149
|
-
setNow(Date.now());
|
|
1150
|
-
} catch (e) {
|
|
1151
|
-
if (active.current && generation === epoch.current && storageRef.current === key) setError(e.message);
|
|
1152
|
-
} finally {
|
|
1153
|
-
inFlight.current = false;
|
|
1154
|
-
if (active.current && generation === epoch.current && storageRef.current === key) setBusy(false);
|
|
1155
|
-
}
|
|
1156
|
-
};
|
|
1157
|
-
const submit = async (input) => {
|
|
1158
|
-
if (!scopeKey || inFlight.current || !request && disabled) return;
|
|
1159
|
-
inFlight.current = true;
|
|
1160
|
-
setBusy(true);
|
|
1161
|
-
setError("");
|
|
1162
|
-
const key = scopeKey;
|
|
1163
|
-
const generation = epoch.current;
|
|
1164
|
-
const current = () => active.current && generation === epoch.current && storageRef.current === key && identityClient.current === client;
|
|
1165
|
-
const send = async () => {
|
|
1166
|
-
if (!current()) return;
|
|
1167
|
-
let uncertain = !!input.uncertain;
|
|
1168
|
-
let sent = false;
|
|
1169
|
-
try {
|
|
1170
|
-
const previous = readCreationRequest(key);
|
|
1171
|
-
if (previous && previous.request_id !== input.request_id) {
|
|
1172
|
-
setPending(previous);
|
|
1173
|
-
throw new Error(t("managed.otherRequest"));
|
|
1174
|
-
}
|
|
1175
|
-
uncertain ||= previous?.request_id === input.request_id || requestRef.current?.request_id === input.request_id;
|
|
1176
|
-
const durable = { ...input, uncertain };
|
|
1177
|
-
localStorage.setItem(key, JSON.stringify(durable));
|
|
1178
|
-
setPending(durable);
|
|
1179
|
-
propsRef.current.onPendingChange(true);
|
|
1180
|
-
sent = true;
|
|
1181
|
-
const value = await run((signal) => client.proxies.create({ request_id: input.request_id, quote_id: input.quote_id, authorized_total_minor: input.authorized_total_minor, currency: "CNY" }, { signal }));
|
|
1182
|
-
if (value.request_id !== input.request_id || value.quote_id !== input.quote_id) throw new Error(translate.current("creation.invalidService"));
|
|
1183
|
-
if (current()) {
|
|
1184
|
-
setReceipt(value);
|
|
1185
|
-
setQuote(null);
|
|
1186
|
-
await refresh();
|
|
1187
|
-
}
|
|
1188
|
-
} catch (e) {
|
|
1189
|
-
const stored = readCreationRequest(key);
|
|
1190
|
-
uncertain ||= stored?.request_id === input.request_id && !!stored.uncertain;
|
|
1191
|
-
if (sent && creationRejected(e) && !uncertain) {
|
|
1192
|
-
if (stored?.request_id === input.request_id) localStorage.removeItem(key);
|
|
1193
|
-
if (current()) {
|
|
1194
|
-
setPending(null);
|
|
1195
|
-
setQuote(null);
|
|
1196
|
-
propsRef.current.onPendingChange(false);
|
|
1197
|
-
}
|
|
1198
|
-
} else if (sent) {
|
|
1199
|
-
if (stored?.request_id === input.request_id) localStorage.setItem(key, JSON.stringify({ ...stored, uncertain: true }));
|
|
1200
|
-
if (current()) await refresh();
|
|
1201
|
-
}
|
|
1202
|
-
if (current()) setError(e.message);
|
|
1203
|
-
}
|
|
1204
|
-
};
|
|
1205
|
-
try {
|
|
1206
|
-
if (typeof navigator.locks?.request === "function") {
|
|
1207
|
-
await navigator.locks.request(key, { ifAvailable: true }, async (lock) => {
|
|
1208
|
-
if (lock) await send();
|
|
1209
|
-
else {
|
|
1210
|
-
if (current()) setError(t("managed.otherRequest"));
|
|
1211
|
-
await refresh();
|
|
1212
|
-
}
|
|
1213
|
-
});
|
|
1214
|
-
} else await send();
|
|
1215
|
-
} catch (e) {
|
|
1216
|
-
if (current()) setError(e.message);
|
|
1217
|
-
} finally {
|
|
1218
|
-
inFlight.current = false;
|
|
1219
|
-
if (current()) setBusy(false);
|
|
1220
|
-
}
|
|
1221
|
-
};
|
|
1222
|
-
const acknowledge = () => {
|
|
1223
|
-
if (!scopeKey || identityClient.current !== client || !receipt || !creationReady(receipt) && receipt.creation_status !== "failed") return;
|
|
1224
|
-
if (readCreationRequest(scopeKey)?.request_id === receipt.request_id) localStorage.removeItem(scopeKey);
|
|
1225
|
-
setPending(null);
|
|
1226
|
-
propsRef.current.onPendingChange(false);
|
|
1227
|
-
propsRef.current.onComplete(receipt.device_id, creationReady(receipt));
|
|
1228
|
-
};
|
|
1229
|
-
if (!props.visible && !request) return null;
|
|
1230
|
-
return /* @__PURE__ */ jsxs("section", { className: "space-y-3 text-sm", "aria-label": t("creation.title"), children: [
|
|
1231
|
-
error && /* @__PURE__ */ jsx("p", { role: "alert", className: "break-words text-destructive", children: error }),
|
|
1232
|
-
!loaded && /* @__PURE__ */ jsx("p", { role: "status", children: t("creation.loading") }),
|
|
1233
|
-
!fresh && loaded && /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => void refresh(), children: t("common.refresh") }),
|
|
1234
|
-
request ? /* @__PURE__ */ jsxs("div", { className: "space-y-3 rounded-md border border-border p-3", children: [
|
|
1235
|
-
/* @__PURE__ */ jsx("p", { role: "status", className: "font-medium", children: creationReady(receipt) ? t("creation.ready") : t(`creation.status.${receipt?.creation_status ?? "unknown"}`) }),
|
|
1236
|
-
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t("creation.recovery") }),
|
|
1237
|
-
/* @__PURE__ */ jsxs("p", { className: "break-all", children: [
|
|
1238
|
-
t("creation.request"),
|
|
1239
|
-
": ",
|
|
1240
|
-
request.request_id
|
|
1241
|
-
] }),
|
|
1242
|
-
receipt && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1243
|
-
/* @__PURE__ */ jsxs("p", { className: "break-all", children: [
|
|
1244
|
-
t("creation.device"),
|
|
1245
|
-
": ",
|
|
1246
|
-
receipt.device_id
|
|
1247
|
-
] }),
|
|
1248
|
-
/* @__PURE__ */ jsxs("p", { children: [
|
|
1249
|
-
t("managed.order"),
|
|
1250
|
-
": ",
|
|
1251
|
-
receipt.proxy_order.id,
|
|
1252
|
-
" \xB7 ",
|
|
1253
|
-
t(`managed.status.${receipt.proxy_order.status}`)
|
|
1254
|
-
] }),
|
|
1255
|
-
receipt.failure_reason && /* @__PURE__ */ jsx("p", { role: "alert", className: "break-words text-destructive", children: receipt.failure_reason }),
|
|
1256
|
-
receipt.creation_status === "failed" && /* @__PURE__ */ jsx("p", { children: t("creation.failedTerms") })
|
|
1257
|
-
] }),
|
|
1258
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
1259
|
-
/* @__PURE__ */ jsx(Button, { variant: "secondary", disabled: busy, onClick: () => void refresh(), children: t("common.refresh") }),
|
|
1260
|
-
!receipt && /* @__PURE__ */ jsx(Button, { disabled: busy || !fresh, onClick: () => void submit(request), children: t("managed.retry") }),
|
|
1261
|
-
(creationReady(receipt) || receipt?.creation_status === "failed") && /* @__PURE__ */ jsx(Button, { disabled: busy, onClick: acknowledge, children: t("creation.done") })
|
|
1262
|
-
] })
|
|
1263
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1264
|
-
!props.supported && /* @__PURE__ */ jsx("p", { children: t("creation.unsupported") }),
|
|
1265
|
-
props.quantity !== 1 && /* @__PURE__ */ jsx("p", { role: "status", children: t("creation.singleOnly") }),
|
|
1266
|
-
catalog && !catalog.enabled && /* @__PURE__ */ jsxs("p", { role: "status", children: [
|
|
1267
|
-
t("creation.unavailable"),
|
|
1268
|
-
catalog.unavailable_reason ? ` \xB7 ${catalog.unavailable_reason}` : ""
|
|
1269
|
-
] }),
|
|
1270
|
-
catalog?.enabled && props.supported && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1271
|
-
/* @__PURE__ */ jsxs("label", { className: "block space-y-1", children: [
|
|
1272
|
-
/* @__PURE__ */ jsx("span", { children: t("creation.country") }),
|
|
1273
|
-
/* @__PURE__ */ jsx("select", { className: "min-h-10 w-full rounded border border-border bg-background px-2", disabled, value: selectedRegion, onChange: (e) => {
|
|
1274
|
-
setRegion(e.target.value);
|
|
1275
|
-
setQuote(null);
|
|
1276
|
-
}, children: regions.map((value) => /* @__PURE__ */ jsx("option", { children: value }, value)) })
|
|
1277
|
-
] }),
|
|
1278
|
-
/* @__PURE__ */ jsx("div", { className: "flex gap-2", role: "group", "aria-label": t("managed.kind"), children: ["static", "dynamic"].map((value) => /* @__PURE__ */ jsx(Button, { variant: kind === value ? "primary" : "secondary", "aria-pressed": kind === value, disabled, onClick: () => {
|
|
1279
|
-
setKind(value);
|
|
1280
|
-
setQuote(null);
|
|
1281
|
-
}, children: t(`managed.${value}`) }, value)) }),
|
|
1282
|
-
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t(`managed.${kind}Hint`) }),
|
|
1283
|
-
selected ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1284
|
-
/* @__PURE__ */ jsxs("label", { className: "block space-y-1", children: [
|
|
1285
|
-
/* @__PURE__ */ jsx("span", { children: t("managed.product") }),
|
|
1286
|
-
/* @__PURE__ */ jsx("select", { className: "min-h-10 w-full rounded border border-border bg-background px-2", disabled, value: selected.id, onChange: (e) => {
|
|
1287
|
-
setProductId(e.target.value);
|
|
1288
|
-
setQuote(null);
|
|
1289
|
-
}, children: products.map((product) => /* @__PURE__ */ jsxs("option", { value: product.id, children: [
|
|
1290
|
-
product.name,
|
|
1291
|
-
" \xB7 ",
|
|
1292
|
-
t("managed.hours", { n: product.duration_seconds / 3600 }),
|
|
1293
|
-
" \xB7 ",
|
|
1294
|
-
money(product.cost_minor)
|
|
1295
|
-
] }, product.id)) })
|
|
1296
|
-
] }),
|
|
1297
|
-
/* @__PURE__ */ jsx("p", { children: t("managed.budget", { amount: money(selected.quota_value) }) }),
|
|
1298
|
-
/* @__PURE__ */ jsx(Button, { disabled, onClick: () => void getQuote(), children: t("managed.quote") })
|
|
1299
|
-
] }) : /* @__PURE__ */ jsx("p", { children: t("managed.emptyCatalog") })
|
|
1300
|
-
] }),
|
|
1301
|
-
quote && /* @__PURE__ */ jsxs("div", { className: "space-y-2 rounded-md border border-primary/40 p-3", children: [
|
|
1302
|
-
/* @__PURE__ */ jsx("p", { className: "font-semibold", children: t("creation.ipTotal", { amount: money(quote.total_minor) }) }),
|
|
1303
|
-
/* @__PURE__ */ jsxs("p", { children: [
|
|
1304
|
-
quote.product.region,
|
|
1305
|
-
" \xB7 ",
|
|
1306
|
-
t(`managed.${quote.product.kind}`),
|
|
1307
|
-
" \xB7 ",
|
|
1308
|
-
t("managed.hours", { n: quote.product.duration_seconds / 3600 })
|
|
1309
|
-
] }),
|
|
1310
|
-
/* @__PURE__ */ jsx("p", { children: t("managed.fixedCost", { amount: money(quote.product.fixed_cost_minor) }) }),
|
|
1311
|
-
/* @__PURE__ */ jsx("p", { children: t("managed.budget", { amount: money(quote.product.quota_value) }) }),
|
|
1312
|
-
quote.product.rate_minor_per_gib != null && /* @__PURE__ */ jsx("p", { children: t("managed.rate", { amount: money(quote.product.rate_minor_per_gib) }) }),
|
|
1313
|
-
quote.product.budget_accounting === "reserved_upper_bound" && /* @__PURE__ */ jsx("p", { children: t("managed.reservations", { kib: (quote.product.reservation_bytes ?? 16384) / 1024 }) }),
|
|
1314
|
-
quote.product.handshake_reservation_bytes != null && /* @__PURE__ */ jsx("p", { children: t("managed.handshakeReservation", { kib: quote.product.handshake_reservation_bytes / 1024 }) }),
|
|
1315
|
-
/* @__PURE__ */ jsx("p", { children: t("managed.noRenew") }),
|
|
1316
|
-
/* @__PURE__ */ jsx("p", { children: t("creation.failedTerms") }),
|
|
1317
|
-
/* @__PURE__ */ jsx("p", { className: "font-medium", children: t("creation.startupNetwork") }),
|
|
1318
|
-
/* @__PURE__ */ jsx("p", { children: quote.device_billing.kind === "metered" ? t("creation.metered", { amount: quote.device_billing.rate_per_hour, currency: quote.device_billing.currency }) : t("creation.personalFree") }),
|
|
1319
|
-
/* @__PURE__ */ jsx("p", { children: expired ? t("managed.quoteExpired") : t("managed.quoteExpiry", { at: new Date(quote.expires_at).toLocaleString() }) }),
|
|
1320
|
-
/* @__PURE__ */ jsx(Button, { disabled: disabled || expired, onClick: () => {
|
|
1321
|
-
if (Date.parse(quote.expires_at) > Date.now()) void submit({ request_id: crypto.randomUUID(), quote_id: quote.id, authorized_total_minor: quote.total_minor, currency: "CNY" });
|
|
1322
|
-
}, children: t("creation.authorize", { amount: money(quote.total_minor) }) })
|
|
1323
|
-
] })
|
|
1324
|
-
] })
|
|
1325
|
-
] });
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
968
|
// src/ui/device-create/create-proxy-capabilities.ts
|
|
1329
969
|
function createProxyCapabilities(kind, spec, node) {
|
|
1330
970
|
const cap = node?.reported_caps?.egress_proxy;
|
|
@@ -1347,7 +987,7 @@ function DeviceCreate({ open, onClose, onCreated }) {
|
|
|
1347
987
|
const [busy, setBusy] = useState(false);
|
|
1348
988
|
const [error, setError] = useState("");
|
|
1349
989
|
const [quantity, setQuantity] = useState(1);
|
|
1350
|
-
const [networkMode, setNetworkMode] = useState("
|
|
990
|
+
const [networkMode, setNetworkMode] = useState("managed");
|
|
1351
991
|
const [managedPending, setManagedPending] = useState(false);
|
|
1352
992
|
const proxyCapabilities = createProxyCapabilities(kind, spec, nodes?.find((node) => node.id === nodeId));
|
|
1353
993
|
useEffect(() => {
|
|
@@ -1361,7 +1001,7 @@ function DeviceCreate({ open, onClose, onCreated }) {
|
|
|
1361
1001
|
setBusy(false);
|
|
1362
1002
|
setError("");
|
|
1363
1003
|
setQuantity(1);
|
|
1364
|
-
setNetworkMode("
|
|
1004
|
+
setNetworkMode("managed");
|
|
1365
1005
|
setManagedPending(false);
|
|
1366
1006
|
}, [open]);
|
|
1367
1007
|
const proxyOk = networkMode !== "custom" || proxyCapabilities.custom && isSupportedProxyUrl(spec.proxy?.trim() ?? "");
|
|
@@ -1455,7 +1095,10 @@ function DeviceCreate({ open, onClose, onCreated }) {
|
|
|
1455
1095
|
active: kind === "virtual",
|
|
1456
1096
|
title: "\u865A\u62DF\u8BBE\u5907",
|
|
1457
1097
|
desc: "Android / iOS \u4E91\u8BBE\u5907\uFF0C\u6309\u89C4\u683C\u65B0\u5EFA",
|
|
1458
|
-
onClick: () =>
|
|
1098
|
+
onClick: () => {
|
|
1099
|
+
setKind("virtual");
|
|
1100
|
+
setNetworkMode("managed");
|
|
1101
|
+
}
|
|
1459
1102
|
}
|
|
1460
1103
|
),
|
|
1461
1104
|
/* @__PURE__ */ jsx(
|
|
@@ -1464,7 +1107,10 @@ function DeviceCreate({ open, onClose, onCreated }) {
|
|
|
1464
1107
|
active: kind === "real",
|
|
1465
1108
|
title: "\u771F\u673A",
|
|
1466
1109
|
desc: "\u4ECE\u8282\u70B9\u5DF2\u4E0A\u62A5\u7684\u771F\u673A\u4E2D\u9009\u53D6",
|
|
1467
|
-
onClick: () =>
|
|
1110
|
+
onClick: () => {
|
|
1111
|
+
setKind("real");
|
|
1112
|
+
setNetworkMode("none");
|
|
1113
|
+
}
|
|
1468
1114
|
}
|
|
1469
1115
|
)
|
|
1470
1116
|
] }),
|
|
@@ -1473,25 +1119,21 @@ function DeviceCreate({ open, onClose, onCreated }) {
|
|
|
1473
1119
|
setVirtualSpecValid(false);
|
|
1474
1120
|
}, hidePlatform: kind === "real", virtualOnly: kind === "virtual" }),
|
|
1475
1121
|
step === 2 && (kind === "virtual" ? /* @__PURE__ */ jsx(VirtualSpecStep, { spec, onChange: setSpec, nodeId, onValidityChange: setVirtualSpecValid }) : /* @__PURE__ */ jsx(RealDiscoverStep, { nodeId, picked, onPick: setPicked })),
|
|
1476
|
-
step === 3 && !managedPending && /* @__PURE__ */
|
|
1477
|
-
/* @__PURE__ */
|
|
1478
|
-
|
|
1479
|
-
/* @__PURE__ */
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
/* @__PURE__ */ jsx(Button, { variant: networkMode === "none" ? "primary" : "secondary", "aria-pressed": networkMode === "none", disabled: busy, onClick: () => setNetworkMode("none"), children: t("creation.none") })
|
|
1483
|
-
] }),
|
|
1484
|
-
!proxyCapabilities.custom && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("creation.unsupported") })
|
|
1122
|
+
step === 3 && !managedPending && /* @__PURE__ */ jsx(Fragment, { children: kind === "virtual" && /* @__PURE__ */ jsxs("fieldset", { className: "space-y-2", children: [
|
|
1123
|
+
/* @__PURE__ */ jsx("legend", { className: "text-sm font-medium", children: t("creation.network") }),
|
|
1124
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-2", children: [
|
|
1125
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "py-2 text-xs font-medium text-primary hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary", "aria-pressed": networkMode === "managed", disabled: busy, onClick: () => setNetworkMode("managed"), children: t("creation.managed") }),
|
|
1126
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "py-2 text-xs text-primary hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:opacity-50", "aria-pressed": networkMode === "custom", disabled: busy || !proxyCapabilities.custom, onClick: () => setNetworkMode("custom"), children: t("proxy.manualInput") }),
|
|
1127
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "py-2 text-xs text-muted-foreground hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary", "aria-pressed": networkMode === "none", disabled: busy, onClick: () => setNetworkMode("none"), children: t("creation.none") })
|
|
1485
1128
|
] }),
|
|
1486
|
-
/* @__PURE__ */ jsx(
|
|
1487
|
-
] }),
|
|
1129
|
+
networkMode === "none" && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("proxy.directHint") })
|
|
1130
|
+
] }) }),
|
|
1488
1131
|
open && /* @__PURE__ */ jsx(
|
|
1489
|
-
|
|
1132
|
+
IpCommercePanel,
|
|
1490
1133
|
{
|
|
1491
1134
|
visible: step === 3 && networkMode === "managed",
|
|
1492
|
-
supported: proxyCapabilities.managed,
|
|
1493
|
-
|
|
1494
|
-
spec: { ...spec, proxy: void 0, node_id: nodeId },
|
|
1135
|
+
supported: proxyCapabilities.managed && quantity === 1,
|
|
1136
|
+
creationSpec: { ...spec, proxy: void 0, node_id: nodeId },
|
|
1495
1137
|
onPendingChange: (pending) => {
|
|
1496
1138
|
setManagedPending(pending);
|
|
1497
1139
|
if (pending) {
|
|
@@ -1499,13 +1141,14 @@ function DeviceCreate({ open, onClose, onCreated }) {
|
|
|
1499
1141
|
setStep(3);
|
|
1500
1142
|
}
|
|
1501
1143
|
},
|
|
1502
|
-
|
|
1144
|
+
onCreated: () => {
|
|
1503
1145
|
void fetchDevices();
|
|
1504
|
-
|
|
1146
|
+
onCreated?.(null);
|
|
1505
1147
|
onClose();
|
|
1506
1148
|
}
|
|
1507
1149
|
}
|
|
1508
1150
|
),
|
|
1151
|
+
step === 3 && !managedPending && /* @__PURE__ */ jsx(ProxySpoofStep, { spec, onChange: setSpec, isReal: kind === "real", showProxy: networkMode === "custom" && proxyCapabilities.custom }),
|
|
1509
1152
|
step === 3 && kind === "virtual" && !managedPending && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1510
1153
|
/* @__PURE__ */ jsx("label", { className: "text-[11px] text-muted-foreground", children: "\u521B\u5EFA\u6570\u91CF" }),
|
|
1511
1154
|
/* @__PURE__ */ jsx(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DeviceChannel, ScriptDebugger, FlowRun, MirrorSession, normalizeDevices, submitBatch } from './chunk-
|
|
2
|
-
import { resolveConfig, AixClient, isFleetRunTerminal, joinUrl, AixAuthError, AixError, EnvRun, detectEnvOs, summarizeEnv, ReconnectingSocket, executionWsTicketUrl } from './chunk-
|
|
1
|
+
import { DeviceChannel, ScriptDebugger, FlowRun, MirrorSession, normalizeDevices, submitBatch } from './chunk-7BJPVSEZ.js';
|
|
2
|
+
import { resolveConfig, AixClient, isFleetRunTerminal, joinUrl, AixAuthError, AixError, EnvRun, detectEnvOs, summarizeEnv, ReconnectingSocket, executionWsTicketUrl } from './chunk-2KPZSPV6.js';
|
|
3
3
|
import React, { createContext, useContext, useState, useRef, useEffect, useCallback, useMemo, createElement } from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -219,7 +219,7 @@ function useFlowRun() {
|
|
|
219
219
|
}, []);
|
|
220
220
|
return { taskId, events, done, error, submit, close };
|
|
221
221
|
}
|
|
222
|
-
function useMirror(sessionId) {
|
|
222
|
+
function useMirror(sessionId, options = {}) {
|
|
223
223
|
const cfg = useAixConfig();
|
|
224
224
|
const [session, setSession] = useState(null);
|
|
225
225
|
const [stream, setStream] = useState(null);
|
|
@@ -241,7 +241,7 @@ function useMirror(sessionId) {
|
|
|
241
241
|
if (!sessionId) return () => {
|
|
242
242
|
mountedRef.current = false;
|
|
243
243
|
};
|
|
244
|
-
MirrorSession.join(cfg, sessionId, joining.signal).then((ms) => {
|
|
244
|
+
MirrorSession.join(cfg, sessionId, joining.signal, options).then((ms) => {
|
|
245
245
|
if (cancelled) {
|
|
246
246
|
ms.leave();
|
|
247
247
|
return;
|
|
@@ -277,7 +277,7 @@ function useMirror(sessionId) {
|
|
|
277
277
|
ref.current?.leave();
|
|
278
278
|
ref.current = null;
|
|
279
279
|
};
|
|
280
|
-
}, [cfg, sessionId]);
|
|
280
|
+
}, [cfg, sessionId, options.permission]);
|
|
281
281
|
const sendInput = useCallback((msg) => {
|
|
282
282
|
ref.current?.sendInput(msg);
|
|
283
283
|
}, []);
|