mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-15 02:11:15 +08:00
Remove a bunch of unused frontend code (#4275)
Co-authored-by: pngwn <hello@pngwn.io>
This commit is contained in:
parent
0dbd8f7fee
commit
0a6a80ce02
@ -6,7 +6,7 @@
|
||||
|
||||
## Bug Fixes:
|
||||
|
||||
No changes to highlight.
|
||||
- Remove unused frontend code by [@akx](https://github.com/akx) in [PR 4275](https://github.com/gradio-app/gradio/pull/4275)
|
||||
|
||||
## Other Changes:
|
||||
|
||||
@ -37,7 +37,6 @@ No changes to highlight.
|
||||
- Relocate `mount_css` fn to remove circular dependency [@whitphx](https://github.com/whitphx) in [PR 4222](https://github.com/gradio-app/gradio/pull/4222)
|
||||
- Upgrade Black to 23.3 by [@akx](https://github.com/akx) in [PR 4259](https://github.com/gradio-app/gradio/pull/4259)
|
||||
- Add frontend LaTeX support in `gr.Chatbot()` using `KaTeX` by [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 4285](https://github.com/gradio-app/gradio/pull/4285).
|
||||
- `Interface.launch()` and `Blocks.launch()` now accept an `app_kwargs` argument to allow customizing the configuration of the underlying FastAPI app, by [@akx](https://github.com/akx) in [PR 4282](https://github.com/gradio-app/gradio/pull/4282)
|
||||
|
||||
## Breaking Changes:
|
||||
|
||||
|
@ -19,11 +19,6 @@
|
||||
|
||||
export let named: boolean;
|
||||
export let current_language: "python" | "javascript";
|
||||
|
||||
const format_url = (desc: string | undefined, data: string | undefined) =>
|
||||
desc
|
||||
?.replace("{ROOT}", root)
|
||||
?.replace("{name}", data ? JSON.parse(`${data}`)?.name : "{name}");
|
||||
</script>
|
||||
|
||||
<h4>
|
||||
|
@ -1,94 +0,0 @@
|
||||
import type { FileData } from "@gradio/upload";
|
||||
|
||||
interface XYValue {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
interface ObjectValue {
|
||||
values: XYValue[];
|
||||
}
|
||||
|
||||
export function get_domains(
|
||||
values: ObjectValue[] | { values: number[] }
|
||||
): [number, number] {
|
||||
let _vs: number[];
|
||||
if (Array.isArray(values)) {
|
||||
_vs = values.reduce<number[]>((acc, { values }) => {
|
||||
return [...acc, ...values.map(({ x, y }) => y)];
|
||||
}, []);
|
||||
} else {
|
||||
_vs = values.values;
|
||||
}
|
||||
return [Math.min(..._vs), Math.max(..._vs)];
|
||||
}
|
||||
|
||||
interface Row {
|
||||
name: string;
|
||||
values: number[];
|
||||
}
|
||||
|
||||
interface RowPoint {
|
||||
name: string;
|
||||
values: Array<{ x: number; y: number }>;
|
||||
}
|
||||
|
||||
interface TransformedValues {
|
||||
x: Row;
|
||||
y: Array<RowPoint>;
|
||||
}
|
||||
|
||||
export function transform_values(
|
||||
values: Array<Record<string, string>>,
|
||||
x?: string,
|
||||
y?: string[]
|
||||
) {
|
||||
const transformed_values = Object.entries(
|
||||
values[0]
|
||||
).reduce<TransformedValues>(
|
||||
(acc, next, i) => {
|
||||
if ((!x && i === 0) || (x && next[0] === x)) {
|
||||
acc.x.name = next[0];
|
||||
} else if (!y || (y && y.includes(next[0]))) {
|
||||
acc.y.push({ name: next[0], values: [] });
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{ x: { name: "", values: [] }, y: [] }
|
||||
);
|
||||
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
const _a = Object.entries(values[i]);
|
||||
for (let j = 0; j < _a.length; j++) {
|
||||
let [name, x] = _a[j];
|
||||
if (name === transformed_values.x.name) {
|
||||
transformed_values.x.values.push(parseInt(x, 10));
|
||||
} else {
|
||||
transformed_values.y[j - 1].values.push({
|
||||
y: parseInt(_a[j][1], 10),
|
||||
x: parseInt(_a[0][1], 10)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return transformed_values;
|
||||
}
|
||||
|
||||
let c = 0;
|
||||
export function get_color(): string {
|
||||
let default_colors = [
|
||||
[255, 99, 132],
|
||||
[54, 162, 235],
|
||||
[240, 176, 26],
|
||||
[153, 102, 255],
|
||||
[75, 192, 192],
|
||||
[255, 159, 64]
|
||||
];
|
||||
|
||||
if (c >= default_colors.length) c = 0;
|
||||
|
||||
const [r, g, b] = default_colors[c++];
|
||||
|
||||
return `rgb(${r},${g},${b})`;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
export const debounce = (callback: Function, wait = 250) => {
|
||||
let timeout: NodeJS.Timeout | null = null;
|
||||
return (...args: Array<unknown>) => {
|
||||
const next = () => callback(...args);
|
||||
if (timeout) clearTimeout(timeout);
|
||||
|
||||
timeout = setTimeout(next, wait);
|
||||
};
|
||||
};
|
@ -1,14 +1,3 @@
|
||||
export const prettyBytes = (bytes: number): string => {
|
||||
let units = ["B", "KB", "MB", "GB", "PB"];
|
||||
let i = 0;
|
||||
while (bytes > 1024) {
|
||||
bytes /= 1024;
|
||||
i++;
|
||||
}
|
||||
let unit = units[i];
|
||||
return bytes.toFixed(1) + " " + unit;
|
||||
};
|
||||
|
||||
export const playable = (): boolean => {
|
||||
// let video_element = document.createElement("video");
|
||||
// let mime_type = mime.lookup(filename);
|
||||
|
@ -1,3 +0,0 @@
|
||||
export function randInt(min: number, max: number): number {
|
||||
return Math.floor(Math.random() * (max - min) + min);
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
import type { FileData } from "@gradio/upload";
|
||||
|
||||
export const prettyBytes = (bytes: number): string => {
|
||||
let units = ["B", "KB", "MB", "GB", "PB"];
|
||||
let i = 0;
|
||||
while (bytes > 1024) {
|
||||
bytes /= 1024;
|
||||
i++;
|
||||
}
|
||||
let unit = units[i];
|
||||
return bytes.toFixed(1) + " " + unit;
|
||||
};
|
||||
|
||||
export const display_file_name = (value: FileData): string => {
|
||||
var str: string;
|
||||
str = value.orig_name || value.name;
|
||||
if (str.length > 30) {
|
||||
return `${str.substr(0, 30)}...`;
|
||||
} else return str;
|
||||
};
|
||||
|
||||
export const display_file_size = (
|
||||
value: FileData | Array<FileData>
|
||||
): string => {
|
||||
var total_size = 0;
|
||||
if (Array.isArray(value)) {
|
||||
for (var file of value) {
|
||||
if (file.size !== undefined) total_size += file.size;
|
||||
}
|
||||
} else {
|
||||
total_size = value.size || 0;
|
||||
}
|
||||
return prettyBytes(total_size);
|
||||
};
|
@ -151,9 +151,6 @@
|
||||
let plugin_scripts = [];
|
||||
|
||||
const resolves = [];
|
||||
const bokehPromises = Array(5)
|
||||
.fill(0)
|
||||
.map((_, i) => createPromise(i));
|
||||
|
||||
const initializeBokeh = (index) => {
|
||||
if (type == "bokeh") {
|
||||
|
@ -1,13 +1,3 @@
|
||||
export const debounce = (callback: Function, wait = 250) => {
|
||||
let timeout: NodeJS.Timeout | null = null;
|
||||
return (...args: Array<unknown>) => {
|
||||
const next = () => callback(...args);
|
||||
if (timeout) clearTimeout(timeout);
|
||||
|
||||
timeout = setTimeout(next, wait);
|
||||
};
|
||||
};
|
||||
|
||||
export interface SelectData {
|
||||
index: number | [number, number];
|
||||
value: any;
|
||||
|
Loading…
Reference in New Issue
Block a user