ai_co_discuss 0.3.53 → 0.3.54
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 +1 -1
- package/web/app.js +6 -4
- package/web/modern.css +1 -1
- package/web/modern.js +9913 -9913
package/package.json
CHANGED
package/web/app.js
CHANGED
|
@@ -53,7 +53,7 @@ const RELAY_PING_MS = 25000;
|
|
|
53
53
|
const ROOM_RELAY_PATH = /^\/api\/(rooms|folders|revisions)(\/|\?|$)/;
|
|
54
54
|
// One part of a file sent to the computer stays well inside the relay's 1 MiB frame once encoded and encrypted.
|
|
55
55
|
const RELAY_UPLOAD_PART_BYTES = 384 * 1024;
|
|
56
|
-
const COMPUTER_UNREACHABLE = "
|
|
56
|
+
const COMPUTER_UNREACHABLE = "电脑未连接:请先与电脑配对,并确认电脑开机且运行 codiscuss";
|
|
57
57
|
let local_connection = null;
|
|
58
58
|
let computer_connecting = false;
|
|
59
59
|
let relay_machine = null;
|
|
@@ -2115,6 +2115,8 @@ function restore_local_connection() {
|
|
|
2115
2115
|
async function local_launch_request(action, payload) {
|
|
2116
2116
|
// A website without rooms of its own reaches the computer only through the relay; pairing itself still needs the local bridge.
|
|
2117
2117
|
if (relay_machine && (!local_connection || computer_rooms_only() && action !== "machine-link")) return relay_command(action, payload);
|
|
2118
|
+
// Only the computer's own page has a local service at this address; elsewhere the computer is reached through the relay alone.
|
|
2119
|
+
if (!local_connection && !["127.0.0.1", "localhost"].includes(location.hostname)) throw Object.assign(new Error(COMPUTER_UNREACHABLE), { preflight: true });
|
|
2118
2120
|
const headers = { "Content-Type": "application/json", "X-CoDiscuss-Local": "1" };
|
|
2119
2121
|
if (local_connection) headers["X-CoDiscuss-Connection"] = local_connection.token;
|
|
2120
2122
|
let response;
|
|
@@ -2781,7 +2783,6 @@ async function load_launch_settings() {
|
|
|
2781
2783
|
state.launch.connect_command = local ? "codiscuss local open" : `codiscuss local connect "${location.origin}"`;
|
|
2782
2784
|
try {
|
|
2783
2785
|
local_connection = null;
|
|
2784
|
-
relay_machine = null;
|
|
2785
2786
|
take_pairing_code();
|
|
2786
2787
|
local_connection = restore_local_connection();
|
|
2787
2788
|
state.launch.remote = Boolean(local_connection);
|
|
@@ -2790,8 +2791,9 @@ async function load_launch_settings() {
|
|
|
2790
2791
|
// Pair first, so the computer this page runs on can then be reached through the relay like any other device.
|
|
2791
2792
|
state.launch.relay = await load_relay_machine();
|
|
2792
2793
|
// An online computer that publishes a command key does everything the local service would; an older one only creates rooms.
|
|
2793
|
-
|
|
2794
|
-
relay_machine = state.launch.relay;
|
|
2794
|
+
// The previous one stays in use until this answer arrives, so requests made meanwhile still reach the computer.
|
|
2795
|
+
relay_machine = state.launch.relay?.online && state.launch.relay.public_key ? state.launch.relay : null;
|
|
2796
|
+
if (!relay_machine) return;
|
|
2795
2797
|
state.launch.remote = true;
|
|
2796
2798
|
}
|
|
2797
2799
|
const settings = await local_launch_request("settings");
|