Upload folder using huggingface_hub
Browse files- 6.0.1/preview/package.json +2 -2
- 6.0.1/preview/src/build.ts +12 -6
- 6.0.1/preview/src/dev.ts +13 -8
- 6.0.1/preview/src/plugins.ts +34 -27
6.0.1/preview/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/preview",
|
| 3 |
-
"version": "0.15.
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"main": "dist/index.js",
|
|
@@ -54,4 +54,4 @@
|
|
| 54 |
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 55 |
"directory": "js/preview"
|
| 56 |
}
|
| 57 |
-
}
|
|
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/preview",
|
| 3 |
+
"version": "0.15.1",
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"main": "dist/index.js",
|
|
|
|
| 54 |
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 55 |
"directory": "js/preview"
|
| 56 |
}
|
| 57 |
+
}
|
6.0.1/preview/src/build.ts
CHANGED
|
@@ -41,7 +41,9 @@ export async function make_build({
|
|
| 41 |
build: {
|
| 42 |
target: []
|
| 43 |
},
|
| 44 |
-
optimizeDeps: {
|
|
|
|
|
|
|
| 45 |
};
|
| 46 |
|
| 47 |
if (
|
|
@@ -55,7 +57,8 @@ export async function make_build({
|
|
| 55 |
component_config.plugins = m.default.plugins || [];
|
| 56 |
component_config.svelte.preprocess = m.default.svelte?.preprocess || [];
|
| 57 |
component_config.build.target = m.default.build?.target || "modules";
|
| 58 |
-
component_config.optimizeDeps =
|
|
|
|
| 59 |
}
|
| 60 |
|
| 61 |
const exports: (string | any)[][] = [
|
|
@@ -73,11 +76,7 @@ export async function make_build({
|
|
| 73 |
make_gradio_plugin({ mode: "build", svelte_dir }),
|
| 74 |
deepmerge_plugin
|
| 75 |
],
|
| 76 |
-
resolve: {
|
| 77 |
-
conditions: ["gradio"]
|
| 78 |
-
},
|
| 79 |
build: {
|
| 80 |
-
target: component_config.build.target,
|
| 81 |
emptyOutDir: true,
|
| 82 |
outDir: join(template_dir, entry as string),
|
| 83 |
lib: {
|
|
@@ -88,6 +87,13 @@ export async function make_build({
|
|
| 88 |
minify: true,
|
| 89 |
rollupOptions: {
|
| 90 |
output: {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
entryFileNames: (chunkInfo: PreRenderedChunk) => {
|
| 92 |
if (chunkInfo.isEntry) {
|
| 93 |
return "index.js";
|
|
|
|
| 41 |
build: {
|
| 42 |
target: []
|
| 43 |
},
|
| 44 |
+
optimizeDeps: {
|
| 45 |
+
exclude: ["svelte", "svelte/*"]
|
| 46 |
+
}
|
| 47 |
};
|
| 48 |
|
| 49 |
if (
|
|
|
|
| 57 |
component_config.plugins = m.default.plugins || [];
|
| 58 |
component_config.svelte.preprocess = m.default.svelte?.preprocess || [];
|
| 59 |
component_config.build.target = m.default.build?.target || "modules";
|
| 60 |
+
component_config.optimizeDeps =
|
| 61 |
+
m.default.optimizeDeps || component_config.optimizeDeps;
|
| 62 |
}
|
| 63 |
|
| 64 |
const exports: (string | any)[][] = [
|
|
|
|
| 76 |
make_gradio_plugin({ mode: "build", svelte_dir }),
|
| 77 |
deepmerge_plugin
|
| 78 |
],
|
|
|
|
|
|
|
|
|
|
| 79 |
build: {
|
|
|
|
| 80 |
emptyOutDir: true,
|
| 81 |
outDir: join(template_dir, entry as string),
|
| 82 |
lib: {
|
|
|
|
| 87 |
minify: true,
|
| 88 |
rollupOptions: {
|
| 89 |
output: {
|
| 90 |
+
assetFileNames: (chunkInfo) => {
|
| 91 |
+
if (chunkInfo.names[0].endsWith(".css")) {
|
| 92 |
+
return `style.css`;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
return chunkInfo.names[0];
|
| 96 |
+
},
|
| 97 |
entryFileNames: (chunkInfo: PreRenderedChunk) => {
|
| 98 |
if (chunkInfo.isEntry) {
|
| 99 |
return "index.js";
|
6.0.1/preview/src/dev.ts
CHANGED
|
@@ -18,6 +18,13 @@ logger.warn = (msg, options) => {
|
|
| 18 |
originalWarning(msg, options);
|
| 19 |
};
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
interface ServerOptions {
|
| 22 |
component_dir: string;
|
| 23 |
root_dir: string;
|
|
@@ -57,13 +64,8 @@ export async function create_server({
|
|
| 57 |
allow: [root_dir, component_dir]
|
| 58 |
}
|
| 59 |
},
|
| 60 |
-
resolve: {
|
| 61 |
-
conditions: ["gradio"]
|
| 62 |
-
},
|
| 63 |
-
build: {
|
| 64 |
-
target: config.build.target
|
| 65 |
-
},
|
| 66 |
optimizeDeps: config.optimizeDeps,
|
|
|
|
| 67 |
plugins: [
|
| 68 |
...plugins(config),
|
| 69 |
make_gradio_plugin({
|
|
@@ -154,7 +156,9 @@ async function generate_imports(
|
|
| 154 |
build: {
|
| 155 |
target: []
|
| 156 |
},
|
| 157 |
-
optimizeDeps: {
|
|
|
|
|
|
|
| 158 |
};
|
| 159 |
|
| 160 |
await Promise.all(
|
|
@@ -170,7 +174,8 @@ async function generate_imports(
|
|
| 170 |
component_config.plugins = m.default.plugins || [];
|
| 171 |
component_config.svelte.preprocess = m.default.svelte?.preprocess || [];
|
| 172 |
component_config.build.target = m.default.build?.target || "modules";
|
| 173 |
-
component_config.optimizeDeps =
|
|
|
|
| 174 |
} else {
|
| 175 |
}
|
| 176 |
})
|
|
|
|
| 18 |
originalWarning(msg, options);
|
| 19 |
};
|
| 20 |
|
| 21 |
+
const originalError = logger.error;
|
| 22 |
+
|
| 23 |
+
logger.error = (msg, options) => {
|
| 24 |
+
if (msg && msg.includes("Pre-transform error")) return;
|
| 25 |
+
originalError(msg, options);
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
interface ServerOptions {
|
| 29 |
component_dir: string;
|
| 30 |
root_dir: string;
|
|
|
|
| 64 |
allow: [root_dir, component_dir]
|
| 65 |
}
|
| 66 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
optimizeDeps: config.optimizeDeps,
|
| 68 |
+
cacheDir: join(component_dir, "frontend", "node_modules", ".vite"),
|
| 69 |
plugins: [
|
| 70 |
...plugins(config),
|
| 71 |
make_gradio_plugin({
|
|
|
|
| 156 |
build: {
|
| 157 |
target: []
|
| 158 |
},
|
| 159 |
+
optimizeDeps: {
|
| 160 |
+
exclude: ["svelte", "svelte/*"]
|
| 161 |
+
}
|
| 162 |
};
|
| 163 |
|
| 164 |
await Promise.all(
|
|
|
|
| 174 |
component_config.plugins = m.default.plugins || [];
|
| 175 |
component_config.svelte.preprocess = m.default.svelte?.preprocess || [];
|
| 176 |
component_config.build.target = m.default.build?.target || "modules";
|
| 177 |
+
component_config.optimizeDeps =
|
| 178 |
+
m.default.optimizeDeps || component_config.optimizeDeps;
|
| 179 |
} else {
|
| 180 |
}
|
| 181 |
})
|
6.0.1/preview/src/plugins.ts
CHANGED
|
@@ -43,10 +43,9 @@ export function plugins(config: ComponentConfig): PluginOption[] {
|
|
| 43 |
handler!(warning);
|
| 44 |
},
|
| 45 |
prebundleSvelteLibraries: false,
|
| 46 |
-
hot: true,
|
| 47 |
compilerOptions: {
|
| 48 |
discloseVersion: false,
|
| 49 |
-
|
| 50 |
},
|
| 51 |
extensions: _svelte_extensions,
|
| 52 |
preprocess: [
|
|
@@ -83,35 +82,24 @@ export function make_gradio_plugin({
|
|
| 83 |
return {
|
| 84 |
name: "gradio",
|
| 85 |
enforce: "pre",
|
| 86 |
-
transform(code) {
|
| 87 |
-
const new_code = code.replace(RE_SVELTE_IMPORT, (str, $1, $2) => {
|
| 88 |
-
if ($1.trim().startsWith("type")) return str;
|
| 89 |
-
if ($1.trim() === "") return "";
|
| 90 |
-
const path = $2.split("/").join("_");
|
| 91 |
-
const identifier = $1.trim().startsWith("* as")
|
| 92 |
-
? $1.replace("* as", "").trim()
|
| 93 |
-
: $1.trim();
|
| 94 |
-
return `const ${identifier.replace(
|
| 95 |
-
" as ",
|
| 96 |
-
": "
|
| 97 |
-
)} = window.__gradio__svelte__.${path};`;
|
| 98 |
-
});
|
| 99 |
-
|
| 100 |
-
return {
|
| 101 |
-
code: new_code,
|
| 102 |
-
map: null
|
| 103 |
-
};
|
| 104 |
-
},
|
| 105 |
resolveId(id) {
|
| 106 |
if (id === v_id) {
|
| 107 |
return resolved_v_id;
|
| 108 |
}
|
| 109 |
-
if (
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
}
|
| 116 |
},
|
| 117 |
load(id) {
|
|
@@ -148,3 +136,22 @@ export const deepmerge_plugin: Plugin = {
|
|
| 148 |
}
|
| 149 |
}
|
| 150 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
handler!(warning);
|
| 44 |
},
|
| 45 |
prebundleSvelteLibraries: false,
|
|
|
|
| 46 |
compilerOptions: {
|
| 47 |
discloseVersion: false,
|
| 48 |
+
hmr: true
|
| 49 |
},
|
| 50 |
extensions: _svelte_extensions,
|
| 51 |
preprocess: [
|
|
|
|
| 82 |
return {
|
| 83 |
name: "gradio",
|
| 84 |
enforce: "pre",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
resolveId(id) {
|
| 86 |
if (id === v_id) {
|
| 87 |
return resolved_v_id;
|
| 88 |
}
|
| 89 |
+
if (id === "svelte") {
|
| 90 |
+
return {
|
| 91 |
+
id: `../../../../../assets/svelte/svelte_svelte.js`,
|
| 92 |
+
external: true
|
| 93 |
+
};
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
if (id.startsWith("svelte/")) {
|
| 97 |
+
const subpath = id.slice("svelte/".length);
|
| 98 |
+
|
| 99 |
+
return {
|
| 100 |
+
id: `../../../../../assets/svelte/svelte_${subpath.replace(/\//g, "_")}.js`,
|
| 101 |
+
external: true
|
| 102 |
+
};
|
| 103 |
}
|
| 104 |
},
|
| 105 |
load(id) {
|
|
|
|
| 136 |
}
|
| 137 |
}
|
| 138 |
};
|
| 139 |
+
|
| 140 |
+
function extract_types(str: string): string[] {
|
| 141 |
+
const regex = /type (\w+\b)/g;
|
| 142 |
+
let m;
|
| 143 |
+
const out = [];
|
| 144 |
+
while ((m = regex.exec(str))) out.push(m[1]);
|
| 145 |
+
|
| 146 |
+
return out;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
function remove_types(input: string): string {
|
| 150 |
+
const inner = input.slice(1, -1); // remove { }
|
| 151 |
+
const parts = inner
|
| 152 |
+
.split(",")
|
| 153 |
+
.map((s) => s.trim())
|
| 154 |
+
.filter((s) => s && !/^type\s+\w+\b$/.test(s));
|
| 155 |
+
|
| 156 |
+
return `{ ${parts.join(", ")} }`;
|
| 157 |
+
}
|