groove-dev 0.15.1 → 0.16.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/docs/FILE-EDITOR-PLAN.md +253 -0
- package/node_modules/@codemirror/autocomplete/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/autocomplete/CHANGELOG.md +639 -0
- package/node_modules/@codemirror/autocomplete/LICENSE +21 -0
- package/node_modules/@codemirror/autocomplete/README.md +43 -0
- package/node_modules/@codemirror/autocomplete/dist/index.cjs +2151 -0
- package/node_modules/@codemirror/autocomplete/dist/index.d.cts +648 -0
- package/node_modules/@codemirror/autocomplete/dist/index.d.ts +648 -0
- package/node_modules/@codemirror/autocomplete/dist/index.js +2120 -0
- package/node_modules/@codemirror/autocomplete/package.json +41 -0
- package/node_modules/@codemirror/commands/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/commands/CHANGELOG.md +386 -0
- package/node_modules/@codemirror/commands/LICENSE +21 -0
- package/node_modules/@codemirror/commands/README.md +35 -0
- package/node_modules/@codemirror/commands/dist/index.cjs +1909 -0
- package/node_modules/@codemirror/commands/dist/index.d.cts +650 -0
- package/node_modules/@codemirror/commands/dist/index.d.ts +650 -0
- package/node_modules/@codemirror/commands/dist/index.js +1795 -0
- package/node_modules/@codemirror/commands/package.json +42 -0
- package/node_modules/@codemirror/lang-css/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-css/CHANGELOG.md +106 -0
- package/node_modules/@codemirror/lang-css/LICENSE +21 -0
- package/node_modules/@codemirror/lang-css/README.md +50 -0
- package/node_modules/@codemirror/lang-css/dist/index.cjs +269 -0
- package/node_modules/@codemirror/lang-css/dist/index.d.cts +28 -0
- package/node_modules/@codemirror/lang-css/dist/index.d.ts +28 -0
- package/node_modules/@codemirror/lang-css/dist/index.js +264 -0
- package/node_modules/@codemirror/lang-css/package.json +42 -0
- package/node_modules/@codemirror/lang-html/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-html/CHANGELOG.md +210 -0
- package/node_modules/@codemirror/lang-html/LICENSE +21 -0
- package/node_modules/@codemirror/lang-html/README.md +147 -0
- package/node_modules/@codemirror/lang-html/dist/index.cjs +667 -0
- package/node_modules/@codemirror/lang-html/dist/index.d.cts +115 -0
- package/node_modules/@codemirror/lang-html/dist/index.d.ts +115 -0
- package/node_modules/@codemirror/lang-html/dist/index.js +661 -0
- package/node_modules/@codemirror/lang-html/package.json +46 -0
- package/node_modules/@codemirror/lang-javascript/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-javascript/CHANGELOG.md +206 -0
- package/node_modules/@codemirror/lang-javascript/LICENSE +21 -0
- package/node_modules/@codemirror/lang-javascript/README.md +125 -0
- package/node_modules/@codemirror/lang-javascript/dist/index.cjs +526 -0
- package/node_modules/@codemirror/lang-javascript/dist/index.d.cts +93 -0
- package/node_modules/@codemirror/lang-javascript/dist/index.d.ts +93 -0
- package/node_modules/@codemirror/lang-javascript/dist/index.js +513 -0
- package/node_modules/@codemirror/lang-javascript/package.json +45 -0
- package/node_modules/@codemirror/lang-json/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-json/CHANGELOG.md +59 -0
- package/node_modules/@codemirror/lang-json/LICENSE +21 -0
- package/node_modules/@codemirror/lang-json/README.md +56 -0
- package/node_modules/@codemirror/lang-json/dist/index.cjs +68 -0
- package/node_modules/@codemirror/lang-json/dist/index.d.cts +22 -0
- package/node_modules/@codemirror/lang-json/dist/index.d.ts +22 -0
- package/node_modules/@codemirror/lang-json/dist/index.js +64 -0
- package/node_modules/@codemirror/lang-json/package.json +39 -0
- package/node_modules/@codemirror/lang-markdown/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-markdown/CHANGELOG.md +246 -0
- package/node_modules/@codemirror/lang-markdown/LICENSE +21 -0
- package/node_modules/@codemirror/lang-markdown/README.md +162 -0
- package/node_modules/@codemirror/lang-markdown/dist/index.cjs +501 -0
- package/node_modules/@codemirror/lang-markdown/dist/index.d.cts +124 -0
- package/node_modules/@codemirror/lang-markdown/dist/index.d.ts +124 -0
- package/node_modules/@codemirror/lang-markdown/dist/index.js +492 -0
- package/node_modules/@codemirror/lang-markdown/package.json +44 -0
- package/node_modules/@codemirror/lang-python/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lang-python/CHANGELOG.md +174 -0
- package/node_modules/@codemirror/lang-python/LICENSE +21 -0
- package/node_modules/@codemirror/lang-python/README.md +61 -0
- package/node_modules/@codemirror/lang-python/dist/index.cjs +313 -0
- package/node_modules/@codemirror/lang-python/dist/index.d.cts +26 -0
- package/node_modules/@codemirror/lang-python/dist/index.d.ts +26 -0
- package/node_modules/@codemirror/lang-python/dist/index.js +308 -0
- package/node_modules/@codemirror/lang-python/package.json +42 -0
- package/node_modules/@codemirror/language/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/language/CHANGELOG.md +412 -0
- package/node_modules/@codemirror/language/LICENSE +21 -0
- package/node_modules/@codemirror/language/README.md +66 -0
- package/node_modules/@codemirror/language/dist/index.cjs +2742 -0
- package/node_modules/@codemirror/language/dist/index.d.cts +1220 -0
- package/node_modules/@codemirror/language/dist/index.d.ts +1220 -0
- package/node_modules/@codemirror/language/dist/index.js +2687 -0
- package/node_modules/@codemirror/language/package.json +44 -0
- package/node_modules/@codemirror/lint/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/lint/CHANGELOG.md +318 -0
- package/node_modules/@codemirror/lint/LICENSE +21 -0
- package/node_modules/@codemirror/lint/README.md +18 -0
- package/node_modules/@codemirror/lint/dist/index.cjs +958 -0
- package/node_modules/@codemirror/lint/dist/index.d.cts +195 -0
- package/node_modules/@codemirror/lint/dist/index.d.ts +195 -0
- package/node_modules/@codemirror/lint/dist/index.js +945 -0
- package/node_modules/@codemirror/lint/package.json +40 -0
- package/node_modules/@codemirror/search/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/search/CHANGELOG.md +324 -0
- package/node_modules/@codemirror/search/LICENSE +21 -0
- package/node_modules/@codemirror/search/README.md +18 -0
- package/node_modules/@codemirror/search/dist/index.cjs +1237 -0
- package/node_modules/@codemirror/search/dist/index.d.cts +385 -0
- package/node_modules/@codemirror/search/dist/index.d.ts +385 -0
- package/node_modules/@codemirror/search/dist/index.js +1217 -0
- package/node_modules/@codemirror/search/package.json +40 -0
- package/node_modules/@codemirror/state/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/state/CHANGELOG.md +308 -0
- package/node_modules/@codemirror/state/LICENSE +21 -0
- package/node_modules/@codemirror/state/README.md +18 -0
- package/node_modules/@codemirror/state/dist/index.cjs +3922 -0
- package/node_modules/@codemirror/state/dist/index.d.cts +1713 -0
- package/node_modules/@codemirror/state/dist/index.d.ts +1713 -0
- package/node_modules/@codemirror/state/dist/index.js +3892 -0
- package/node_modules/@codemirror/state/package.json +38 -0
- package/node_modules/@codemirror/theme-one-dark/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/theme-one-dark/CHANGELOG.md +97 -0
- package/node_modules/@codemirror/theme-one-dark/LICENSE +21 -0
- package/node_modules/@codemirror/theme-one-dark/README.md +46 -0
- package/node_modules/@codemirror/theme-one-dark/dist/index.cjs +139 -0
- package/node_modules/@codemirror/theme-one-dark/dist/index.d.cts +39 -0
- package/node_modules/@codemirror/theme-one-dark/dist/index.d.ts +39 -0
- package/node_modules/@codemirror/theme-one-dark/dist/index.js +134 -0
- package/node_modules/@codemirror/theme-one-dark/package.json +41 -0
- package/node_modules/@codemirror/view/.github/workflows/dispatch.yml +16 -0
- package/node_modules/@codemirror/view/CHANGELOG.md +2284 -0
- package/node_modules/@codemirror/view/LICENSE +21 -0
- package/node_modules/@codemirror/view/README.md +37 -0
- package/node_modules/@codemirror/view/dist/index.cjs +11796 -0
- package/node_modules/@codemirror/view/dist/index.d.cts +2389 -0
- package/node_modules/@codemirror/view/dist/index.d.ts +2389 -0
- package/node_modules/@codemirror/view/dist/index.js +11745 -0
- package/node_modules/@codemirror/view/package.json +41 -0
- package/node_modules/@groove-dev/daemon/src/api.js +268 -2
- package/node_modules/@groove-dev/daemon/src/filewatcher.js +59 -0
- package/node_modules/@groove-dev/daemon/src/index.js +28 -1
- package/node_modules/@groove-dev/daemon/src/mimetypes.js +43 -0
- package/node_modules/@groove-dev/gui/dist/assets/index-BQSznoq0.js +103 -0
- package/node_modules/@groove-dev/gui/dist/index.html +1 -1
- package/node_modules/@groove-dev/gui/package.json +15 -2
- package/node_modules/@groove-dev/gui/src/App.jsx +3 -0
- package/node_modules/@groove-dev/gui/src/components/CodeEditor.jsx +143 -0
- package/node_modules/@groove-dev/gui/src/components/EditorTabs.jsx +83 -0
- package/node_modules/@groove-dev/gui/src/components/FileTree.jsx +492 -0
- package/node_modules/@groove-dev/gui/src/components/MediaViewer.jsx +104 -0
- package/node_modules/@groove-dev/gui/src/stores/groove.js +287 -1
- package/node_modules/@groove-dev/gui/src/views/FileEditor.jsx +149 -0
- package/node_modules/@lezer/common/LICENSE +21 -0
- package/node_modules/@lezer/common/README.md +14 -0
- package/node_modules/@lezer/common/dist/index.cjs +2209 -0
- package/node_modules/@lezer/common/dist/index.d.cts +1174 -0
- package/node_modules/@lezer/common/dist/index.d.ts +1174 -0
- package/node_modules/@lezer/common/dist/index.js +2196 -0
- package/node_modules/@lezer/common/package.json +32 -0
- package/node_modules/@lezer/css/CHANGELOG.md +307 -0
- package/node_modules/@lezer/css/LICENSE +21 -0
- package/node_modules/@lezer/css/README.md +6 -0
- package/node_modules/@lezer/css/dist/index.cjs +151 -0
- package/node_modules/@lezer/css/dist/index.d.cts +3 -0
- package/node_modules/@lezer/css/dist/index.d.ts +3 -0
- package/node_modules/@lezer/css/dist/index.js +147 -0
- package/node_modules/@lezer/css/package.json +36 -0
- package/node_modules/@lezer/css/rollup.config.js +16 -0
- package/node_modules/@lezer/css/src/css.grammar +290 -0
- package/node_modules/@lezer/css/src/highlight.js +36 -0
- package/node_modules/@lezer/css/src/parser.js +31 -0
- package/node_modules/@lezer/css/src/parser.terms.js +63 -0
- package/node_modules/@lezer/css/src/tokens.js +75 -0
- package/node_modules/@lezer/css/test/declarations.txt +241 -0
- package/node_modules/@lezer/css/test/selector.txt +178 -0
- package/node_modules/@lezer/css/test/statements.txt +227 -0
- package/node_modules/@lezer/css/test/test-css.js +16 -0
- package/node_modules/@lezer/highlight/LICENSE +21 -0
- package/node_modules/@lezer/highlight/README.md +14 -0
- package/node_modules/@lezer/highlight/dist/index.cjs +936 -0
- package/node_modules/@lezer/highlight/dist/index.d.cts +623 -0
- package/node_modules/@lezer/highlight/dist/index.d.ts +623 -0
- package/node_modules/@lezer/highlight/dist/index.js +927 -0
- package/node_modules/@lezer/highlight/package.json +31 -0
- package/node_modules/@lezer/html/CHANGELOG.md +303 -0
- package/node_modules/@lezer/html/LICENSE +21 -0
- package/node_modules/@lezer/html/README.md +37 -0
- package/node_modules/@lezer/html/dist/index.cjs +354 -0
- package/node_modules/@lezer/html/dist/index.d.cts +14 -0
- package/node_modules/@lezer/html/dist/index.d.ts +14 -0
- package/node_modules/@lezer/html/dist/index.js +349 -0
- package/node_modules/@lezer/html/package.json +37 -0
- package/node_modules/@lezer/html/rollup.config.js +16 -0
- package/node_modules/@lezer/html/src/.tern-port +1 -0
- package/node_modules/@lezer/html/src/content.js +87 -0
- package/node_modules/@lezer/html/src/highlight.js +15 -0
- package/node_modules/@lezer/html/src/html.grammar +181 -0
- package/node_modules/@lezer/html/src/index.js +2 -0
- package/node_modules/@lezer/html/src/parser.js +27 -0
- package/node_modules/@lezer/html/src/parser.terms.js +53 -0
- package/node_modules/@lezer/html/src/tokens.js +199 -0
- package/node_modules/@lezer/html/test/mixed.txt +69 -0
- package/node_modules/@lezer/html/test/tags.txt +370 -0
- package/node_modules/@lezer/html/test/test-html.js +29 -0
- package/node_modules/@lezer/html/test/test-incremental.js +97 -0
- package/node_modules/@lezer/html/test/vue.txt +56 -0
- package/node_modules/@lezer/javascript/CHANGELOG.md +485 -0
- package/node_modules/@lezer/javascript/LICENSE +21 -0
- package/node_modules/@lezer/javascript/README.md +14 -0
- package/node_modules/@lezer/javascript/dist/index.cjs +196 -0
- package/node_modules/@lezer/javascript/dist/index.d.cts +3 -0
- package/node_modules/@lezer/javascript/dist/index.d.ts +3 -0
- package/node_modules/@lezer/javascript/dist/index.js +192 -0
- package/node_modules/@lezer/javascript/package.json +36 -0
- package/node_modules/@lezer/javascript/rollup.config.js +16 -0
- package/node_modules/@lezer/javascript/src/highlight.js +62 -0
- package/node_modules/@lezer/javascript/src/javascript.grammar +735 -0
- package/node_modules/@lezer/javascript/src/parser.js +33 -0
- package/node_modules/@lezer/javascript/src/parser.terms.js +177 -0
- package/node_modules/@lezer/javascript/src/tokens.js +87 -0
- package/node_modules/@lezer/javascript/test/decorator.txt +64 -0
- package/node_modules/@lezer/javascript/test/expression.txt +686 -0
- package/node_modules/@lezer/javascript/test/jsx.txt +79 -0
- package/node_modules/@lezer/javascript/test/semicolon.txt +77 -0
- package/node_modules/@lezer/javascript/test/statement.txt +404 -0
- package/node_modules/@lezer/javascript/test/test-javascript.js +17 -0
- package/node_modules/@lezer/javascript/test/typescript.txt +401 -0
- package/node_modules/@lezer/json/CHANGELOG.md +79 -0
- package/node_modules/@lezer/json/LICENSE +21 -0
- package/node_modules/@lezer/json/README.md +7 -0
- package/node_modules/@lezer/json/dist/index.cjs +41 -0
- package/node_modules/@lezer/json/dist/index.d.cts +3 -0
- package/node_modules/@lezer/json/dist/index.d.ts +3 -0
- package/node_modules/@lezer/json/dist/index.js +37 -0
- package/node_modules/@lezer/json/package.json +36 -0
- package/node_modules/@lezer/json/rollup.config.js +15 -0
- package/node_modules/@lezer/json/src/highlight.js +12 -0
- package/node_modules/@lezer/json/src/json.grammar +38 -0
- package/node_modules/@lezer/json/src/parser.js +23 -0
- package/node_modules/@lezer/json/src/parser.terms.js +12 -0
- package/node_modules/@lezer/json/test/arrays.txt +34 -0
- package/node_modules/@lezer/json/test/literals.txt +23 -0
- package/node_modules/@lezer/json/test/numbers.txt +87 -0
- package/node_modules/@lezer/json/test/objects.txt +34 -0
- package/node_modules/@lezer/json/test/strings.txt +50 -0
- package/node_modules/@lezer/json/test/test-json.js +17 -0
- package/node_modules/@lezer/lr/LICENSE +21 -0
- package/node_modules/@lezer/lr/README.md +25 -0
- package/node_modules/@lezer/lr/dist/constants.d.ts +45 -0
- package/node_modules/@lezer/lr/dist/constants.js +5 -0
- package/node_modules/@lezer/lr/dist/index.cjs +1891 -0
- package/node_modules/@lezer/lr/dist/index.d.cts +303 -0
- package/node_modules/@lezer/lr/dist/index.d.ts +303 -0
- package/node_modules/@lezer/lr/dist/index.js +1884 -0
- package/node_modules/@lezer/lr/package.json +32 -0
- package/node_modules/@lezer/markdown/CHANGELOG.md +279 -0
- package/node_modules/@lezer/markdown/LICENSE +21 -0
- package/node_modules/@lezer/markdown/README.md +725 -0
- package/node_modules/@lezer/markdown/bin/build-readme.cjs +39 -0
- package/node_modules/@lezer/markdown/build.js +16 -0
- package/node_modules/@lezer/markdown/dist/index.cjs +2352 -0
- package/node_modules/@lezer/markdown/dist/index.d.cts +600 -0
- package/node_modules/@lezer/markdown/dist/index.d.ts +600 -0
- package/node_modules/@lezer/markdown/dist/index.js +2335 -0
- package/node_modules/@lezer/markdown/package.json +37 -0
- package/node_modules/@lezer/markdown/src/README.md +83 -0
- package/node_modules/@lezer/markdown/src/extension.ts +301 -0
- package/node_modules/@lezer/markdown/src/index.ts +5 -0
- package/node_modules/@lezer/markdown/src/markdown.ts +1961 -0
- package/node_modules/@lezer/markdown/src/nest.ts +46 -0
- package/node_modules/@lezer/markdown/test/compare-tree.ts +14 -0
- package/node_modules/@lezer/markdown/test/spec.ts +79 -0
- package/node_modules/@lezer/markdown/test/test-extension.ts +269 -0
- package/node_modules/@lezer/markdown/test/test-incremental.ts +265 -0
- package/node_modules/@lezer/markdown/test/test-markdown.ts +3574 -0
- package/node_modules/@lezer/markdown/test/test-nesting.ts +86 -0
- package/node_modules/@lezer/markdown/test/tsconfig.json +12 -0
- package/node_modules/@lezer/markdown/tsconfig.json +14 -0
- package/node_modules/@lezer/python/CHANGELOG.md +243 -0
- package/node_modules/@lezer/python/LICENSE +21 -0
- package/node_modules/@lezer/python/README.md +6 -0
- package/node_modules/@lezer/python/dist/index.cjs +330 -0
- package/node_modules/@lezer/python/dist/index.d.cts +3 -0
- package/node_modules/@lezer/python/dist/index.d.ts +3 -0
- package/node_modules/@lezer/python/dist/index.js +326 -0
- package/node_modules/@lezer/python/package.json +36 -0
- package/node_modules/@lezer/python/rollup.config.js +16 -0
- package/node_modules/@lezer/python/src/highlight.js +35 -0
- package/node_modules/@lezer/python/src/python.grammar +381 -0
- package/node_modules/@lezer/python/src/tokens.js +224 -0
- package/node_modules/@lezer/python/test/expression.txt +231 -0
- package/node_modules/@lezer/python/test/statement.txt +442 -0
- package/node_modules/@lezer/python/test/test-incremental.js +33 -0
- package/node_modules/@lezer/python/test/test-python.js +17 -0
- package/node_modules/@marijn/find-cluster-break/LICENSE +21 -0
- package/node_modules/@marijn/find-cluster-break/README.md +28 -0
- package/node_modules/@marijn/find-cluster-break/dist/index.cjs +85 -0
- package/node_modules/@marijn/find-cluster-break/dist/index.d.cts +15 -0
- package/node_modules/@marijn/find-cluster-break/package.json +35 -0
- package/node_modules/@marijn/find-cluster-break/rollup.config.js +7 -0
- package/node_modules/@marijn/find-cluster-break/src/index.d.ts +15 -0
- package/node_modules/@marijn/find-cluster-break/src/index.js +87 -0
- package/node_modules/@marijn/find-cluster-break/test/test-cluster.js +30 -0
- package/node_modules/crelt/LICENSE +19 -0
- package/node_modules/crelt/README.md +23 -0
- package/node_modules/crelt/dist/index.cjs +31 -0
- package/node_modules/crelt/dist/index.d.cts +4 -0
- package/node_modules/crelt/index.d.ts +4 -0
- package/node_modules/crelt/index.js +28 -0
- package/node_modules/crelt/package.json +35 -0
- package/node_modules/crelt/rollup.config.js +13 -0
- package/node_modules/style-mod/LICENSE +19 -0
- package/node_modules/style-mod/README.md +98 -0
- package/node_modules/style-mod/dist/style-mod.cjs +165 -0
- package/node_modules/style-mod/dist/style-mod.d.cts +16 -0
- package/node_modules/style-mod/package.json +39 -0
- package/node_modules/style-mod/src/README.md +34 -0
- package/node_modules/style-mod/src/style-mod.d.ts +16 -0
- package/node_modules/style-mod/src/style-mod.js +172 -0
- package/node_modules/style-mod/test/test-style-mod.js +104 -0
- package/node_modules/w3c-keyname/.tern-port +1 -0
- package/node_modules/w3c-keyname/LICENSE +19 -0
- package/node_modules/w3c-keyname/README.md +18 -0
- package/node_modules/w3c-keyname/index.cjs +127 -0
- package/node_modules/w3c-keyname/index.d.cts +5 -0
- package/node_modules/w3c-keyname/index.d.ts +5 -0
- package/node_modules/w3c-keyname/index.js +119 -0
- package/node_modules/w3c-keyname/package.json +37 -0
- package/package.json +1 -1
- package/packages/daemon/src/api.js +268 -2
- package/packages/daemon/src/filewatcher.js +59 -0
- package/packages/daemon/src/index.js +28 -1
- package/packages/daemon/src/mimetypes.js +43 -0
- package/packages/gui/dist/assets/index-BQSznoq0.js +103 -0
- package/packages/gui/dist/index.html +1 -1
- package/packages/gui/package.json +15 -2
- package/packages/gui/src/App.jsx +3 -0
- package/packages/gui/src/components/CodeEditor.jsx +143 -0
- package/packages/gui/src/components/EditorTabs.jsx +83 -0
- package/packages/gui/src/components/FileTree.jsx +492 -0
- package/packages/gui/src/components/MediaViewer.jsx +104 -0
- package/packages/gui/src/stores/groove.js +287 -1
- package/packages/gui/src/views/FileEditor.jsx +149 -0
- package/node_modules/@groove-dev/gui/dist/assets/index-8Kqi_LVo.js +0 -74
- package/packages/gui/dist/assets/index-8Kqi_LVo.js +0 -74
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
// GROOVE GUI — File Tree (expandable directory browser)
|
|
2
|
+
// FSL-1.1-Apache-2.0 — see LICENSE
|
|
3
|
+
|
|
4
|
+
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
5
|
+
import { useGrooveStore } from '../stores/groove';
|
|
6
|
+
|
|
7
|
+
const FILE_COLORS = {
|
|
8
|
+
javascript: '#e5c07b',
|
|
9
|
+
typescript: '#61afef',
|
|
10
|
+
css: '#c678dd',
|
|
11
|
+
html: '#e06c75',
|
|
12
|
+
json: '#4ae168',
|
|
13
|
+
markdown: '#c678dd',
|
|
14
|
+
python: '#61afef',
|
|
15
|
+
rust: '#e06c75',
|
|
16
|
+
go: '#33afbc',
|
|
17
|
+
shell: '#4ae168',
|
|
18
|
+
text: '#abb2bf',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function TreeNode({ entry, depth, activeFile, expandedDirs, onToggleDir, onFileClick, onContextMenu, renamingPath, renameValue, onRenameChange, onRenameSubmit, onRenameCancel }) {
|
|
22
|
+
const isDir = entry.type === 'dir';
|
|
23
|
+
const isExpanded = expandedDirs.has(entry.path);
|
|
24
|
+
const isActive = !isDir && entry.path === activeFile;
|
|
25
|
+
const isRenaming = renamingPath === entry.path;
|
|
26
|
+
const treeCache = useGrooveStore((s) => s.editorTreeCache);
|
|
27
|
+
const children = treeCache[entry.path] || [];
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<div
|
|
32
|
+
onClick={() => isDir ? onToggleDir(entry.path, entry.hasChildren) : onFileClick(entry.path)}
|
|
33
|
+
onContextMenu={(e) => onContextMenu(e, entry)}
|
|
34
|
+
style={{
|
|
35
|
+
...styles.row,
|
|
36
|
+
paddingLeft: 12 + depth * 16,
|
|
37
|
+
background: isActive ? 'var(--bg-active)' : 'transparent',
|
|
38
|
+
borderLeft: isActive ? '2px solid var(--accent)' : '2px solid transparent',
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
{isDir ? (
|
|
42
|
+
<span style={styles.arrow}>{isExpanded ? '\u25BE' : '\u25B8'}</span>
|
|
43
|
+
) : (
|
|
44
|
+
<span style={{ ...styles.fileDot, background: FILE_COLORS[entry.language] || FILE_COLORS.text }} />
|
|
45
|
+
)}
|
|
46
|
+
{isRenaming ? (
|
|
47
|
+
<input
|
|
48
|
+
autoFocus
|
|
49
|
+
value={renameValue}
|
|
50
|
+
onChange={(e) => onRenameChange(e.target.value)}
|
|
51
|
+
onKeyDown={(e) => {
|
|
52
|
+
if (e.key === 'Enter') onRenameSubmit();
|
|
53
|
+
if (e.key === 'Escape') onRenameCancel();
|
|
54
|
+
}}
|
|
55
|
+
onBlur={onRenameCancel}
|
|
56
|
+
onClick={(e) => e.stopPropagation()}
|
|
57
|
+
style={styles.renameInput}
|
|
58
|
+
/>
|
|
59
|
+
) : (
|
|
60
|
+
<span style={{
|
|
61
|
+
...styles.name,
|
|
62
|
+
color: isDir ? 'var(--text-primary)' : (isActive ? 'var(--text-bright)' : 'var(--text-primary)'),
|
|
63
|
+
fontWeight: isDir ? 600 : 400,
|
|
64
|
+
}}>
|
|
65
|
+
{entry.name}
|
|
66
|
+
</span>
|
|
67
|
+
)}
|
|
68
|
+
{!isDir && !isRenaming && entry.size > 0 && (
|
|
69
|
+
<span style={styles.size}>{formatSize(entry.size)}</span>
|
|
70
|
+
)}
|
|
71
|
+
</div>
|
|
72
|
+
{isDir && isExpanded && children.map((child) => (
|
|
73
|
+
<TreeNode
|
|
74
|
+
key={child.path}
|
|
75
|
+
entry={child}
|
|
76
|
+
depth={depth + 1}
|
|
77
|
+
activeFile={activeFile}
|
|
78
|
+
expandedDirs={expandedDirs}
|
|
79
|
+
onToggleDir={onToggleDir}
|
|
80
|
+
onFileClick={onFileClick}
|
|
81
|
+
onContextMenu={onContextMenu}
|
|
82
|
+
renamingPath={renamingPath}
|
|
83
|
+
renameValue={renameValue}
|
|
84
|
+
onRenameChange={onRenameChange}
|
|
85
|
+
onRenameSubmit={onRenameSubmit}
|
|
86
|
+
onRenameCancel={onRenameCancel}
|
|
87
|
+
/>
|
|
88
|
+
))}
|
|
89
|
+
</>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function formatSize(bytes) {
|
|
94
|
+
if (bytes < 1024) return `${bytes}B`;
|
|
95
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(0)}K`;
|
|
96
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)}M`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// --- Context Menu ---
|
|
100
|
+
function ContextMenu({ x, y, entry, onClose, onAction }) {
|
|
101
|
+
const ref = useRef(null);
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
const handle = (e) => {
|
|
105
|
+
if (ref.current && !ref.current.contains(e.target)) onClose();
|
|
106
|
+
};
|
|
107
|
+
document.addEventListener('mousedown', handle);
|
|
108
|
+
return () => document.removeEventListener('mousedown', handle);
|
|
109
|
+
}, [onClose]);
|
|
110
|
+
|
|
111
|
+
const isDir = entry?.type === 'dir';
|
|
112
|
+
|
|
113
|
+
const items = [
|
|
114
|
+
...(isDir ? [
|
|
115
|
+
{ label: 'New File Here', action: 'newFileIn' },
|
|
116
|
+
{ label: 'New Folder Here', action: 'newDirIn' },
|
|
117
|
+
{ sep: true },
|
|
118
|
+
] : []),
|
|
119
|
+
{ label: 'Rename', action: 'rename' },
|
|
120
|
+
{ label: 'Delete', action: 'delete', danger: true },
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<div ref={ref} style={{ ...styles.contextMenu, left: x, top: y }}>
|
|
125
|
+
{items.map((item, i) =>
|
|
126
|
+
item.sep ? (
|
|
127
|
+
<div key={i} style={styles.contextSep} />
|
|
128
|
+
) : (
|
|
129
|
+
<div
|
|
130
|
+
key={item.action}
|
|
131
|
+
onClick={() => { onAction(item.action, entry); onClose(); }}
|
|
132
|
+
style={{
|
|
133
|
+
...styles.contextItem,
|
|
134
|
+
color: item.danger ? 'var(--red)' : 'var(--text-primary)',
|
|
135
|
+
}}
|
|
136
|
+
>
|
|
137
|
+
{item.label}
|
|
138
|
+
</div>
|
|
139
|
+
)
|
|
140
|
+
)}
|
|
141
|
+
</div>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// --- Inline New-Item Input ---
|
|
146
|
+
function InlineInput({ placeholder, onSubmit, onCancel, depth }) {
|
|
147
|
+
const [value, setValue] = useState('');
|
|
148
|
+
return (
|
|
149
|
+
<div style={{ ...styles.row, paddingLeft: 12 + (depth || 0) * 16 }}>
|
|
150
|
+
<input
|
|
151
|
+
autoFocus
|
|
152
|
+
placeholder={placeholder}
|
|
153
|
+
value={value}
|
|
154
|
+
onChange={(e) => setValue(e.target.value)}
|
|
155
|
+
onKeyDown={(e) => {
|
|
156
|
+
if (e.key === 'Enter' && value.trim()) onSubmit(value.trim());
|
|
157
|
+
if (e.key === 'Escape') onCancel();
|
|
158
|
+
}}
|
|
159
|
+
onBlur={onCancel}
|
|
160
|
+
style={styles.renameInput}
|
|
161
|
+
/>
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// --- Main FileTree ---
|
|
167
|
+
export default function FileTree() {
|
|
168
|
+
const treeCache = useGrooveStore((s) => s.editorTreeCache);
|
|
169
|
+
const activeFile = useGrooveStore((s) => s.editorActiveFile);
|
|
170
|
+
const fetchTreeDir = useGrooveStore((s) => s.fetchTreeDir);
|
|
171
|
+
const openFile = useGrooveStore((s) => s.openFile);
|
|
172
|
+
const createFile = useGrooveStore((s) => s.createFile);
|
|
173
|
+
const createDir = useGrooveStore((s) => s.createDir);
|
|
174
|
+
const deleteFile = useGrooveStore((s) => s.deleteFile);
|
|
175
|
+
const renameFile = useGrooveStore((s) => s.renameFile);
|
|
176
|
+
|
|
177
|
+
const [expandedDirs, setExpandedDirs] = useState(new Set(['']));
|
|
178
|
+
const [filter, setFilter] = useState('');
|
|
179
|
+
|
|
180
|
+
// Context menu state
|
|
181
|
+
const [contextMenu, setContextMenu] = useState(null); // { x, y, entry }
|
|
182
|
+
|
|
183
|
+
// Inline creation state
|
|
184
|
+
const [creating, setCreating] = useState(null); // { type: 'file'|'dir', parentPath: '' }
|
|
185
|
+
|
|
186
|
+
// Rename state
|
|
187
|
+
const [renamingPath, setRenamingPath] = useState(null);
|
|
188
|
+
const [renameValue, setRenameValue] = useState('');
|
|
189
|
+
|
|
190
|
+
// Fetch root on mount
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
fetchTreeDir('');
|
|
193
|
+
}, [fetchTreeDir]);
|
|
194
|
+
|
|
195
|
+
const onToggleDir = useCallback((path, hasChildren) => {
|
|
196
|
+
setExpandedDirs((prev) => {
|
|
197
|
+
const next = new Set(prev);
|
|
198
|
+
if (next.has(path)) {
|
|
199
|
+
next.delete(path);
|
|
200
|
+
} else {
|
|
201
|
+
next.add(path);
|
|
202
|
+
if (hasChildren || !treeCache[path]) {
|
|
203
|
+
fetchTreeDir(path);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return next;
|
|
207
|
+
});
|
|
208
|
+
}, [fetchTreeDir, treeCache]);
|
|
209
|
+
|
|
210
|
+
const onContextMenu = useCallback((e, entry) => {
|
|
211
|
+
e.preventDefault();
|
|
212
|
+
e.stopPropagation();
|
|
213
|
+
setContextMenu({ x: e.clientX, y: e.clientY, entry });
|
|
214
|
+
}, []);
|
|
215
|
+
|
|
216
|
+
const handleContextAction = useCallback(async (action, entry) => {
|
|
217
|
+
const parentDir = entry.path.includes('/') ? entry.path.split('/').slice(0, -1).join('/') : '';
|
|
218
|
+
|
|
219
|
+
switch (action) {
|
|
220
|
+
case 'newFileIn':
|
|
221
|
+
setCreating({ type: 'file', parentPath: entry.path });
|
|
222
|
+
// Ensure dir is expanded
|
|
223
|
+
setExpandedDirs((prev) => {
|
|
224
|
+
const next = new Set(prev);
|
|
225
|
+
next.add(entry.path);
|
|
226
|
+
if (!treeCache[entry.path]) fetchTreeDir(entry.path);
|
|
227
|
+
return next;
|
|
228
|
+
});
|
|
229
|
+
break;
|
|
230
|
+
case 'newDirIn':
|
|
231
|
+
setCreating({ type: 'dir', parentPath: entry.path });
|
|
232
|
+
setExpandedDirs((prev) => {
|
|
233
|
+
const next = new Set(prev);
|
|
234
|
+
next.add(entry.path);
|
|
235
|
+
if (!treeCache[entry.path]) fetchTreeDir(entry.path);
|
|
236
|
+
return next;
|
|
237
|
+
});
|
|
238
|
+
break;
|
|
239
|
+
case 'rename':
|
|
240
|
+
setRenamingPath(entry.path);
|
|
241
|
+
setRenameValue(entry.name);
|
|
242
|
+
break;
|
|
243
|
+
case 'delete':
|
|
244
|
+
if (confirm(`Delete "${entry.name}"?`)) {
|
|
245
|
+
await deleteFile(entry.path);
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
}, [deleteFile, fetchTreeDir, treeCache]);
|
|
250
|
+
|
|
251
|
+
const handleCreate = useCallback(async (name) => {
|
|
252
|
+
if (!creating) return;
|
|
253
|
+
const fullPath = creating.parentPath ? `${creating.parentPath}/${name}` : name;
|
|
254
|
+
const ok = creating.type === 'file'
|
|
255
|
+
? await createFile(fullPath)
|
|
256
|
+
: await createDir(fullPath);
|
|
257
|
+
setCreating(null);
|
|
258
|
+
if (ok && creating.type === 'file') openFile(fullPath);
|
|
259
|
+
}, [creating, createFile, createDir, openFile]);
|
|
260
|
+
|
|
261
|
+
const handleRenameSubmit = useCallback(async () => {
|
|
262
|
+
if (!renamingPath || !renameValue.trim()) { setRenamingPath(null); return; }
|
|
263
|
+
const parentDir = renamingPath.includes('/') ? renamingPath.split('/').slice(0, -1).join('/') : '';
|
|
264
|
+
const newPath = parentDir ? `${parentDir}/${renameValue.trim()}` : renameValue.trim();
|
|
265
|
+
if (newPath !== renamingPath) {
|
|
266
|
+
await renameFile(renamingPath, newPath);
|
|
267
|
+
}
|
|
268
|
+
setRenamingPath(null);
|
|
269
|
+
}, [renamingPath, renameValue, renameFile]);
|
|
270
|
+
|
|
271
|
+
// Handle root-level context menu (right-click on empty space)
|
|
272
|
+
const handleTreeContextMenu = useCallback((e) => {
|
|
273
|
+
// Only if click is on the tree background, not a node
|
|
274
|
+
if (e.target === e.currentTarget) {
|
|
275
|
+
e.preventDefault();
|
|
276
|
+
setContextMenu({ x: e.clientX, y: e.clientY, entry: { type: 'dir', path: '', name: 'root' } });
|
|
277
|
+
}
|
|
278
|
+
}, []);
|
|
279
|
+
|
|
280
|
+
const rootEntries = treeCache[''] || [];
|
|
281
|
+
|
|
282
|
+
// Client-side filter — search all cached entries recursively
|
|
283
|
+
const filtered = filter
|
|
284
|
+
? rootEntries.filter((e) => e.name.toLowerCase().includes(filter.toLowerCase()))
|
|
285
|
+
: rootEntries;
|
|
286
|
+
|
|
287
|
+
// Calculate inline input depth based on parent
|
|
288
|
+
const creatingDepth = creating
|
|
289
|
+
? (creating.parentPath === '' ? 0 : creating.parentPath.split('/').length)
|
|
290
|
+
: 0;
|
|
291
|
+
|
|
292
|
+
return (
|
|
293
|
+
<div style={styles.container}>
|
|
294
|
+
{/* Toolbar */}
|
|
295
|
+
<div style={styles.toolbar}>
|
|
296
|
+
<span style={styles.toolbarTitle}>FILES</span>
|
|
297
|
+
<div style={styles.toolbarActions}>
|
|
298
|
+
<button
|
|
299
|
+
onClick={() => setCreating({ type: 'file', parentPath: '' })}
|
|
300
|
+
title="New File"
|
|
301
|
+
style={styles.toolbarBtn}
|
|
302
|
+
>
|
|
303
|
+
+f
|
|
304
|
+
</button>
|
|
305
|
+
<button
|
|
306
|
+
onClick={() => setCreating({ type: 'dir', parentPath: '' })}
|
|
307
|
+
title="New Folder"
|
|
308
|
+
style={styles.toolbarBtn}
|
|
309
|
+
>
|
|
310
|
+
+d
|
|
311
|
+
</button>
|
|
312
|
+
<button
|
|
313
|
+
onClick={() => setExpandedDirs(new Set(['']))}
|
|
314
|
+
title="Collapse All"
|
|
315
|
+
style={styles.toolbarBtn}
|
|
316
|
+
>
|
|
317
|
+
{'\u2191'}
|
|
318
|
+
</button>
|
|
319
|
+
<button
|
|
320
|
+
onClick={() => fetchTreeDir('')}
|
|
321
|
+
title="Refresh"
|
|
322
|
+
style={styles.toolbarBtn}
|
|
323
|
+
>
|
|
324
|
+
{'\u21BB'}
|
|
325
|
+
</button>
|
|
326
|
+
</div>
|
|
327
|
+
</div>
|
|
328
|
+
|
|
329
|
+
{/* Search */}
|
|
330
|
+
<div style={styles.searchWrap}>
|
|
331
|
+
<input
|
|
332
|
+
type="text"
|
|
333
|
+
placeholder="Filter..."
|
|
334
|
+
value={filter}
|
|
335
|
+
onChange={(e) => setFilter(e.target.value)}
|
|
336
|
+
style={styles.searchInput}
|
|
337
|
+
/>
|
|
338
|
+
</div>
|
|
339
|
+
|
|
340
|
+
{/* Tree */}
|
|
341
|
+
<div style={styles.tree} onContextMenu={handleTreeContextMenu}>
|
|
342
|
+
{filtered.length === 0 && !creating && (
|
|
343
|
+
<div style={styles.empty}>
|
|
344
|
+
{rootEntries.length === 0 ? 'Loading...' : 'No matches'}
|
|
345
|
+
</div>
|
|
346
|
+
)}
|
|
347
|
+
|
|
348
|
+
{/* Inline creation at root level */}
|
|
349
|
+
{creating && creating.parentPath === '' && (
|
|
350
|
+
<InlineInput
|
|
351
|
+
placeholder={creating.type === 'file' ? 'filename.ext' : 'folder-name'}
|
|
352
|
+
onSubmit={handleCreate}
|
|
353
|
+
onCancel={() => setCreating(null)}
|
|
354
|
+
depth={0}
|
|
355
|
+
/>
|
|
356
|
+
)}
|
|
357
|
+
|
|
358
|
+
{filtered.map((entry) => (
|
|
359
|
+
<React.Fragment key={entry.path}>
|
|
360
|
+
<TreeNode
|
|
361
|
+
entry={entry}
|
|
362
|
+
depth={0}
|
|
363
|
+
activeFile={activeFile}
|
|
364
|
+
expandedDirs={expandedDirs}
|
|
365
|
+
onToggleDir={onToggleDir}
|
|
366
|
+
onFileClick={openFile}
|
|
367
|
+
onContextMenu={onContextMenu}
|
|
368
|
+
renamingPath={renamingPath}
|
|
369
|
+
renameValue={renameValue}
|
|
370
|
+
onRenameChange={setRenameValue}
|
|
371
|
+
onRenameSubmit={handleRenameSubmit}
|
|
372
|
+
onRenameCancel={() => setRenamingPath(null)}
|
|
373
|
+
/>
|
|
374
|
+
{/* Inline creation inside this dir */}
|
|
375
|
+
{creating && creating.parentPath === entry.path && expandedDirs.has(entry.path) && (
|
|
376
|
+
<InlineInput
|
|
377
|
+
placeholder={creating.type === 'file' ? 'filename.ext' : 'folder-name'}
|
|
378
|
+
onSubmit={handleCreate}
|
|
379
|
+
onCancel={() => setCreating(null)}
|
|
380
|
+
depth={1}
|
|
381
|
+
/>
|
|
382
|
+
)}
|
|
383
|
+
</React.Fragment>
|
|
384
|
+
))}
|
|
385
|
+
</div>
|
|
386
|
+
|
|
387
|
+
{/* Context Menu */}
|
|
388
|
+
{contextMenu && (
|
|
389
|
+
<ContextMenu
|
|
390
|
+
x={contextMenu.x}
|
|
391
|
+
y={contextMenu.y}
|
|
392
|
+
entry={contextMenu.entry}
|
|
393
|
+
onClose={() => setContextMenu(null)}
|
|
394
|
+
onAction={handleContextAction}
|
|
395
|
+
/>
|
|
396
|
+
)}
|
|
397
|
+
</div>
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const styles = {
|
|
402
|
+
container: {
|
|
403
|
+
display: 'flex', flexDirection: 'column',
|
|
404
|
+
height: '100%', background: 'var(--bg-chrome)',
|
|
405
|
+
position: 'relative',
|
|
406
|
+
},
|
|
407
|
+
toolbar: {
|
|
408
|
+
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
|
|
409
|
+
padding: '6px 10px',
|
|
410
|
+
borderBottom: '1px solid var(--border)',
|
|
411
|
+
},
|
|
412
|
+
toolbarTitle: {
|
|
413
|
+
fontSize: 10, fontWeight: 700, letterSpacing: 1,
|
|
414
|
+
color: 'var(--text-dim)', textTransform: 'uppercase',
|
|
415
|
+
},
|
|
416
|
+
toolbarActions: {
|
|
417
|
+
display: 'flex', gap: 2,
|
|
418
|
+
},
|
|
419
|
+
toolbarBtn: {
|
|
420
|
+
background: 'none', border: 'none',
|
|
421
|
+
color: 'var(--text-dim)', fontSize: 11, fontWeight: 600,
|
|
422
|
+
cursor: 'pointer', fontFamily: 'var(--font)',
|
|
423
|
+
padding: '2px 5px', borderRadius: 3,
|
|
424
|
+
lineHeight: 1,
|
|
425
|
+
},
|
|
426
|
+
searchWrap: {
|
|
427
|
+
padding: '6px 8px',
|
|
428
|
+
borderBottom: '1px solid var(--border)',
|
|
429
|
+
},
|
|
430
|
+
searchInput: {
|
|
431
|
+
width: '100%', padding: '5px 8px',
|
|
432
|
+
background: 'var(--bg-base)', border: '1px solid var(--border)',
|
|
433
|
+
borderRadius: 3, color: 'var(--text-primary)',
|
|
434
|
+
fontSize: 11, fontFamily: 'var(--font)',
|
|
435
|
+
outline: 'none',
|
|
436
|
+
},
|
|
437
|
+
tree: {
|
|
438
|
+
flex: 1, overflowY: 'auto', overflowX: 'hidden',
|
|
439
|
+
},
|
|
440
|
+
row: {
|
|
441
|
+
display: 'flex', alignItems: 'center', gap: 6,
|
|
442
|
+
padding: '4px 12px', cursor: 'pointer',
|
|
443
|
+
transition: 'background 0.08s',
|
|
444
|
+
whiteSpace: 'nowrap',
|
|
445
|
+
},
|
|
446
|
+
arrow: {
|
|
447
|
+
fontSize: 10, color: 'var(--text-muted)',
|
|
448
|
+
width: 10, flexShrink: 0, textAlign: 'center',
|
|
449
|
+
},
|
|
450
|
+
fileDot: {
|
|
451
|
+
width: 6, height: 6, borderRadius: '50%',
|
|
452
|
+
flexShrink: 0,
|
|
453
|
+
},
|
|
454
|
+
name: {
|
|
455
|
+
fontSize: 12, overflow: 'hidden', textOverflow: 'ellipsis',
|
|
456
|
+
flex: 1, minWidth: 0,
|
|
457
|
+
},
|
|
458
|
+
size: {
|
|
459
|
+
fontSize: 9, color: 'var(--text-muted)', flexShrink: 0,
|
|
460
|
+
},
|
|
461
|
+
empty: {
|
|
462
|
+
padding: 16, textAlign: 'center',
|
|
463
|
+
fontSize: 11, color: 'var(--text-dim)',
|
|
464
|
+
},
|
|
465
|
+
renameInput: {
|
|
466
|
+
flex: 1, padding: '2px 6px',
|
|
467
|
+
background: 'var(--bg-base)', border: '1px solid var(--accent)',
|
|
468
|
+
borderRadius: 2, color: 'var(--text-bright)',
|
|
469
|
+
fontSize: 12, fontFamily: 'var(--font)',
|
|
470
|
+
outline: 'none', minWidth: 0,
|
|
471
|
+
},
|
|
472
|
+
|
|
473
|
+
// Context menu
|
|
474
|
+
contextMenu: {
|
|
475
|
+
position: 'fixed', zIndex: 300,
|
|
476
|
+
background: 'var(--bg-surface)',
|
|
477
|
+
border: '1px solid var(--border)',
|
|
478
|
+
borderRadius: 4, padding: '4px 0',
|
|
479
|
+
minWidth: 160,
|
|
480
|
+
boxShadow: '0 8px 24px rgba(0,0,0,0.4)',
|
|
481
|
+
fontFamily: 'var(--font)',
|
|
482
|
+
},
|
|
483
|
+
contextItem: {
|
|
484
|
+
padding: '6px 14px', fontSize: 11,
|
|
485
|
+
cursor: 'pointer',
|
|
486
|
+
transition: 'background 0.08s',
|
|
487
|
+
},
|
|
488
|
+
contextSep: {
|
|
489
|
+
height: 1, background: 'var(--border)',
|
|
490
|
+
margin: '4px 0',
|
|
491
|
+
},
|
|
492
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// GROOVE GUI — Media Viewer (images + video)
|
|
2
|
+
// FSL-1.1-Apache-2.0 — see LICENSE
|
|
3
|
+
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
const IMAGE_EXTS = new Set(['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp', 'ico', 'bmp', 'avif']);
|
|
7
|
+
const VIDEO_EXTS = new Set(['mp4', 'webm', 'mov', 'avi', 'mkv', 'ogv']);
|
|
8
|
+
|
|
9
|
+
export function isMediaFile(path) {
|
|
10
|
+
const ext = path.split('.').pop()?.toLowerCase();
|
|
11
|
+
return IMAGE_EXTS.has(ext) || VIDEO_EXTS.has(ext);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function isImageFile(path) {
|
|
15
|
+
const ext = path.split('.').pop()?.toLowerCase();
|
|
16
|
+
return IMAGE_EXTS.has(ext);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default function MediaViewer({ path }) {
|
|
20
|
+
const ext = path.split('.').pop()?.toLowerCase();
|
|
21
|
+
const rawUrl = `/api/files/raw?path=${encodeURIComponent(path)}`;
|
|
22
|
+
const filename = path.split('/').pop();
|
|
23
|
+
const isImage = IMAGE_EXTS.has(ext);
|
|
24
|
+
const isVideo = VIDEO_EXTS.has(ext);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div style={styles.container}>
|
|
28
|
+
<div style={styles.header}>
|
|
29
|
+
<span style={styles.filename}>{filename}</span>
|
|
30
|
+
<span style={styles.badge}>{ext.toUpperCase()}</span>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div style={styles.preview}>
|
|
34
|
+
{isImage && (
|
|
35
|
+
<img
|
|
36
|
+
src={rawUrl}
|
|
37
|
+
alt={filename}
|
|
38
|
+
style={styles.image}
|
|
39
|
+
draggable={false}
|
|
40
|
+
/>
|
|
41
|
+
)}
|
|
42
|
+
{isVideo && (
|
|
43
|
+
<video
|
|
44
|
+
src={rawUrl}
|
|
45
|
+
controls
|
|
46
|
+
style={styles.video}
|
|
47
|
+
>
|
|
48
|
+
Your browser does not support this video format.
|
|
49
|
+
</video>
|
|
50
|
+
)}
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<div style={styles.footer}>
|
|
54
|
+
<a href={rawUrl} target="_blank" rel="noopener noreferrer" style={styles.link}>
|
|
55
|
+
Open in new tab
|
|
56
|
+
</a>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const styles = {
|
|
63
|
+
container: {
|
|
64
|
+
flex: 1, display: 'flex', flexDirection: 'column',
|
|
65
|
+
background: 'var(--bg-base)', overflow: 'hidden',
|
|
66
|
+
},
|
|
67
|
+
header: {
|
|
68
|
+
padding: '10px 16px',
|
|
69
|
+
borderBottom: '1px solid var(--border)',
|
|
70
|
+
display: 'flex', alignItems: 'center', gap: 8,
|
|
71
|
+
},
|
|
72
|
+
filename: {
|
|
73
|
+
fontSize: 12, color: 'var(--text-bright)', fontWeight: 500,
|
|
74
|
+
},
|
|
75
|
+
badge: {
|
|
76
|
+
fontSize: 9, fontWeight: 700, letterSpacing: 0.5,
|
|
77
|
+
color: 'var(--text-dim)', background: 'var(--bg-active)',
|
|
78
|
+
padding: '2px 6px', borderRadius: 3,
|
|
79
|
+
},
|
|
80
|
+
preview: {
|
|
81
|
+
flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
82
|
+
overflow: 'auto', padding: 24,
|
|
83
|
+
background: 'repeating-conic-gradient(var(--bg-surface) 0% 25%, var(--bg-base) 0% 50%) 50% / 20px 20px',
|
|
84
|
+
},
|
|
85
|
+
image: {
|
|
86
|
+
maxWidth: '100%', maxHeight: '100%',
|
|
87
|
+
objectFit: 'contain', borderRadius: 4,
|
|
88
|
+
boxShadow: '0 4px 16px rgba(0,0,0,0.3)',
|
|
89
|
+
},
|
|
90
|
+
video: {
|
|
91
|
+
maxWidth: '100%', maxHeight: '100%',
|
|
92
|
+
borderRadius: 4, outline: 'none',
|
|
93
|
+
boxShadow: '0 4px 16px rgba(0,0,0,0.3)',
|
|
94
|
+
},
|
|
95
|
+
footer: {
|
|
96
|
+
padding: '8px 16px',
|
|
97
|
+
borderTop: '1px solid var(--border)',
|
|
98
|
+
display: 'flex', alignItems: 'center',
|
|
99
|
+
},
|
|
100
|
+
link: {
|
|
101
|
+
fontSize: 11, color: 'var(--accent)',
|
|
102
|
+
textDecoration: 'none', fontFamily: 'var(--font)',
|
|
103
|
+
},
|
|
104
|
+
};
|