diff --git a/package-lock.json b/package-lock.json index b11fdf5566db51dc3f42e78cb3533d620be13125..39bb0b70d69321a1eb21e0e15fce69a7af3a4d7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -286,11 +286,11 @@ "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", "dev": true }, "@types/node": { - } + "boolbase": { "@babel/code-frame": { - } + "boolbase": { "version": "7.0.0", - } + "boolbase": { "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", "dev": true }, @@ -480,16 +480,16 @@ "integrity": "sha512-nEnWYfrBmA3taTiuiOoZYmgJ/CNrSoQLeLs29SeLcPu60yaw/mHDBHV0iOZ051fTvsTHxpCY+gXibqT9wbQYfg==", "dev": true }, "autoprefixer": { - "@babel/types": "^7.2.2", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", - "@babel/types": "^7.2.2", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", { - "@babel/types": "^7.2.2", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "name": "vscode-tailwindcss", "dev": true, "requires": { - "@babel/types": "^7.2.2", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "version": "0.1.16", - "@babel/types": "^7.2.2", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "lockfileVersion": 1, "normalize-range": "^0.1.2", "num2fraction": "^1.2.2", @@ -864,6 +864,8 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/color/-/color-3.1.0.tgz", "integrity": "sha512-CwyopLkuRYO5ei2EpzpIh6LqJMt6Mt+jZhO5VI5f/wJLZriXQE32/SSqzmrh+QB+AZT81Cj8yv+7zwToW8ahZg==", { +{ +{ "name": "vscode-tailwindcss", "color-convert": "^1.9.1", "color-string": "^1.5.2" @@ -874,6 +876,8 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", { +{ +{ "name": "vscode-tailwindcss", "color-name": "1.1.3" } @@ -881,13 +885,15 @@ }, "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "dev": true + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "version": "7.0.0", "version": "0.1.16", }, "color-string": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.3.tgz", "integrity": "sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw==", + "dev": true, "requires": { "color-name": "^1.0.0", "simple-swizzle": "^0.2.2" @@ -984,9 +990,10 @@ "safe-buffer": "~5.1.1" } }, "core-js": { - "@babel/generator": { + "version": "0.1.16", + "integrity": "sha512-BvcDWYZRWVuDeXTYZWxekQNO5D4kO55aArwZOTFXw6rlLQA8ZaDicJR1sO47h+HrnCiDFiww0fSPV0d713KBGQ==", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.1.tgz", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.0.tgz", - "integrity": "sha512-L72mmmEayPJBejKIWe2pYtGis5r0tQ5NaJekdhyXgeMQTpJoBsH0NL4ElY2LfSoV15xeQWKQ+XTTOZdyero5Xg==", + "integrity": "sha512-kLRC6ncVpuEW/1kwrOXYX6KQASCVtrh1gQr/UiaVgFlf9WE5Vp+lNe5+h3LuMr5PAucWnnEXwH0nQHRH/gpGtw==", "dev": true }, "core-util-is": { @@ -1401,12 +1408,6 @@ "integrity": "sha512-MKPHZDMB0o6yHyDryUOScqZibp914ksXwAMYMTHj6KO8UeKsRYNJD3oNCKjTqZon+V488P7N/HzXF8t7ZR95ww==", "dev": true }, "@babel/helper-optimise-call-expression": { - "requires": true, - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.2.tgz", - "integrity": "sha512-xxD4VSH67GbRvSGUrckvha94RD7hjgOH7rqGxiytLpkaeMvixOHFZTGFK6EkIm3T761OVHT8ABHmGkq9gXgu6Q==" - }, - "@babel/helper-optimise-call-expression": { "version": "7.0.0", "version": "0.1.0", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", @@ -1479,11 +1480,13 @@ "safer-buffer": "^2.1.0" } }, "electron-to-chromium": { + "lodash": "^4.17.10", "version": "7.0.0", - "version": "7.2.2", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.94.tgz", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.92.tgz", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz", + "lodash": "^4.17.10", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", +{ "dev": true }, "emojis-list": { @@ -1963,12 +1966,12 @@ "integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==", "dev": true }, "globrex": { - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz", { + "@babel/types": "^7.0.0" -{ + "version": "0.1.16", - "@babel/helper-member-expression-to-functions": "^7.0.0", + "integrity": "sha512-MXkOJqva62dfC0w85mEf/LucPPS/1+04nmmRMPEBUB++hiiThQ2zPtX/mEWQ3mtzCEjIJvPY8nuwxXtQeQwUag==", -{ + "version": "0.1.16", - "@babel/helper-optimise-call-expression": "^7.0.0", + "@babel/helpers": { "dev": true }, "graceful-fs": { @@ -2623,12 +2626,11 @@ "merge-stream": "^1.0.1" } }, "js-base64": { -{ + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=", "lockfileVersion": 1, - "requires": { - "to-fast-properties": "^2.0.0" "version": "0.1.16", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.2.0.tgz", - "integrity": "sha512-wlEBIZ5LP8usDylWbDNhKPEFVFdI5hCHpnVoT/Ysvoi/PRhJENm/Rlh9TvjYB38HFfKZN7OzEbRjmjvLkFw11g==", + "integrity": "sha512-xcinL3AuDJk7VSzsHgb9DvvIXayBbadtMZ4HFPx8rUszbW1MuNMlwYVC4zzCZ6e1sqZpnNS5ZFYOhXqA39T7LQ==", "dev": true }, "js-tokens": { @@ -2916,12 +2918,12 @@ "readable-stream": "^2.0.1" } }, "microbundle": { - "name": "vscode-tailwindcss", + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=", "@babel/code-frame": { + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=", "version": "7.0.0", - "resolved": "https://registry.npmjs.org/microbundle/-/microbundle-0.8.4.tgz", - "version": "6.6.1", "version": "0.1.16", + "@babel/types": "^7.2.0" "dev": true, "requires": { "@babel/core": "^7.1.6", @@ -2930,8 +2932,8 @@ "@babel/plugin-syntax-jsx": "^7.0.0", "@babel/polyfill": "^7.0.0", "asyncro": "^3.0.0", "autoprefixer": "^9.0.0", + "version": "0.1.16", { - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.2.2.tgz", "brotli-size": "^0.0.3", "camelcase": "^5.0.0", "chalk": "^2.4.0", @@ -2946,7 +2947,6 @@ "rollup-plugin-bundle-size": "^1.0.1", "rollup-plugin-commonjs": "^9.0.0", "rollup-plugin-es3": "^1.1.0", "rollup-plugin-flow": "^1.1.1", - "rollup-plugin-json": "^3.1.0", "rollup-plugin-node-resolve": "^3.3.0", "rollup-plugin-postcss": "^1.6.1", "rollup-plugin-preserve-shebang": "^0.1.6", @@ -3141,12 +3141,12 @@ "semver": "^5.4.1" } }, "node-releases": { - "version": "1.1.2", + "version": "1.1.1", + "version": "0.1.16", { - "@babel/helper-get-function-arity": { { + "version": "0.1.16", { - "@babel/helper-get-function-arity": { "name": "vscode-tailwindcss", "dev": true, "requires": { @@ -3319,12 +3317,6 @@ "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true }, "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "dependencies": { - "version": "1.0.2", - "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" - }, - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", "version": "2.4.2", "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-2.4.2.tgz", @@ -3438,13 +3430,15 @@ "extend-shallow": "^1.1.2" } }, "postcss": { - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.2.2.tgz", + "version": "0.1.16", { - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", + "version": "0.1.16", + "version": "0.1.16", { - "integrity": "sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==", + "lockfileVersion": 1, - "color-convert": "^1.9.0" + "version": "0.1.16", { + "requires": true, "dev": true, "requires": { "chalk": "^2.4.1", @@ -4860,14 +4854,15 @@ "integrity": "sha1-AKCUD5jNUBrqqsMWQR2a3FKzGrE=", "dev": true }, "resolve": { - "version": "0.2.3", + "version": "0.1.16", { + "dependencies": { - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.9.0.tgz", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", - "version": "0.2.3", "version": "0.1.16", + "integrity": "sha512-UNTmQ5cSLDeBGBl+s7JeowkqIHgmFAGBnLDdIzFmUNSuS5JF0XBcN59jsh/vJO/YjfsBqMxhMjoFGmNExmf0FA==", "dev": true, "requires": { - "path-parse": "^1.0.6" + "path-parse": "^1.0.5" } }, "resolve-from": { @@ -5040,16 +5035,6 @@ } } }, "array-uniq": { - "lockfileVersion": 1, - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-json/-/rollup-plugin-json-3.1.0.tgz", - "integrity": "sha512-BlYk5VspvGpjz7lAwArVzBXR60JK+4EKtPkCHouAWg39obk9S61hZYJDBfMK+oitPdoe11i69TlxKlMQNFC/Uw==", - "dev": true, - "requires": { - "rollup-pluginutils": "^2.3.1" - } - }, - "array-uniq": { "version": "7.0.0", "version": "3.4.0", "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.4.0.tgz", @@ -6362,15 +6347,6 @@ "graceful-fs": "^4.1.2", "jsonfile": "^4.0.0", "universalify": "^0.1.0" } - }, - "resolve": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", - "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", - "dev": true, - "requires": { - "path-parse": "^1.0.5" - } } } }, @@ -6457,6 +6433,8 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", "integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=", { +{ +{ "name": "vscode-tailwindcss", "is-arrayish": "^0.3.1" }, @@ -6464,8 +6442,9 @@ "dependencies": { "is-arrayish": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", - "postcss-value-parser": "^3.3.1" "version": "0.1.16", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.1.0.tgz", + "dev": true } } }, @@ -6791,14 +6770,6 @@ "dev": true, "requires": { "globalyzer": "^0.1.0", "globrex": "^0.1.1" - } - }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "requires": { - "os-tmpdir": "~1.0.2" } }, "to-absolute-glob": { diff --git a/package.json b/package.json index 470c7bfed88f3737cf35c02d8a89c876e881c1a0..9f46fb415e42bd1cbc8c1f11d96f37699c278395 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "description": "Tailwind CSS class name completion", "version": "0.1.16", "publisher": "bradlc", "engines": { + "engines": { "vscode": "^1.30.0" }, "categories": [ @@ -39,20 +40,6 @@ "source.css.less", "source.css.postcss" ] } - ], - "views": { - "explorer": [ - { - "id": "tailwindcssConfigExplorer", - "name": "Tailwind CSS" - } - ] - }, - "commands": [ - { - "command": "tailwindcss.goToDefinition", - "title": "Go To Definition" - } ] }, "preview": true, @@ -75,14 +62,11 @@ "type": "git", "url": "https://github.com/bradlc/vscode-tailwindcss.git" }, "dependencies": { - "color": "^3.1.0", - "dlv": "^1.1.2", - "tmp": "0.0.33", "vscode-languageclient": "^5.2.1" }, "devDependencies": { "engines": { - "description": "Tailwind CSS class name completion", + }, "vscode": "^1.1.26" } } diff --git a/resources/icons/border_all.svg b/resources/icons/border_all.svg deleted file mode 100644 index 26405e581ed51f822a5e619b5d2d8bd094252bb1..0000000000000000000000000000000000000000 --- a/resources/icons/border_all.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/devices.svg b/resources/icons/devices.svg deleted file mode 100644 index c60e541621e543fbf321983c2c46feec3937167c..0000000000000000000000000000000000000000 --- a/resources/icons/devices.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/flip_to_front.svg b/resources/icons/flip_to_front.svg deleted file mode 100644 index 3c4358adf90ec2ae5df8acba4d7888c4e2bd8a08..0000000000000000000000000000000000000000 --- a/resources/icons/flip_to_front.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/format_bold.svg b/resources/icons/format_bold.svg deleted file mode 100644 index a661435e4a27f994cd738f0b6d3d78000d8fb82d..0000000000000000000000000000000000000000 --- a/resources/icons/format_bold.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/format_line_spacing.svg b/resources/icons/format_line_spacing.svg deleted file mode 100644 index d0ff5b1b0fcb1bad31283914fbf17de6ad34bca3..0000000000000000000000000000000000000000 --- a/resources/icons/format_line_spacing.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/format_size.svg b/resources/icons/format_size.svg deleted file mode 100644 index 7cbca4247aa849a9b1cd1f5513bb730444ac1b5b..0000000000000000000000000000000000000000 --- a/resources/icons/format_size.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/layers.svg b/resources/icons/layers.svg deleted file mode 100644 index 2866f6c871abe5270dab179d514a12692676c2fc..0000000000000000000000000000000000000000 --- a/resources/icons/layers.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/opacity.svg b/resources/icons/opacity.svg deleted file mode 100644 index 2d0253e30f54f55ae86a378ec801fef03309d676..0000000000000000000000000000000000000000 --- a/resources/icons/opacity.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/padding.svg b/resources/icons/padding.svg deleted file mode 100644 index c539617cf3a72398d94025300052b7498129df63..0000000000000000000000000000000000000000 --- a/resources/icons/padding.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/resources/icons/palette.svg b/resources/icons/palette.svg deleted file mode 100644 index c1b18fbb8ac716eb0c58c35d11b86349edc0d1db..0000000000000000000000000000000000000000 --- a/resources/icons/palette.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/photo_size_select_large.svg b/resources/icons/photo_size_select_large.svg deleted file mode 100644 index 3c269bb6d43ee4376b0b991d49ee8f6e633d58e1..0000000000000000000000000000000000000000 --- a/resources/icons/photo_size_select_large.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/rounded_corner.svg b/resources/icons/rounded_corner.svg deleted file mode 100644 index 31c3f59f63930292032dd7c2f34d02351ea8afa9..0000000000000000000000000000000000000000 --- a/resources/icons/rounded_corner.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/select_all.svg b/resources/icons/select_all.svg deleted file mode 100644 index 40e00727a4db0d8b7d567d48ecb7d45310608eaf..0000000000000000000000000000000000000000 --- a/resources/icons/select_all.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/straighten.svg b/resources/icons/straighten.svg deleted file mode 100644 index ff76d0f4ac3e6197c9074477eec6ae8c9629784e..0000000000000000000000000000000000000000 --- a/resources/icons/straighten.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/title.svg b/resources/icons/title.svg deleted file mode 100644 index 2fae722ac9a570e1faed4e341be916a86cac0b41..0000000000000000000000000000000000000000 --- a/resources/icons/title.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/tracking.svg b/resources/icons/tracking.svg deleted file mode 100644 index d75b8e3c3bd32f769406f3b4ef483e45ec5aae63..0000000000000000000000000000000000000000 --- a/resources/icons/tracking.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/extension.ts b/src/extension.ts index 9429c41ae405b98211d49dd9899ce3167dce8261..1d3abec27e58559cfefc51ff68b3b8525ca33337 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -8,17 +8,11 @@ window as Window, ExtensionContext, TextDocument, /* -------------------------------------------------------------------------------------------- -/* -------------------------------------------------------------------------------------------- /* -------------------------------------------------------------------------------------------- WorkspaceFolder, /* -------------------------------------------------------------------------------------------- - * Licensed under the MIT License. See License.txt in the project root for license information. -/* -------------------------------------------------------------------------------------------- * ------------------------------------------------------------------------------------------ */ /* -------------------------------------------------------------------------------------------- -import { - Position, - Range } from 'vscode' import { @@ -26,10 +21,6 @@ LanguageClientOptions, TransportKind } from 'vscode-languageclient' -import { createTreeView } from './treeView' - -const CONFIG_GLOB = - '**/{tailwind,tailwind.config,tailwind-config,.tailwindrc}.js' let LANGUAGES: string[] = ['html'] let defaultClient: LanguageClient @@ -72,35 +63,14 @@ } return folder } - workspace as Workspace, /* -------------------------------------------------------------------------------------------- + .sort((a, b) => { // let module = context.asAbsolutePath(path.join('server', 'out', 'server.js')) let module = '/Users/brad/Code/tailwindcss-language-server/dist/index.js' let outputChannel: OutputChannel = Window.createOutputChannel( 'lsp-multi-server-example' ) - let files = await Workspace.findFiles(CONFIG_GLOB, '**/node_modules/**', 1) - - if (!files.length) return - - let configPath = files[0].fsPath - delete require.cache[configPath] - - let refresh = createTreeView(configPath) - commands.registerCommand('tailwindcss.goToDefinition', () => { - // refresh() - // Window.showInformationMessage('Hello World!') - Workspace.openTextDocument(files[0]).then((doc: TextDocument) => { - Window.showTextDocument(doc).then((editor: TextEditor) => { - let start = new Position(0, 0) - let end = new Position(0, 0) - editor.revealRange(new Range(start, end)) - editor.selection = new Selection(start, end) - }) - }) - }) - function didOpenTextDocument(document: TextDocument): void { if ( document.uri.scheme !== 'file' || @@ -143,11 +113,6 @@ 'LSP Multi Server Example', serverOptions, clientOptions ) - // client.onReady().then(() => { - // client.onNotification('tailwind/loaded', () => { - // console.log('loaded') - // }) - // }) client.start() clients.set(folder.uri.toString(), client) } diff --git a/src/treeView.ts b/src/treeView.ts deleted file mode 100644 index 6931c6cad12fd3fbc3a609dd3655e26d57d52cf4..0000000000000000000000000000000000000000 --- a/src/treeView.ts +++ /dev/null @@ -1,219 +0,0 @@ -import { - TreeDataProvider, - TreeItem, - TreeItemCollapsibleState, - window as Window, - Command, - Event, - EventEmitter -} from 'vscode' -import { getSvgColorFromValue, createTempFile } from './util' -import dlv from 'dlv' -import * as path from 'path' - -const ICONS = { - colors: 'palette.svg', - backgroundColors: 'palette.svg', - borderColors: 'palette.svg', - textColors: 'palette.svg', - svgFill: 'palette.svg', - svgStroke: 'palette.svg', - screens: 'devices.svg', - textSizes: 'format_size.svg', - fonts: 'title.svg', - fontWeights: 'format_bold.svg', - zIndex: 'layers.svg', - borderWidths: 'border_all.svg', - shadows: 'flip_to_front.svg', - borderRadius: 'rounded_corner.svg', - width: 'straighten.svg', - minWidth: 'straighten.svg', - maxWidth: 'straighten.svg', - height: 'straighten.svg', - minHeight: 'straighten.svg', - maxHeight: 'straighten.svg', - opacity: 'opacity.svg', - leading: 'format_line_spacing.svg', - backgroundSize: 'photo_size_select_large.svg', - padding: 'padding.svg', - margin: 'select_all.svg', - negativeMargin: 'select_all.svg', - tracking: 'tracking.svg' -} - -function configValueToString(value: any): string { - if (Array.isArray(value)) { - return value.join(', ') - } - return value.toString() -} - -function isObject(val: any): boolean { - return val != null && typeof val === 'object' && Array.isArray(val) === false -} - -class ConfigItem extends TreeItem { - constructor( - public label: string, - public key: string[], - public collapsibleState: TreeItemCollapsibleState, - public description?: string, - public iconPath?: string, - public command?: Command - ) { - super(label, collapsibleState) - this.key = key - this.description = description - this.iconPath = iconPath - } -} - -class TailwindDataProvider implements TreeDataProvider { - private _onDidChangeTreeData: EventEmitter = new EventEmitter() - readonly onDidChangeTreeData: Event = this - ._onDidChangeTreeData.event - - private config: any - - constructor(public configPath: string) { - this.config = require(configPath) - } - public refresh(configPath?: string): void { - if (configPath) this.configPath = configPath - delete require.cache[this.configPath] - this.config = require(this.configPath) - this._onDidChangeTreeData.fire() - } - getTreeItem(element: ConfigItem): ConfigItem { - return element - } - async getChildren(element: ConfigItem): Promise { - let command = { - command: 'tailwindcss.goToDefinition', - title: 'Go To Definition' - } - if (element) { - let item = dlv(this.config, element.key) - let children = Object.keys(item).map(key => { - let isObj = isObject(item[key]) - let child = new ConfigItem( - key, - element.key.concat(key), - isObj - ? TreeItemCollapsibleState.Collapsed - : TreeItemCollapsibleState.None, - isObj ? undefined : configValueToString(item[key]), - undefined, - isObj ? undefined : command - ) - let color = getSvgColorFromValue(item[key]) - - if (color) { - return createTempFile( - ``, - { postfix: '.svg' } - ).then(iconPath => { - child.iconPath = iconPath - return child - }) - } - - return child - }) - return Promise.all(children) - } - - return Object.keys(this.config) - .filter(key => ['modules', 'plugins', 'options'].indexOf(key) === -1) - .map( - key => - new ConfigItem( - key, - [key], - isObject(this.config[key]) - ? TreeItemCollapsibleState.Collapsed - : TreeItemCollapsibleState.None, - isObject(this.config[key]) - ? undefined - : configValueToString(this.config[key]), - ICONS[key] - ? path.join( - __filename, - '..', - '..', - 'resources', - 'icons', - ICONS[key] - ) - : undefined, - isObject(this.config[key]) ? undefined : command - ) - ) - } -} - -function treeDataProvider1(config): TreeDataProvider { - return { - getChildren: async (element): Promise => { - if (element) { - let child = dlv(config, element.label, {}) - let items = Object.keys(child).map(key => { - let color = getSvgColorFromValue(child[key]) - - if (color) { - return createTempFile( - ``, - { postfix: '.svg' } - ).then(iconPath => ({ - label: key, - description: configValueToString(child[key]), - iconPath - })) - } - - return Promise.resolve({ - label: key, - description: configValueToString(child[key]) - }) - }) - return Promise.all(items) - } - - return Object.keys(config) - .filter(key => ['modules', 'plugins', 'options'].indexOf(key) === -1) - .map(key => ({ - label: key, - collapsibleState: isObject(config[key]) - ? TreeItemCollapsibleState.Collapsed - : TreeItemCollapsibleState.None, - description: isObject(config[key]) - ? undefined - : configValueToString(config[key]), - iconPath: ICONS[key] - ? path.join( - __filename, - '..', - '..', - 'resources', - 'icons', - ICONS[key] - ) - : undefined - })) - }, - getTreeItem: (element: TreeItem): TreeItem => { - return element - } - } -} - -export function createTreeView(configPath) { - let provider = new TailwindDataProvider(configPath) - let view = Window.createTreeView('tailwindcssConfigExplorer', { - treeDataProvider: provider, - showCollapseAll: true - }) - view.reveal(undefined) - - return () => provider.refresh() -} diff --git a/src/util.ts b/src/util.ts deleted file mode 100644 index 5d3f624607ddb7384776f0bbc2145e366ef428cb..0000000000000000000000000000000000000000 --- a/src/util.ts +++ /dev/null @@ -1,31 +0,0 @@ -import * as fs from 'fs' -import Color from 'color' -import tmp from 'tmp' - -export function createTempFile(content: string, options = {}): Promise { - return new Promise((resolve, reject) => { - tmp.file(options, (err, path) => { - if (err) return reject(err) - fs.writeFile(path, content, 'utf8', err => { - if (err) return reject(err) - resolve(path) - }) - }) - }) -} - -export function getSvgColorFromValue(value: string): string { - if (typeof value !== 'string') return null - - if (value === 'transparent') { - return 'none' - } - - try { - let parsed = Color(value) - if (parsed.valpha === 0) return 'none' - return parsed.rgb().string() - } catch (err) { - return null - } -}