diff --git a/.changeset/config.json b/.changeset/config.json index d2ba85f6bb..d3179effbd 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -7,5 +7,5 @@ "access": "public", "baseBranch": "main", "updateInternalDependencies": "patch", - "ignore": ["@gradio/spaces-test", "@gradio/cdn-test"] + "ignore": ["@self/spaces-test", "@self/cdn-test"] } diff --git a/.changeset/plenty-cycles-chew.md b/.changeset/plenty-cycles-chew.md new file mode 100644 index 0000000000..efbd9d6c3d --- /dev/null +++ b/.changeset/plenty-cycles-chew.md @@ -0,0 +1,71 @@ +--- +"@gradio/multimodaltextbox": patch +"@gradio/highlightedtext": patch +"@gradio/annotatedimage": patch +"@self/component-test": patch +"@gradio/downloadbutton": patch +"@gradio/simpledropdown": patch +"@gradio/checkboxgroup": patch +"@gradio/simpletextbox": patch +"@gradio/statustracker": patch +"@gradio/fileexplorer": patch +"@gradio/uploadbutton": patch +"@gradio/colorpicker": patch +"@gradio/imageeditor": patch +"@gradio/paramviewer": patch +"@gradio/simpleimage": patch +"@gradio/nativeplot": patch +"@gradio/accordion": patch +"@gradio/dataframe": patch +"@self/storybook": patch +"website": patch +"@gradio/checkbox": patch +"@gradio/datetime": patch +"@gradio/dropdown": patch +"@gradio/fallback": patch +"@gradio/markdown": patch +"@gradio/chatbot": patch +"@gradio/dataset": patch +"@gradio/gallery": patch +"@gradio/model3d": patch +"@gradio/preview": patch +"@gradio/tabitem": patch +"@gradio/textbox": patch +"@gradio/tooltip": patch +"@self/tootils": patch +"@gradio/client": patch +"@gradio/button": patch +"@gradio/column": patch +"@gradio/number": patch +"@gradio/slider": patch +"@gradio/upload": patch +"@gradio/atoms": patch +"@gradio/audio": patch +"@self/build": patch +"@gradio/group": patch +"@gradio/icons": patch +"@gradio/image": patch +"@gradio/label": patch +"@gradio/radio": patch +"@gradio/state": patch +"@gradio/theme": patch +"@gradio/timer": patch +"@gradio/utils": patch +"@gradio/video": patch +"@gradio/code": patch +"@gradio/core": patch +"@gradio/file": patch +"@gradio/form": patch +"@gradio/html": patch +"@gradio/json": patch +"@gradio/lite": patch +"@gradio/plot": patch +"@gradio/tabs": patch +"@gradio/wasm": patch +"@self/app": patch +"@gradio/box": patch +"@gradio/row": patch +"@self/spa": patch +--- + +fix:fix exports and generate types diff --git a/.config/.prettierignore b/.config/.prettierignore index aeb550d7b8..f45be57177 100644 --- a/.config/.prettierignore +++ b/.config/.prettierignore @@ -5,7 +5,7 @@ **/js/wasm/dist/** **/js/preview/dist/** **/client/js/dist/** -**/js/lite/dist/** +**/js/*/dist/** **/pnpm-lock.yaml **/js/plot/src/Plot.svelte **/.svelte-kit/** diff --git a/.config/eslint.config.js b/.config/eslint.config.js index 4cd91f66fe..b1fda3c0a5 100644 --- a/.config/eslint.config.js +++ b/.config/eslint.config.js @@ -63,7 +63,7 @@ const { browser, es2021, node } = globals; export default [ { ignores: [ - ".svelte-kit/**/*", + "**/.svelte-kit/**/*", "**/node_modules/**", "**/dist/**", "**/.config/*", @@ -75,7 +75,8 @@ export default [ "**/_website/**/*", "**/_spaces-test/**/*", "**/preview/test/**/*", - "**/component-test/**/*" + "**/component-test/**/*", + "**/js/wasm/src/webworker/**/*" ] }, { diff --git a/.config/svelte.config.js b/.config/svelte.config.js new file mode 100644 index 0000000000..be776c5610 --- /dev/null +++ b/.config/svelte.config.js @@ -0,0 +1,5 @@ +import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; + +export default { + preprocess: vitePreprocess() +}; diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bdb5ff7512..b1148aaacc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -30,6 +30,7 @@ jobs: . venv/bin/activate pip install -U build hatch packaging>=23.2 # packaging>=23.2 is needed to build Lite due to https://github.com/pypa/hatch/issues/1381 pnpm --filter @gradio/client --filter @gradio/lite --filter @gradio/preview build + - name: create and publish versions id: changesets uses: changesets/action@aba318e9165b45b7948c60273e0b72fce0a64eb9 # @v1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 47d8976c17..56c70b5797 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -309,7 +309,7 @@ Verify that you've used the correct filename of your gradio app, and that you're --- -```ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL @gradio/spa@1.0.0 build:local: vite build --mode production:local --emptyOutDir "--emptyOutDir"``` +```ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL @self/spa@1.0.0 build:local: vite build --mode production:local --emptyOutDir "--emptyOutDir"``` Delete `/node_modules` and `pnpm-lock.yaml`: diff --git a/client/js/package.json b/client/js/package.json index bcf8c6b7b0..a52da6d245 100644 --- a/client/js/package.json +++ b/client/js/package.json @@ -8,6 +8,7 @@ "license": "ISC", "exports": { ".": { + "gradio": "./src/index.ts", "import": "./dist/index.js" }, "./package.json": "./package.json" diff --git a/guides/cn/07_other-tutorials/creating-a-new-component.md b/guides/cn/07_other-tutorials/creating-a-new-component.md index 647171907d..2a71b6d4ab 100644 --- a/guides/cn/07_other-tutorials/creating-a-new-component.md +++ b/guides/cn/07_other-tutorials/creating-a-new-component.md @@ -302,7 +302,7 @@ class TestColorPicker(unittest.TestCase): ```typescript import { test, describe, assert, afterEach } from "vitest"; -import { cleanup, render } from "@gradio/tootils"; +import { cleanup, render } from "@self/tootils"; import ColorPicker from "./ColorPicker.svelte"; import type { LoadingStatus } from "../StatusTracker/types"; diff --git a/js/_cdn-test/package.json b/js/_cdn-test/package.json index 3401e2dffa..730e7719e7 100644 --- a/js/_cdn-test/package.json +++ b/js/_cdn-test/package.json @@ -1,5 +1,5 @@ { - "name": "@gradio/cdn-test", + "name": "@self/cdn-test", "private": true, "version": "0.0.1", "scripts": { diff --git a/js/_spaces-test/CHANGELOG.md b/js/_spaces-test/CHANGELOG.md index 1895157941..2759587045 100644 --- a/js/_spaces-test/CHANGELOG.md +++ b/js/_spaces-test/CHANGELOG.md @@ -1,4 +1,4 @@ -# @gradio/spaces-test +# @self/spaces-test ## 0.0.1 diff --git a/js/_spaces-test/package.json b/js/_spaces-test/package.json index 17de8e6920..477f20ea50 100644 --- a/js/_spaces-test/package.json +++ b/js/_spaces-test/package.json @@ -1,5 +1,5 @@ { - "name": "@gradio/spaces-test", + "name": "@self/spaces-test", "version": "0.0.1", "private": true, "scripts": { diff --git a/js/_website/vite.config.ts b/js/_website/vite.config.ts index 14762ec0f6..92f11d6579 100644 --- a/js/_website/vite.config.ts +++ b/js/_website/vite.config.ts @@ -1,8 +1,11 @@ import { sveltekit } from "@sveltejs/kit/vite"; import { defineConfig } from "vite"; -import { inject_component_loader } from "../build/dist/index.js"; +import { inject_component_loader } from "../build/out/index.js"; //@ts-ignore export default defineConfig(({ mode }) => ({ - plugins: [sveltekit(), inject_component_loader({ mode })] + plugins: [sveltekit(), inject_component_loader({ mode })], + resolve: { + conditions: ["gradio"] + } })); diff --git a/js/accordion/package.json b/js/accordion/package.json index 4b9a345006..b2533caaf8 100644 --- a/js/accordion/package.json +++ b/js/accordion/package.json @@ -5,7 +5,6 @@ "type": "module", "author": "", "license": "ISC", - "private": true, "main_changeset": true, "dependencies": { "@gradio/atoms": "workspace:^", @@ -13,11 +12,18 @@ "@gradio/statustracker": "workspace:^", "@gradio/utils": "workspace:0.6.0" }, + "peerDependencies": { + "svelte": "^4.0.0" + }, "devDependencies": { "@gradio/preview": "workspace:^" }, "exports": { - ".": "./Index.svelte", + ".": { + "gradio": "./Index.svelte", + "svelte": "./dist/Index.svelte", + "types": "./dist/Index.svelte.d.ts" + }, "./package.json": "./package.json" }, "repository": { diff --git a/js/annotatedimage/package.json b/js/annotatedimage/package.json index d31995b332..f41aa264e0 100644 --- a/js/annotatedimage/package.json +++ b/js/annotatedimage/package.json @@ -5,15 +5,22 @@ "type": "module", "author": "", "license": "ISC", - "private": true, + "private": false, "main_changeset": true, "exports": { - ".": "./Index.svelte", + ".": { + "gradio": "./Index.svelte", + "svelte": "./dist/Index.svelte", + "types": "./dist/Index.svelte.d.ts" + }, "./package.json": "./package.json" }, "devDependencies": { "@gradio/preview": "workspace:^" }, + "peerDependencies": { + "svelte": "^4.0.0" + }, "dependencies": { "@gradio/atoms": "workspace:^", "@gradio/icons": "workspace:^", diff --git a/js/app/CHANGELOG.md b/js/app/CHANGELOG.md index a95f936749..03700607d0 100644 --- a/js/app/CHANGELOG.md +++ b/js/app/CHANGELOG.md @@ -1,4 +1,4 @@ -# @gradio/app +# @self/app ## 1.40.0 diff --git a/js/app/package.json b/js/app/package.json index 88cea4d90d..cea9a0c72d 100644 --- a/js/app/package.json +++ b/js/app/package.json @@ -1,5 +1,5 @@ { - "name": "@gradio/app", + "name": "@self/app", "version": "1.40.0", "private": true, "scripts": { diff --git a/js/atoms/package.json b/js/atoms/package.json index 1d4f917032..208d6f8bb7 100644 --- a/js/atoms/package.json +++ b/js/atoms/package.json @@ -7,13 +7,27 @@ "author": "", "license": "ISC", "dependencies": { - "@gradio/utils": "workspace:^", - "@gradio/icons": "workspace:^" + "@gradio/icons": "workspace:^", + "@gradio/utils": "workspace:^" + }, + "peerDependencies": { + "svelte": "^4.0.0" + }, + "exports": { + ".": { + "gradio": "./src/index.ts", + "svelte": "./dist/src/index.js", + "types": "./dist/src/index.d.ts" + }, + "./package.json": "./package.json" }, "main_changeset": true, "repository": { "type": "git", "url": "git+https://github.com/gradio-app/gradio.git", "directory": "js/atoms" + }, + "scripts": { + "sv-pkg": "svelte-package --input=. --cwd=../../.config/" } } diff --git a/js/audio/audio.test.ts b/js/audio/audio.test.ts index 810e837ca7..7a3dffbf1d 100644 --- a/js/audio/audio.test.ts +++ b/js/audio/audio.test.ts @@ -1,5 +1,5 @@ import { test, describe, assert, afterEach } from "vitest"; -import { cleanup, render } from "@gradio/tootils"; +import { cleanup, render } from "@self/tootils"; import Audio from "./"; import type { LoadingStatus } from "@gradio/statustracker"; import { setupi18n } from "../core/src/i18n"; diff --git a/js/audio/package.json b/js/audio/package.json index 77a3c35cd8..92496d6568 100644 --- a/js/audio/package.json +++ b/js/audio/package.json @@ -28,11 +28,30 @@ "main_changeset": true, "main": "index.ts", "exports": { - ".": "./index.ts", - "./example": "./Example.svelte", - "./shared": "./shared/index.ts", - "./base": "./static/StaticAudio.svelte", - "./package.json": "./package.json" + "./package.json": "./package.json", + ".": { + "gradio": "./index.ts", + "svelte": "./dist/index.js", + "types": "./dist/index.d.ts" + }, + "./example": { + "gradio": "./Example.svelte", + "svelte": "./dist/Example.svelte", + "types": "./dist/Example.svelte.d.ts" + }, + "./shared": { + "gradio": "./shared/index.ts", + "svelte": "./dist/shared/index.js", + "types": "./dist/shared/index.d.ts" + }, + "./base": { + "gradio": "./static/StaticAudio.svelte", + "svelte": "./dist/static/StaticAudio.svelte", + "types": "./dist/static/StaticAudio.svelte.d.ts" + } + }, + "peerDependencies": { + "svelte": "^4.0.0" }, "repository": { "type": "git", diff --git a/js/box/package.json b/js/box/package.json index 752e9bb7e0..af082058c0 100644 --- a/js/box/package.json +++ b/js/box/package.json @@ -8,12 +8,19 @@ "private": false, "main_changeset": true, "exports": { - ".": "./Index.svelte", + ".": { + "gradio": "./Index.svelte", + "svelte": "./dist/Index.svelte", + "types": "./dist/Index.svelte.d.ts" + }, "./package.json": "./package.json" }, "dependencies": { "@gradio/atoms": "workspace:^" }, + "peerDependencies": { + "svelte": "^4.0.0" + }, "repository": { "type": "git", "url": "git+https://github.com/gradio-app/gradio.git", diff --git a/js/build/CHANGELOG.md b/js/build/CHANGELOG.md index baa06912d0..88290fcc2b 100644 --- a/js/build/CHANGELOG.md +++ b/js/build/CHANGELOG.md @@ -1,4 +1,4 @@ -# @gradio/build +# @self/build ## 0.0.2 diff --git a/js/build/README.md b/js/build/README.md index 9a8109d646..f5f8e579e4 100644 --- a/js/build/README.md +++ b/js/build/README.md @@ -1,3 +1,3 @@ -# `@gradio/build` +# `@self/build` Build utilities for the gradio frontend + lite. diff --git a/js/build/dist/component_loader.js b/js/build/out/component_loader.js similarity index 100% rename from js/build/dist/component_loader.js rename to js/build/out/component_loader.js diff --git a/js/build/dist/index.js b/js/build/out/index.js similarity index 98% rename from js/build/dist/index.js rename to js/build/out/index.js index b35e27d088..b8edee8112 100644 --- a/js/build/dist/index.js +++ b/js/build/out/index.js @@ -124,9 +124,10 @@ function handle_ce_css() { var __filename = url.fileURLToPath(import.meta.url); var __dirname = url.fileURLToPath(new URL(".", import.meta.url)); function get_export_path(path, root, pkg_json) { - if (!pkg_json.exports) return void 0; + if (!pkg_json.exports) return false; + if (typeof pkg_json.exports[`${path}`] === "object") return true; const _path = join(root, "..", `${pkg_json.exports[`${path}`]}`); - return existsSync(_path) ? _path : void 0; + return existsSync(_path); } var ignore_list = [ "tootils", diff --git a/js/build/package.json b/js/build/package.json index 66949026e9..679917ec8f 100644 --- a/js/build/package.json +++ b/js/build/package.json @@ -1,20 +1,23 @@ { - "name": "@gradio/build", + "name": "@self/build", "version": "0.0.2", "description": "Gradio UI packages", "type": "module", - "main": "dist/index.js", + "main": "out/index.js", "private": "true", "author": "", "license": "ISC", "scripts": { - "build": "esbuild src/index.ts --platform=node --format=esm --target=node18 --bundle --packages=external --outfile=dist/index.js" + "build": "esbuild src/index.ts --platform=node --format=esm --target=node18 --bundle --packages=external --outfile=out/index.js" }, "dependencies": { "@gradio/theme": "workspace:^", "esbuild": "^0.21.0", "svelte-i18n": "^3.6.0" }, + "peerDependencies": { + "svelte": "^4.0.0" + }, "main_changeset": true, "repository": { "type": "git", diff --git a/js/build/src/index.ts b/js/build/src/index.ts index 50e666eeb3..77a1055b3c 100644 --- a/js/build/src/index.ts +++ b/js/build/src/index.ts @@ -183,11 +183,12 @@ function get_export_path( path: string, root: string, pkg_json: Record -): string | undefined { - if (!pkg_json.exports) return undefined; +): boolean { + if (!pkg_json.exports) return false; + if ( typeof pkg_json.exports[`${path}`] === "object") return true; const _path = join(root, "..", `${pkg_json.exports[`${path}`]}`); - return existsSync(_path) ? _path : undefined; + return existsSync(_path); } const ignore_list = [ diff --git a/js/button/package.json b/js/button/package.json index 2ed5a3d422..5d3d2977a7 100644 --- a/js/button/package.json +++ b/js/button/package.json @@ -17,8 +17,15 @@ "main": "./Index.svelte", "main_changeset": true, "exports": { - ".": "./Index.svelte", - "./package.json": "./package.json" + "./package.json": "./package.json", + ".": { + "gradio": "./Index.svelte", + "svelte": "./dist/Index.svelte", + "types": "./dist/Index.svelte.d.ts" + } + }, + "peerDependencies": { + "svelte": "^4.0.0" }, "repository": { "type": "git", diff --git a/js/chatbot/Chatbot.test.ts b/js/chatbot/Chatbot.test.ts index 20644faf61..c001c716ff 100644 --- a/js/chatbot/Chatbot.test.ts +++ b/js/chatbot/Chatbot.test.ts @@ -1,5 +1,5 @@ import { test, describe, assert, afterEach, vi } from "vitest"; -import { cleanup, render, fireEvent } from "@gradio/tootils"; +import { cleanup, render, fireEvent } from "@self/tootils"; import Chatbot from "./Index.svelte"; import type { LoadingStatus } from "@gradio/statustracker"; import type { FileData } from "@gradio/client"; diff --git a/js/chatbot/package.json b/js/chatbot/package.json index 12e239042f..b7bfa23de7 100644 --- a/js/chatbot/package.json +++ b/js/chatbot/package.json @@ -32,8 +32,15 @@ "main_changeset": true, "main": "./Index.svelte", "exports": { - ".": "./Index.svelte", - "./package.json": "./package.json" + "./package.json": "./package.json", + ".": { + "gradio": "./Index.svelte", + "svelte": "./dist/Index.svelte", + "types": "./dist/Index.svelte.d.ts" + } + }, + "peerDependencies": { + "svelte": "^4.0.0" }, "repository": { "type": "git", diff --git a/js/checkbox/package.json b/js/checkbox/package.json index ee2a955e85..2df362a6b5 100644 --- a/js/checkbox/package.json +++ b/js/checkbox/package.json @@ -9,9 +9,17 @@ "main_changeset": true, "main": "./Index.svelte", "exports": { - ".": "./Index.svelte", - "./example": "./Example.svelte", - "./package.json": "./package.json" + "./package.json": "./package.json", + ".": { + "gradio": "./Index.svelte", + "svelte": "./dist/Index.svelte", + "types": "./dist/Index.svelte.d.ts" + }, + "./example": { + "gradio": "./Example.svelte", + "svelte": "./dist/Example.svelte", + "types": "./dist/Example.svelte.d.ts" + } }, "dependencies": { "@gradio/atoms": "workspace:^", @@ -21,6 +29,9 @@ "devDependencies": { "@gradio/preview": "workspace:^" }, + "peerDependencies": { + "svelte": "^4.0.0" + }, "repository": { "type": "git", "url": "git+https://github.com/gradio-app/gradio.git", diff --git a/js/checkboxgroup/checkboxgroup.test.ts b/js/checkboxgroup/checkboxgroup.test.ts index 98932629ce..2d2ba644c9 100644 --- a/js/checkboxgroup/checkboxgroup.test.ts +++ b/js/checkboxgroup/checkboxgroup.test.ts @@ -1,5 +1,5 @@ import { test, describe, assert, afterEach, vi } from "vitest"; -import { cleanup, render } from "@gradio/tootils"; +import { cleanup, render } from "@self/tootils"; import event from "@testing-library/user-event"; import { setupi18n } from "../core/src/i18n"; diff --git a/js/checkboxgroup/package.json b/js/checkboxgroup/package.json index 88934f1d8f..d237ff3886 100644 --- a/js/checkboxgroup/package.json +++ b/js/checkboxgroup/package.json @@ -9,8 +9,16 @@ "main_changeset": true, "main": "./Index.svelte", "exports": { - ".": "./Index.svelte", - "./example": "./Example.svelte", + ".": { + "gradio": "./Index.svelte", + "svelte": "./dist/Index.svelte", + "types": "./dist/Index.svelte.d.ts" + }, + "./example": { + "gradio": "./Example.svelte", + "svelte": "./dist/Example.svelte", + "types": "./dist/Example.svelte.d.ts" + }, "./package.json": "./package.json" }, "dependencies": { @@ -21,6 +29,9 @@ "devDependencies": { "@gradio/preview": "workspace:^" }, + "peerDependencies": { + "svelte": "^4.0.0" + }, "repository": { "type": "git", "url": "git+https://github.com/gradio-app/gradio.git", diff --git a/js/code/package.json b/js/code/package.json index 63372625e1..cfac02f727 100644 --- a/js/code/package.json +++ b/js/code/package.json @@ -37,13 +37,24 @@ "main_changeset": true, "main": "./Index.svelte", "exports": { - ".": "./Index.svelte", - "./example": "./Example.svelte", + ".": { + "gradio": "./Index.svelte", + "svelte": "./dist/Index.svelte", + "types": "./dist/Index.svelte.d.ts" + }, + "./example": { + "gradio": "./Example.svelte", + "svelte": "./dist/Example.svelte", + "types": "./dist/Example.svelte.d.ts" + }, "./package.json": "./package.json" }, "devDependencies": { "@gradio/preview": "workspace:^" }, + "peerDependencies": { + "svelte": "^4.0.0" + }, "repository": { "type": "git", "url": "git+https://github.com/gradio-app/gradio.git", diff --git a/js/colorpicker/package.json b/js/colorpicker/package.json index 01450794cb..4750103f30 100644 --- a/js/colorpicker/package.json +++ b/js/colorpicker/package.json @@ -9,8 +9,16 @@ "main_changeset": true, "main": "./Index.svelte", "exports": { - ".": "./Index.svelte", - "./example": "./Example.svelte", + ".": { + "gradio": "./Index.svelte", + "svelte": "./dist/Index.svelte", + "types": "./dist/Index.svelte.d.ts" + }, + "./example": { + "gradio": "./Example.svelte", + "svelte": "./dist/Example.svelte", + "types": "./dist/Example.svelte.d.ts" + }, "./package.json": "./package.json" }, "dependencies": { @@ -21,6 +29,9 @@ "devDependencies": { "@gradio/preview": "workspace:^" }, + "peerDependencies": { + "svelte": "^4.0.0" + }, "repository": { "type": "git", "url": "git+https://github.com/gradio-app/gradio.git", diff --git a/js/column/package.json b/js/column/package.json index 1879676b8e..f08fa9f890 100644 --- a/js/column/package.json +++ b/js/column/package.json @@ -9,7 +9,11 @@ "private": false, "main": "./Index.svelte", "exports": { - ".": "./Index.svelte", + ".": { + "gradio": "./Index.svelte", + "svelte": "./dist/Index.svelte", + "types": "./dist/Index.svelte.d.ts" + }, "./package.json": "./package.json" }, "devDependencies": { @@ -17,6 +21,9 @@ "@gradio/statustracker": "workspace:^", "@gradio/utils": "workspace:^" }, + "peerDependencies": { + "svelte": "^4.0.0" + }, "repository": { "type": "git", "url": "git+https://github.com/gradio-app/gradio.git", diff --git a/js/component-test/CHANGELOG.md b/js/component-test/CHANGELOG.md index 99af666f37..2fe2066c08 100644 --- a/js/component-test/CHANGELOG.md +++ b/js/component-test/CHANGELOG.md @@ -1,4 +1,4 @@ -# @gradio/component-test +# @self/component-test ## 0.1.0 diff --git a/js/component-test/package.json b/js/component-test/package.json index df63f429aa..2a9f7c4a2e 100644 --- a/js/component-test/package.json +++ b/js/component-test/package.json @@ -1,5 +1,5 @@ { - "name": "@gradio/component-test", + "name": "@self/component-test", "version": "0.1.0", "scripts": { "dev": "vite dev", @@ -9,7 +9,7 @@ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json" }, "devDependencies": { - "@gradio/build": "workspace:^", + "@self/build": "workspace:^", "@sveltejs/adapter-auto": "^3.0.0", "@sveltejs/kit": "^2.0.0" }, diff --git a/js/component-test/src/routes/+layout.svelte b/js/component-test/src/routes/+layout.svelte index 8ff6efc84f..1a10344f9c 100644 --- a/js/component-test/src/routes/+layout.svelte +++ b/js/component-test/src/routes/+layout.svelte @@ -1,6 +1,14 @@
diff --git a/js/component-test/src/routes/[...all]/+page.ts b/js/component-test/src/routes/[...all]/+page.ts index 20418a40f8..13776fd576 100644 --- a/js/component-test/src/routes/[...all]/+page.ts +++ b/js/component-test/src/routes/[...all]/+page.ts @@ -1,75 +1,40 @@ import config from "$lib/component_json"; -// @ts-ignore const comps = { - // @ts-ignore accordion: () => import("@gradio/accordion"), audio: () => import("@gradio/audio"), - // @ts-ignore button: () => import("@gradio/button"), - // @ts-ignore chatbot: () => import("@gradio/chatbot"), - // @ts-ignore checkbox: () => import("@gradio/checkbox"), - // @ts-ignore checkboxgroup: () => import("@gradio/checkboxgroup"), - // @ts-ignore code: () => import("@gradio/code"), - // @ts-ignore colorpicker: () => import("@gradio/colorpicker"), - // @ts-ignore dataframe: () => import("@gradio/dataframe"), - // @ts-ignore dataset: () => import("@gradio/dataset"), - // @ts-ignore datetime: () => import("@gradio/datetime"), - // @ts-ignore downloadbutton: () => import("@gradio/downloadbutton"), - // @ts-ignore dropdown: () => import("@gradio/dropdown"), - // @ts-ignore file: () => import("@gradio/file"), - // @ts-ignore gallery: () => import("@gradio/gallery"), - // @ts-ignore highlightedtext: () => import("@gradio/highlightedtext"), - // @ts-ignore html: () => import("@gradio/html"), - // @ts-ignore image: () => import("@gradio/image"), - // @ts-ignore imageeditor: () => import("@gradio/imageeditor"), - // @ts-ignore json: () => import("@gradio/json"), - // @ts-ignore label: () => import("@gradio/label"), - // @ts-ignore markdown: () => import("@gradio/markdown"), - // @ts-ignore model3d: () => import("@gradio/model3d"), - // @ts-ignore multimodaltextbox: () => import("@gradio/multimodaltextbox"), - // @ts-ignore number: () => import("@gradio/number"), - // @ts-ignore paramviewer: () => import("@gradio/paramviewer"), - // @ts-ignore plot: () => import("@gradio/plot"), - // @ts-ignore radio: () => import("@gradio/radio"), - // @ts-ignore simpleimage: () => import("@gradio/simpleimage"), - // @ts-ignore slider: () => import("@gradio/slider"), - // @ts-ignore state: () => import("@gradio/state"), - // @ts-ignore textbox: () => import("@gradio/textbox"), - // @ts-ignore timer: () => import("@gradio/timer"), - // @ts-ignore uploadbutton: () => import("@gradio/uploadbutton"), - // @ts-ignore video: () => import("@gradio/video") }; @@ -86,10 +51,8 @@ export const load: PageLoad = async ({ url }) => { const comp = route_name in comps - ? // @ts-ignore - await comps[route_name]() - : // @ts-ignore - await import("@gradio/label"); + ? await comps[route_name]() + : await import("@gradio/label"); return { component: comp, diff --git a/js/component-test/vite.config.js b/js/component-test/vite.config.js index f90a31792f..d8dba7a1c9 100644 --- a/js/component-test/vite.config.js +++ b/js/component-test/vite.config.js @@ -8,8 +8,11 @@ import { inject_ejs, mock_modules, resolve_svelte -} from "@gradio/build"; +} from "@self/build"; export default defineConfig({ - plugins: [sveltekit(), inject_component_loader({ mode: "development" })] + plugins: [sveltekit()], + resolve: { + conditions: ["gradio"] + } }); diff --git a/js/core/package.json b/js/core/package.json index 125f356fbd..010e3f74b7 100644 --- a/js/core/package.json +++ b/js/core/package.json @@ -66,13 +66,24 @@ "main_changeset": true, "exports": { "./blocks": { - "svelte": "./src/Blocks.svelte" + "gradio": "./src/Blocks.svelte", + "svelte": "./dist/src/Blocks.svelte", + "types": "./dist/src/Blocks.svelte.d.ts" }, "./login": { - "svelte": "./src/Login.svelte" + "gradio": "./src/Login.svelte", + "svelte": "./dist/src/Login.svelte", + "types": "./dist/src/Login.svelte.d.ts" }, "./package.json": "./package.json", - ".": "./index.ts" + ".": { + "gradio": "./index.ts", + "import": "./dist/index.js", + "types": "./dist/index.d.ts" + } + }, + "peerDependencies": { + "svelte": "^4.0.0" }, "main": "./index.ts", "repository": { diff --git a/js/core/src/Render.svelte b/js/core/src/Render.svelte index 73110058a7..f79e619cd5 100644 --- a/js/core/src/Render.svelte +++ b/js/core/src/Render.svelte @@ -4,6 +4,7 @@ import type { ComponentMeta, ThemeMode } from "./types"; import type { Client } from "@gradio/client"; import RenderComponent from "./RenderComponent.svelte"; + import { load_component } from "virtual:component-loader"; export let root: string; @@ -66,7 +67,8 @@ autoscroll, max_file_size, formatter, - client + client, + load_component ); diff --git a/js/core/src/api_docs/ApiDocs.svelte b/js/core/src/api_docs/ApiDocs.svelte index 81c3a69717..6999b71650 100644 --- a/js/core/src/api_docs/ApiDocs.svelte +++ b/js/core/src/api_docs/ApiDocs.svelte @@ -7,7 +7,7 @@ import type { Payload } from "../types"; import ApiBanner from "./ApiBanner.svelte"; - import Button from "../../../button/shared/Button.svelte"; + import { BaseButton as Button } from "@gradio/button"; import ParametersSnippet from "./ParametersSnippet.svelte"; import InstallSnippet from "./InstallSnippet.svelte"; import CodeSnippet from "./CodeSnippet.svelte"; diff --git a/js/core/src/api_docs/ApiRecorder.svelte b/js/core/src/api_docs/ApiRecorder.svelte index 5798ce3d5a..e4bb935b6a 100644 --- a/js/core/src/api_docs/ApiRecorder.svelte +++ b/js/core/src/api_docs/ApiRecorder.svelte @@ -1,6 +1,6 @@