@gradio/client 2.5.0 → 2.5.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/CHANGELOG.md +6 -0
- package/dist/browser.js +174 -156
- package/dist/index.cjs +32 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -1
- package/dist/index.min.js +55 -37
- package/dist/utils/run_history.d.ts +26 -0
- package/dist/utils/run_history.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/test/run_history.test.ts +67 -0
- package/src/utils/run_history.ts +69 -0
package/dist/index.cjs
CHANGED
|
@@ -1594,6 +1594,27 @@ function consume_run_history_replay_impl(scope) {
|
|
|
1594
1594
|
return null;
|
|
1595
1595
|
}
|
|
1596
1596
|
}
|
|
1597
|
+
function restore_run_impl(config, run) {
|
|
1598
|
+
const dependency = config.dependencies.find((item) => item.id === run.fn_index || typeof item.api_name === "string" && `/${item.api_name.replace(/^\//, "")}` === run.api_name);
|
|
1599
|
+
if (!dependency) return false;
|
|
1600
|
+
const inputs = Array.isArray(run.inputs) ? run.inputs : Object.values(run.inputs ?? {});
|
|
1601
|
+
const outputs = Array.isArray(run.outputs) ? run.outputs : run.outputs === null || run.outputs === void 0 ? [] : [run.outputs];
|
|
1602
|
+
const restore = (ids, saved) => {
|
|
1603
|
+
for (const [index, id] of ids.entries()) {
|
|
1604
|
+
const component = config.components.find((item) => item.id === id);
|
|
1605
|
+
if (!component || index >= saved.length) continue;
|
|
1606
|
+
if (component.type === "state") continue;
|
|
1607
|
+
component.props.value = saved[index];
|
|
1608
|
+
}
|
|
1609
|
+
};
|
|
1610
|
+
restore(dependency.inputs, inputs);
|
|
1611
|
+
restore(dependency.outputs, outputs);
|
|
1612
|
+
return true;
|
|
1613
|
+
}
|
|
1614
|
+
function apply_run_history_replay_impl(config) {
|
|
1615
|
+
const run = consume_run_history_replay_impl(config);
|
|
1616
|
+
return run ? restore_run_impl(config, run) : false;
|
|
1617
|
+
}
|
|
1597
1618
|
function start_run_history_impl(options) {
|
|
1598
1619
|
const key = storage_key(options);
|
|
1599
1620
|
if (!key) return null;
|
|
@@ -1686,6 +1707,16 @@ function stage_run_history_replay(scope, run) {
|
|
|
1686
1707
|
function consume_run_history_replay(scope) {
|
|
1687
1708
|
return safely(() => consume_run_history_replay_impl(scope), null);
|
|
1688
1709
|
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Applies the run staged by the history page, if this page load is the one it
|
|
1712
|
+
* was staged for. Every entry point that renders an app has to call this, or
|
|
1713
|
+
* "Load run" silently does nothing on that entry point.
|
|
1714
|
+
*
|
|
1715
|
+
* @returns whether a staged run was found and applied.
|
|
1716
|
+
*/
|
|
1717
|
+
function apply_run_history_replay(config) {
|
|
1718
|
+
return safely(() => apply_run_history_replay_impl(config), false);
|
|
1719
|
+
}
|
|
1689
1720
|
function start_run_history(options) {
|
|
1690
1721
|
return safely(() => start_run_history_impl(options), null);
|
|
1691
1722
|
}
|
|
@@ -2567,6 +2598,7 @@ async function duplicate_space(app_reference, options) {
|
|
|
2567
2598
|
exports.Client = Client;
|
|
2568
2599
|
exports.FileData = FileData;
|
|
2569
2600
|
exports.MISSING_CREDENTIALS_MSG = MISSING_CREDENTIALS_MSG;
|
|
2601
|
+
exports.apply_run_history_replay = apply_run_history_replay;
|
|
2570
2602
|
exports.clear_run_history = clear_run_history;
|
|
2571
2603
|
exports.client = client;
|
|
2572
2604
|
exports.consume_run_history_replay = consume_run_history_replay;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { submit } from "./utils/submit";
|
|
|
4
4
|
export { upload_files } from "./utils/upload_files";
|
|
5
5
|
export { FileData, upload, prepare_files } from "./upload";
|
|
6
6
|
export { handle_file } from "./helpers/data";
|
|
7
|
-
export { clear_run_history, consume_run_history_replay, delete_run_history, on_run_history_change, read_run_history, run_history_url, stage_run_history_replay, type RunHistoryScope, type StoredRunComponent, type StoredRun } from "./utils/run_history";
|
|
7
|
+
export { apply_run_history_replay, clear_run_history, consume_run_history_replay, delete_run_history, on_run_history_change, read_run_history, run_history_url, stage_run_history_replay, type ReplayTarget, type RunHistoryScope, type StoredRunComponent, type StoredRun } from "./utils/run_history";
|
|
8
8
|
export type { SpaceStatus, StatusMessage, Status, client_return, UploadResponse, RenderMessage, LogMessage, Payload, Config, ValidationError } from "./types";
|
|
9
9
|
export { MISSING_CREDENTIALS_MSG } from "./constants";
|
|
10
10
|
export { client } from "./client";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACN,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACX,WAAW,EACX,aAAa,EACb,MAAM,EACN,aAAa,EACb,cAAc,EACd,aAAa,EACb,UAAU,EACV,OAAO,EACP,MAAM,EACN,eAAe,EACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAGtD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,IAAI,SAAS,EAAE,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACN,wBAAwB,EACxB,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,wBAAwB,EACxB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACX,WAAW,EACX,aAAa,EACb,MAAM,EACN,aAAa,EACb,cAAc,EACd,aAAa,EACb,UAAU,EACV,OAAO,EACP,MAAM,EACN,eAAe,EACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAGtD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,IAAI,SAAS,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1593,6 +1593,27 @@ function consume_run_history_replay_impl(scope) {
|
|
|
1593
1593
|
return null;
|
|
1594
1594
|
}
|
|
1595
1595
|
}
|
|
1596
|
+
function restore_run_impl(config, run) {
|
|
1597
|
+
const dependency = config.dependencies.find((item) => item.id === run.fn_index || typeof item.api_name === "string" && `/${item.api_name.replace(/^\//, "")}` === run.api_name);
|
|
1598
|
+
if (!dependency) return false;
|
|
1599
|
+
const inputs = Array.isArray(run.inputs) ? run.inputs : Object.values(run.inputs ?? {});
|
|
1600
|
+
const outputs = Array.isArray(run.outputs) ? run.outputs : run.outputs === null || run.outputs === void 0 ? [] : [run.outputs];
|
|
1601
|
+
const restore = (ids, saved) => {
|
|
1602
|
+
for (const [index, id] of ids.entries()) {
|
|
1603
|
+
const component = config.components.find((item) => item.id === id);
|
|
1604
|
+
if (!component || index >= saved.length) continue;
|
|
1605
|
+
if (component.type === "state") continue;
|
|
1606
|
+
component.props.value = saved[index];
|
|
1607
|
+
}
|
|
1608
|
+
};
|
|
1609
|
+
restore(dependency.inputs, inputs);
|
|
1610
|
+
restore(dependency.outputs, outputs);
|
|
1611
|
+
return true;
|
|
1612
|
+
}
|
|
1613
|
+
function apply_run_history_replay_impl(config) {
|
|
1614
|
+
const run = consume_run_history_replay_impl(config);
|
|
1615
|
+
return run ? restore_run_impl(config, run) : false;
|
|
1616
|
+
}
|
|
1596
1617
|
function start_run_history_impl(options) {
|
|
1597
1618
|
const key = storage_key(options);
|
|
1598
1619
|
if (!key) return null;
|
|
@@ -1685,6 +1706,16 @@ function stage_run_history_replay(scope, run) {
|
|
|
1685
1706
|
function consume_run_history_replay(scope) {
|
|
1686
1707
|
return safely(() => consume_run_history_replay_impl(scope), null);
|
|
1687
1708
|
}
|
|
1709
|
+
/**
|
|
1710
|
+
* Applies the run staged by the history page, if this page load is the one it
|
|
1711
|
+
* was staged for. Every entry point that renders an app has to call this, or
|
|
1712
|
+
* "Load run" silently does nothing on that entry point.
|
|
1713
|
+
*
|
|
1714
|
+
* @returns whether a staged run was found and applied.
|
|
1715
|
+
*/
|
|
1716
|
+
function apply_run_history_replay(config) {
|
|
1717
|
+
return safely(() => apply_run_history_replay_impl(config), false);
|
|
1718
|
+
}
|
|
1688
1719
|
function start_run_history(options) {
|
|
1689
1720
|
return safely(() => start_run_history_impl(options), null);
|
|
1690
1721
|
}
|
|
@@ -2563,4 +2594,4 @@ async function duplicate_space(app_reference, options) {
|
|
|
2563
2594
|
return await Client.duplicate(app_reference, options);
|
|
2564
2595
|
}
|
|
2565
2596
|
//#endregion
|
|
2566
|
-
export { Client, FileData, MISSING_CREDENTIALS_MSG, clear_run_history, client, consume_run_history_replay, delete_run_history, duplicate_space as duplicate, handle_file, on_run_history_change, predict, prepare_files, read_run_history, run_history_url, stage_run_history_replay, submit, upload, upload_files };
|
|
2597
|
+
export { Client, FileData, MISSING_CREDENTIALS_MSG, apply_run_history_replay, clear_run_history, client, consume_run_history_replay, delete_run_history, duplicate_space as duplicate, handle_file, on_run_history_change, predict, prepare_files, read_run_history, run_history_url, stage_run_history_replay, submit, upload, upload_files };
|
package/dist/index.min.js
CHANGED
|
@@ -1227,7 +1227,22 @@ function St(e) {
|
|
|
1227
1227
|
return null;
|
|
1228
1228
|
}
|
|
1229
1229
|
}
|
|
1230
|
-
function Ct(e) {
|
|
1230
|
+
function Ct(e, t) {
|
|
1231
|
+
let n = e.dependencies.find((e) => e.id === t.fn_index || typeof e.api_name == "string" && `/${e.api_name.replace(/^\//, "")}` === t.api_name);
|
|
1232
|
+
if (!n) return !1;
|
|
1233
|
+
let r = Array.isArray(t.inputs) ? t.inputs : Object.values(t.inputs ?? {}), i = Array.isArray(t.outputs) ? t.outputs : t.outputs === null || t.outputs === void 0 ? [] : [t.outputs], a = (t, n) => {
|
|
1234
|
+
for (let [r, i] of t.entries()) {
|
|
1235
|
+
let t = e.components.find((e) => e.id === i);
|
|
1236
|
+
!t || r >= n.length || t.type !== "state" && (t.props.value = n[r]);
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1239
|
+
return a(n.inputs, r), a(n.outputs, i), !0;
|
|
1240
|
+
}
|
|
1241
|
+
function wt(e) {
|
|
1242
|
+
let t = St(e);
|
|
1243
|
+
return t ? Ct(e, t) : !1;
|
|
1244
|
+
}
|
|
1245
|
+
function Tt(e) {
|
|
1231
1246
|
let t = Y(e);
|
|
1232
1247
|
if (!t) return null;
|
|
1233
1248
|
pt(t);
|
|
@@ -1246,74 +1261,77 @@ function Ct(e) {
|
|
|
1246
1261
|
};
|
|
1247
1262
|
return ht(e, [n, ...Z(e)]), yt(), n.id;
|
|
1248
1263
|
}
|
|
1249
|
-
function
|
|
1264
|
+
function Et(e, t, n) {
|
|
1250
1265
|
if (!t) return;
|
|
1251
1266
|
let r = Z(e), i = r.find((e) => e.id === t);
|
|
1252
1267
|
i && (i.inputs = X(n), ht(e, r));
|
|
1253
1268
|
}
|
|
1254
|
-
function
|
|
1269
|
+
function Dt(e, t, n) {
|
|
1255
1270
|
if (!t) return;
|
|
1256
1271
|
let r = Z(e), i = r.find((e) => e.id === t);
|
|
1257
1272
|
if (!i) return;
|
|
1258
1273
|
let a = !1;
|
|
1259
1274
|
if (n.type === "data") i.outputs = X(n.data), Q.set(t, i.outputs);
|
|
1260
|
-
else if (n.type === "status" && n.original_msg === "process_starts")
|
|
1275
|
+
else if (n.type === "status" && n.original_msg === "process_starts") At(i, n.time);
|
|
1261
1276
|
else if (n.type === "status" && (n.stage === "generating" || n.stage === "streaming")) i.streamed = !0;
|
|
1262
|
-
else if (n.type === "status" && n.stage === "complete") i.status = "completed",
|
|
1263
|
-
else if (n.type === "status" && n.stage === "error") i.status = "failed", i.error = typeof n.message == "string" ? n.message : JSON.stringify(n.message || "Unknown error"),
|
|
1277
|
+
else if (n.type === "status" && n.stage === "complete") i.status = "completed", jt(i, n), a = !0;
|
|
1278
|
+
else if (n.type === "status" && n.stage === "error") i.status = "failed", i.error = typeof n.message == "string" ? n.message : JSON.stringify(n.message || "Unknown error"), jt(i, n), a = !0;
|
|
1264
1279
|
else return;
|
|
1265
|
-
if (a) Q.has(t) && (i.outputs = Q.get(t)), Q.delete(t),
|
|
1280
|
+
if (a) Q.has(t) && (i.outputs = Q.get(t)), Q.delete(t), kt.delete(t);
|
|
1266
1281
|
else if (i.streamed) {
|
|
1267
|
-
if (Date.now() - (
|
|
1268
|
-
|
|
1282
|
+
if (Date.now() - (kt.get(t) ?? 0) < Ot) return;
|
|
1283
|
+
kt.set(t, Date.now()), Q.delete(t);
|
|
1269
1284
|
}
|
|
1270
1285
|
ht(e, r);
|
|
1271
1286
|
}
|
|
1272
|
-
var
|
|
1273
|
-
function
|
|
1287
|
+
var Ot = 500, kt = /* @__PURE__ */ new Map(), Q = /* @__PURE__ */ new Map();
|
|
1288
|
+
function At(e, t) {
|
|
1274
1289
|
if (e.process_started_at) return;
|
|
1275
1290
|
let n = t || /* @__PURE__ */ new Date();
|
|
1276
1291
|
e.process_started_at = n.toISOString(), e.queued_ms = Math.max(0, n.getTime() - Date.parse(e.started_at));
|
|
1277
1292
|
}
|
|
1278
|
-
function
|
|
1293
|
+
function jt(e, t) {
|
|
1279
1294
|
let n = t.time || /* @__PURE__ */ new Date();
|
|
1280
1295
|
e.completed_at = n.toISOString(), e.duration_ms = (!e.streamed && typeof t.cache_duration == "number" && t.cache_duration >= 0 ? t.cache_duration * 1e3 : null) ?? Math.max(0, n.getTime() - Date.parse(e.process_started_at || e.started_at));
|
|
1281
1296
|
}
|
|
1282
|
-
function
|
|
1297
|
+
function Mt(e) {
|
|
1283
1298
|
return J(() => Z(e), []);
|
|
1284
1299
|
}
|
|
1285
|
-
function
|
|
1300
|
+
function Nt(e) {
|
|
1286
1301
|
J(() => gt(e), void 0);
|
|
1287
1302
|
}
|
|
1288
|
-
function
|
|
1303
|
+
function Pt(e, t) {
|
|
1289
1304
|
J(() => _t(e, t), void 0);
|
|
1290
1305
|
}
|
|
1291
|
-
function
|
|
1306
|
+
function Ft(e, t) {
|
|
1292
1307
|
J(() => xt(e, t), void 0);
|
|
1293
1308
|
}
|
|
1294
|
-
function
|
|
1309
|
+
function It(e) {
|
|
1295
1310
|
return J(() => St(e), null);
|
|
1296
1311
|
}
|
|
1297
|
-
function
|
|
1298
|
-
return J(() =>
|
|
1312
|
+
function Lt(e) {
|
|
1313
|
+
return J(() => wt(e), !1);
|
|
1299
1314
|
}
|
|
1300
|
-
function
|
|
1301
|
-
J(() =>
|
|
1315
|
+
function Rt(e) {
|
|
1316
|
+
return J(() => Tt(e), null);
|
|
1302
1317
|
}
|
|
1303
|
-
function
|
|
1304
|
-
J(() =>
|
|
1318
|
+
function zt(e, t, n) {
|
|
1319
|
+
J(() => Et(e, t, n), void 0);
|
|
1305
1320
|
}
|
|
1306
|
-
function
|
|
1321
|
+
function Bt(e, t, n) {
|
|
1322
|
+
J(() => Dt(e, t, n), void 0);
|
|
1323
|
+
}
|
|
1324
|
+
function Vt(e) {
|
|
1307
1325
|
return J(() => bt(() => J(e, void 0)), () => {});
|
|
1308
1326
|
}
|
|
1309
1327
|
//#endregion
|
|
1310
1328
|
//#region src/utils/submit.ts
|
|
1311
|
-
function
|
|
1329
|
+
function Ht(e, t = {}, n, r, i, a) {
|
|
1312
1330
|
try {
|
|
1313
1331
|
let { token: o } = this.options, { fetch: s, app_reference: c, config: l, session_hash: f, api_info: p, api_map: m, stream_status: h, pending_stream_messages: g, pending_diff_streams: ee, event_callbacks: _, unclosed_events: te, post_data: v, options: b, api_prefix: x } = this, S = a || { "x-gradio-user": "api" }, C = this;
|
|
1314
1332
|
if (!p) throw Error(se);
|
|
1315
1333
|
if (!l) throw Error("Could not resolve app config");
|
|
1316
|
-
let { fn_index: w, endpoint_info: T, dependency: E } =
|
|
1334
|
+
let { fn_index: w, endpoint_info: T, dependency: E } = Wt(p, e, m, l), ae = ye(t, T), D = l.protocol ?? "ws";
|
|
1317
1335
|
if (D === "ws") throw Error(ce);
|
|
1318
1336
|
let oe = typeof E.api_name == "string" ? `/${E.api_name}` : e, le = typeof E.api_name == "string" ? `/${E.api_name}` : `Function ${w}`, O = (e) => {
|
|
1319
1337
|
let t = l.components.find((t) => t.id === e);
|
|
@@ -1325,7 +1343,7 @@ function zt(e, t = {}, n, r, i, a) {
|
|
|
1325
1343
|
}, ue = E.api_visibility === "public", de = l.run_history !== !1 && this.options.record_history !== !1, k = {
|
|
1326
1344
|
app_id: l.app_id,
|
|
1327
1345
|
username: l.username
|
|
1328
|
-
}, fe = !de || !ue ? null :
|
|
1346
|
+
}, fe = !de || !ue ? null : Rt({
|
|
1329
1347
|
...k,
|
|
1330
1348
|
endpoint: oe,
|
|
1331
1349
|
api_name: le,
|
|
@@ -1335,7 +1353,7 @@ function zt(e, t = {}, n, r, i, a) {
|
|
|
1335
1353
|
output_components: E.outputs.map(O)
|
|
1336
1354
|
}), A, j = "", M = typeof e == "number" ? "/predict" : e, N, P = null, F = !1, I = {}, L = typeof window < "u" && typeof document < "u" ? new URLSearchParams(window.location.search).toString() : "", pe = b?.events?.reduce((e, t) => (e[t] = !0, e), {}) || {};
|
|
1337
1355
|
function R(e) {
|
|
1338
|
-
|
|
1356
|
+
Bt(k, fe, e), (i || pe[e.type]) && U(e);
|
|
1339
1357
|
}
|
|
1340
1358
|
async function me() {
|
|
1341
1359
|
let e = {}, t = {};
|
|
@@ -1376,7 +1394,7 @@ function zt(e, t = {}, n, r, i, a) {
|
|
|
1376
1394
|
}
|
|
1377
1395
|
let _e = this.handle_blob(l.root, ae, T).then(async (e) => {
|
|
1378
1396
|
let t = G(e, E, l.components, "input", !0);
|
|
1379
|
-
if (
|
|
1397
|
+
if (zt(k, fe, t || []), N = {
|
|
1380
1398
|
data: t || [],
|
|
1381
1399
|
event_data: n,
|
|
1382
1400
|
fn_index: w,
|
|
@@ -1678,7 +1696,7 @@ function zt(e, t = {}, n, r, i, a) {
|
|
|
1678
1696
|
B.length > 0 ? B.shift()(e) : z.push(e);
|
|
1679
1697
|
}
|
|
1680
1698
|
function xe(e) {
|
|
1681
|
-
H(
|
|
1699
|
+
H(Ut(e)), V();
|
|
1682
1700
|
}
|
|
1683
1701
|
function U(e) {
|
|
1684
1702
|
H({
|
|
@@ -1718,10 +1736,10 @@ function zt(e, t = {}, n, r, i, a) {
|
|
|
1718
1736
|
throw console.error("Submit function encountered an error:", e), e;
|
|
1719
1737
|
}
|
|
1720
1738
|
}
|
|
1721
|
-
function
|
|
1739
|
+
function Ut(e) {
|
|
1722
1740
|
return { then: (t, n) => n(e) };
|
|
1723
1741
|
}
|
|
1724
|
-
function
|
|
1742
|
+
function Wt(e, t, n, r) {
|
|
1725
1743
|
let i, a, o;
|
|
1726
1744
|
if (typeof t == "number") i = t, a = e.unnamed_endpoints[i], o = r.dependencies.find((e) => e.id == t);
|
|
1727
1745
|
else {
|
|
@@ -1809,7 +1827,7 @@ var $ = class {
|
|
|
1809
1827
|
resolve_config;
|
|
1810
1828
|
resolve_cookies;
|
|
1811
1829
|
constructor(e, t = { events: ["data"] }) {
|
|
1812
|
-
this.app_reference = e, this.deep_link = t.query_params?.deep_link || null, t.events ||= ["data"], k(t), this.options = t, this.current_payload = {}, t.cookies && (this.cookies = t.cookies), this.view_api = be.bind(this), this.upload_files = z.bind(this), this.handle_blob = ke.bind(this), this.post_data = Ne.bind(this), this.submit =
|
|
1830
|
+
this.app_reference = e, this.deep_link = t.query_params?.deep_link || null, t.events ||= ["data"], k(t), this.options = t, this.current_payload = {}, t.cookies && (this.cookies = t.cookies), this.view_api = be.bind(this), this.upload_files = z.bind(this), this.handle_blob = ke.bind(this), this.post_data = Ne.bind(this), this.submit = Ht.bind(this), this.predict = Pe.bind(this), this.open_stream = et.bind(this), this.resolve_config = j.bind(this), this.resolve_cookies = N.bind(this), this.upload = H.bind(this), this.fetch = this.fetch.bind(this), this.handle_space_success = this.handle_space_success.bind(this), this.stream = this.stream.bind(this);
|
|
1813
1831
|
}
|
|
1814
1832
|
async init() {
|
|
1815
1833
|
qe(), this.options.auth && await this.resolve_cookies(), await this._resolve_config().then((e) => e?.config && this._resolve_heartbeat(e.config));
|
|
@@ -1881,7 +1899,7 @@ var $ = class {
|
|
|
1881
1899
|
}
|
|
1882
1900
|
}
|
|
1883
1901
|
async config_success(e) {
|
|
1884
|
-
if (this.config = e, this.api_prefix = e.api_prefix || "", e.run_history === !1 &&
|
|
1902
|
+
if (this.config = e, this.api_prefix = e.api_prefix || "", e.run_history === !1 && Nt({
|
|
1885
1903
|
app_id: e.app_id,
|
|
1886
1904
|
username: e.username
|
|
1887
1905
|
}), this.config.auth_required) return this.prepare_return_obj();
|
|
@@ -1952,11 +1970,11 @@ var $ = class {
|
|
|
1952
1970
|
};
|
|
1953
1971
|
}
|
|
1954
1972
|
};
|
|
1955
|
-
async function
|
|
1973
|
+
async function Gt(e, t = { events: ["data"] }) {
|
|
1956
1974
|
return await $.connect(e, t);
|
|
1957
1975
|
}
|
|
1958
|
-
async function
|
|
1976
|
+
async function Kt(e, t) {
|
|
1959
1977
|
return await $.duplicate(e, t);
|
|
1960
1978
|
}
|
|
1961
1979
|
//#endregion
|
|
1962
|
-
export { $ as Client, U as FileData, ae as MISSING_CREDENTIALS_MSG,
|
|
1980
|
+
export { $ as Client, U as FileData, ae as MISSING_CREDENTIALS_MSG, Lt as apply_run_history_replay, Nt as clear_run_history, Gt as client, It as consume_run_history_replay, Pt as delete_run_history, Kt as duplicate, De as handle_file, Vt as on_run_history_change, Pe as predict, xe as prepare_files, Mt as read_run_history, ut as run_history_url, Ft as stage_run_history_replay, Ht as submit, H as upload, z as upload_files };
|
|
@@ -51,11 +51,37 @@ interface StartRunOptions extends RunHistoryScope {
|
|
|
51
51
|
* slash, so it cannot simply be concatenated with the path.
|
|
52
52
|
*/
|
|
53
53
|
export declare function run_history_url(root: string, api_prefix?: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* The parts of an app config a replayed run writes back into. Kept structural
|
|
56
|
+
* so every entry point — the SPA and the SSR app each carry their own `Config`
|
|
57
|
+
* declaration — can hand its config straight over.
|
|
58
|
+
*/
|
|
59
|
+
export interface ReplayTarget {
|
|
60
|
+
components: {
|
|
61
|
+
id: number;
|
|
62
|
+
type: string;
|
|
63
|
+
props: Record<string, any>;
|
|
64
|
+
}[];
|
|
65
|
+
dependencies: {
|
|
66
|
+
id: number;
|
|
67
|
+
api_name?: string | null;
|
|
68
|
+
inputs: number[];
|
|
69
|
+
outputs: number[];
|
|
70
|
+
}[];
|
|
71
|
+
}
|
|
54
72
|
export declare function read_run_history(scope: RunHistoryScope | null | undefined): StoredRun[];
|
|
55
73
|
export declare function clear_run_history(scope: RunHistoryScope | null | undefined): void;
|
|
56
74
|
export declare function delete_run_history(scope: RunHistoryScope | null | undefined, id: string): void;
|
|
57
75
|
export declare function stage_run_history_replay(scope: RunHistoryScope | null | undefined, run: StoredRun): void;
|
|
58
76
|
export declare function consume_run_history_replay(scope: RunHistoryScope | null | undefined): StoredRun | null;
|
|
77
|
+
/**
|
|
78
|
+
* Applies the run staged by the history page, if this page load is the one it
|
|
79
|
+
* was staged for. Every entry point that renders an app has to call this, or
|
|
80
|
+
* "Load run" silently does nothing on that entry point.
|
|
81
|
+
*
|
|
82
|
+
* @returns whether a staged run was found and applied.
|
|
83
|
+
*/
|
|
84
|
+
export declare function apply_run_history_replay(config: ReplayTarget & RunHistoryScope): boolean;
|
|
59
85
|
export declare function start_run_history(options: StartRunOptions): string | null;
|
|
60
86
|
export declare function update_run_inputs(scope: RunHistoryScope | null | undefined, id: string | null, inputs: unknown): void;
|
|
61
87
|
export declare function update_run_history(scope: RunHistoryScope | null | undefined, id: string | null, event: GradioEvent): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run_history.d.ts","sourceRoot":"","sources":["../../src/utils/run_history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,UAAU,CAAC;AAgB3D,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAgBD,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EA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,CACvC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,EACzC,GAAG,EAAE,SAAS,GACZ,IAAI,CAEN;AAED,wBAAgB,0BAA0B,CACzC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,GACvC,SAAS,GAAG,IAAI,CAElB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,YAAY,GAAG,eAAe,GACpC,OAAO,CAET;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAEzE;AAED,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,EACzC,EAAE,EAAE,MAAM,GAAG,IAAI,EACjB,MAAM,EAAE,OAAO,GACb,IAAI,CAEN;AAED,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,EACzC,EAAE,EAAE,MAAM,GAAG,IAAI,EACjB,KAAK,EAAE,WAAW,GAChB,IAAI,CAEN;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAKtE"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { upload_files } from "./utils/upload_files";
|
|
|
6
6
|
export { FileData, upload, prepare_files } from "./upload";
|
|
7
7
|
export { handle_file } from "./helpers/data";
|
|
8
8
|
export {
|
|
9
|
+
apply_run_history_replay,
|
|
9
10
|
clear_run_history,
|
|
10
11
|
consume_run_history_replay,
|
|
11
12
|
delete_run_history,
|
|
@@ -13,6 +14,7 @@ export {
|
|
|
13
14
|
read_run_history,
|
|
14
15
|
run_history_url,
|
|
15
16
|
stage_run_history_replay,
|
|
17
|
+
type ReplayTarget,
|
|
16
18
|
type RunHistoryScope,
|
|
17
19
|
type StoredRunComponent,
|
|
18
20
|
type StoredRun
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
apply_run_history_replay,
|
|
4
5
|
clear_run_history,
|
|
5
6
|
consume_run_history_replay,
|
|
6
7
|
delete_run_history,
|
|
@@ -314,6 +315,72 @@ describe.skipIf(!in_browser)("run history", () => {
|
|
|
314
315
|
});
|
|
315
316
|
});
|
|
316
317
|
|
|
318
|
+
describe.skipIf(!in_browser)("replaying a run", () => {
|
|
319
|
+
function make_config() {
|
|
320
|
+
return {
|
|
321
|
+
app_id,
|
|
322
|
+
components: [
|
|
323
|
+
{ id: 1, type: "textbox", props: { value: "default in" } },
|
|
324
|
+
{ id: 2, type: "state", props: { value: "server side" } },
|
|
325
|
+
{ id: 3, type: "image", props: { value: null } },
|
|
326
|
+
{ id: 4, type: "textbox", props: { value: "default out" } }
|
|
327
|
+
],
|
|
328
|
+
dependencies: [
|
|
329
|
+
{ id: 7, api_name: "transform", inputs: [1, 2], outputs: [3, 4] }
|
|
330
|
+
]
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const stored = {
|
|
335
|
+
id: "run-1",
|
|
336
|
+
endpoint: "/transform",
|
|
337
|
+
api_name: "/transform",
|
|
338
|
+
fn_index: 7,
|
|
339
|
+
page: "/",
|
|
340
|
+
inputs: ["prompt", null],
|
|
341
|
+
outputs: [{ url: "http://localhost/image.webp" }, "described"],
|
|
342
|
+
status: "completed" as const,
|
|
343
|
+
started_at: new Date().toISOString()
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
test("writes the saved inputs and outputs back into the config", () => {
|
|
347
|
+
stage_run_history_replay(scope, stored);
|
|
348
|
+
const config = make_config();
|
|
349
|
+
|
|
350
|
+
expect(apply_run_history_replay(config)).toBe(true);
|
|
351
|
+
expect(config.components.map((component) => component.props.value)).toEqual(
|
|
352
|
+
["prompt", "server side", stored.outputs[0], "described"]
|
|
353
|
+
);
|
|
354
|
+
expect(apply_run_history_replay(make_config())).toBe(false);
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
test("matches the endpoint by api name when the fn index has moved", () => {
|
|
358
|
+
stage_run_history_replay(scope, { ...stored, fn_index: 99 });
|
|
359
|
+
const config = make_config();
|
|
360
|
+
|
|
361
|
+
expect(apply_run_history_replay(config)).toBe(true);
|
|
362
|
+
expect(config.components[3].props.value).toBe("described");
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
test("leaves the config alone when the endpoint is gone", () => {
|
|
366
|
+
stage_run_history_replay(scope, {
|
|
367
|
+
...stored,
|
|
368
|
+
fn_index: 99,
|
|
369
|
+
api_name: "/removed"
|
|
370
|
+
});
|
|
371
|
+
const config = make_config();
|
|
372
|
+
|
|
373
|
+
expect(apply_run_history_replay(config)).toBe(false);
|
|
374
|
+
expect(config.components.map((component) => component.props.value)).toEqual(
|
|
375
|
+
["default in", "server side", null, "default out"]
|
|
376
|
+
);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
test("is a no-op when nothing was staged", () => {
|
|
380
|
+
expect(apply_run_history_replay(make_config())).toBe(false);
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
|
|
317
384
|
describe("run history url", () => {
|
|
318
385
|
test("joins the app root and the api prefix", () => {
|
|
319
386
|
expect(run_history_url("http://localhost:7860")).toBe(
|
package/src/utils/run_history.ts
CHANGED
|
@@ -308,6 +308,62 @@ function consume_run_history_replay_impl(
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
+
/**
|
|
312
|
+
* The parts of an app config a replayed run writes back into. Kept structural
|
|
313
|
+
* so every entry point — the SPA and the SSR app each carry their own `Config`
|
|
314
|
+
* declaration — can hand its config straight over.
|
|
315
|
+
*/
|
|
316
|
+
export interface ReplayTarget {
|
|
317
|
+
components: { id: number; type: string; props: Record<string, any> }[];
|
|
318
|
+
dependencies: {
|
|
319
|
+
id: number;
|
|
320
|
+
api_name?: string | null;
|
|
321
|
+
inputs: number[];
|
|
322
|
+
outputs: number[];
|
|
323
|
+
}[];
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function restore_run_impl(config: ReplayTarget, run: StoredRun): boolean {
|
|
327
|
+
const dependency = config.dependencies.find(
|
|
328
|
+
(item) =>
|
|
329
|
+
item.id === run.fn_index ||
|
|
330
|
+
(typeof item.api_name === "string" &&
|
|
331
|
+
`/${item.api_name.replace(/^\//, "")}` === run.api_name)
|
|
332
|
+
);
|
|
333
|
+
if (!dependency) return false;
|
|
334
|
+
|
|
335
|
+
const inputs = Array.isArray(run.inputs)
|
|
336
|
+
? run.inputs
|
|
337
|
+
: Object.values((run.inputs ?? {}) as Record<string, unknown>);
|
|
338
|
+
const outputs = Array.isArray(run.outputs)
|
|
339
|
+
? run.outputs
|
|
340
|
+
: run.outputs === null || run.outputs === undefined
|
|
341
|
+
? []
|
|
342
|
+
: [run.outputs];
|
|
343
|
+
|
|
344
|
+
const restore = (ids: number[], saved: unknown[]): void => {
|
|
345
|
+
for (const [index, id] of ids.entries()) {
|
|
346
|
+
const component = config.components.find((item) => item.id === id);
|
|
347
|
+
if (!component || index >= saved.length) continue;
|
|
348
|
+
// `gr.State` is held on the server and always saved as null, so
|
|
349
|
+
// writing it back would wipe out the component's real default.
|
|
350
|
+
if (component.type === "state") continue;
|
|
351
|
+
component.props.value = saved[index];
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
restore(dependency.inputs, inputs);
|
|
356
|
+
restore(dependency.outputs, outputs);
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function apply_run_history_replay_impl(
|
|
361
|
+
config: ReplayTarget & RunHistoryScope
|
|
362
|
+
): boolean {
|
|
363
|
+
const run = consume_run_history_replay_impl(config);
|
|
364
|
+
return run ? restore_run_impl(config, run) : false;
|
|
365
|
+
}
|
|
366
|
+
|
|
311
367
|
function start_run_history_impl(options: StartRunOptions): string | null {
|
|
312
368
|
const key = storage_key(options);
|
|
313
369
|
if (!key) return null;
|
|
@@ -492,6 +548,19 @@ export function consume_run_history_replay(
|
|
|
492
548
|
return safely(() => consume_run_history_replay_impl(scope), null);
|
|
493
549
|
}
|
|
494
550
|
|
|
551
|
+
/**
|
|
552
|
+
* Applies the run staged by the history page, if this page load is the one it
|
|
553
|
+
* was staged for. Every entry point that renders an app has to call this, or
|
|
554
|
+
* "Load run" silently does nothing on that entry point.
|
|
555
|
+
*
|
|
556
|
+
* @returns whether a staged run was found and applied.
|
|
557
|
+
*/
|
|
558
|
+
export function apply_run_history_replay(
|
|
559
|
+
config: ReplayTarget & RunHistoryScope
|
|
560
|
+
): boolean {
|
|
561
|
+
return safely(() => apply_run_history_replay_impl(config), false);
|
|
562
|
+
}
|
|
563
|
+
|
|
495
564
|
export function start_run_history(options: StartRunOptions): string | null {
|
|
496
565
|
return safely(() => start_run_history_impl(options), null);
|
|
497
566
|
}
|