Upload folder using huggingface_hub
Browse files
6.0.0-dev.5/preview/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/preview",
|
| 3 |
-
"version": "0.
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"main": "dist/index.js",
|
|
@@ -17,7 +17,8 @@
|
|
| 17 |
"@rollup/plugin-json": "^6.1.0",
|
| 18 |
"@rollup/plugin-node-resolve": "^16.0.2",
|
| 19 |
"@rollup/plugin-typescript": "^12.1.4",
|
| 20 |
-
"rollup": "^4.52.4"
|
|
|
|
| 21 |
},
|
| 22 |
"dependencies": {
|
| 23 |
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
@@ -38,9 +39,6 @@
|
|
| 38 |
"which": "5.0.0",
|
| 39 |
"yootils": "^0.3.1"
|
| 40 |
},
|
| 41 |
-
"optionalDependencies": {
|
| 42 |
-
"svelte": "^5.43.4"
|
| 43 |
-
},
|
| 44 |
"exports": {
|
| 45 |
".": {
|
| 46 |
"default": "./dist/index.js",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/preview",
|
| 3 |
+
"version": "0.15.0-dev.0",
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"main": "dist/index.js",
|
|
|
|
| 17 |
"@rollup/plugin-json": "^6.1.0",
|
| 18 |
"@rollup/plugin-node-resolve": "^16.0.2",
|
| 19 |
"@rollup/plugin-typescript": "^12.1.4",
|
| 20 |
+
"rollup": "^4.52.4",
|
| 21 |
+
"svelte": "^5.43.4"
|
| 22 |
},
|
| 23 |
"dependencies": {
|
| 24 |
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
|
|
| 39 |
"which": "5.0.0",
|
| 40 |
"yootils": "^0.3.1"
|
| 41 |
},
|
|
|
|
|
|
|
|
|
|
| 42 |
"exports": {
|
| 43 |
".": {
|
| 44 |
"default": "./dist/index.js",
|
6.0.0-dev.5/preview/src/plugins.ts
CHANGED
|
@@ -11,8 +11,8 @@ const svelte_codes_to_ignore: Record<string, string> = {
|
|
| 11 |
};
|
| 12 |
|
| 13 |
const RE_SVELTE_IMPORT =
|
| 14 |
-
/import\s+([
|
| 15 |
-
const RE_BARE_SVELTE_IMPORT = /import ("|')svelte(\/\w+)*("|')(;)*/g;
|
| 16 |
export function plugins(config: ComponentConfig): PluginOption[] {
|
| 17 |
const _additional_plugins = config.plugins || [];
|
| 18 |
const _additional_svelte_preprocess = config.svelte?.preprocess || [];
|
|
@@ -84,18 +84,19 @@ export function make_gradio_plugin({
|
|
| 84 |
name: "gradio",
|
| 85 |
enforce: "pre",
|
| 86 |
transform(code) {
|
| 87 |
-
const new_code = code
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
}
|
| 98 |
-
|
|
|
|
| 99 |
return {
|
| 100 |
code: new_code,
|
| 101 |
map: null
|
|
|
|
| 11 |
};
|
| 12 |
|
| 13 |
const RE_SVELTE_IMPORT =
|
| 14 |
+
/import\s+(?:([ -~]*)\s+from\s+){0,1}['"](svelte(?:\/[ -~]+){0,3})['"]/g;
|
| 15 |
+
// const RE_BARE_SVELTE_IMPORT = /import ("|')svelte(\/\w+)*("|')(;)*/g;
|
| 16 |
export function plugins(config: ComponentConfig): PluginOption[] {
|
| 17 |
const _additional_plugins = config.plugins || [];
|
| 18 |
const _additional_svelte_preprocess = config.svelte?.preprocess || [];
|
|
|
|
| 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
|