diff --git a/.vscode/launch.json b/.vscode/launch.json index 6810190e..2fdcd837 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,12 +8,12 @@ "runtimeArgs": [ "--enable-source-maps", "--test", - "lib/umd/test/**/*.test.js" + "lib/esm/test/**/*.test.js" ], "cwd": "${workspaceRoot}", "sourceMaps": true, "outFiles": [ - "${workspaceRoot}/lib/umd/**" + "${workspaceRoot}/lib/esm/**" ], "skipFiles": [ "/**" diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d19fa69..f8af8e27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +7.0.0-next.1 / 2026-03-04 +========================= + * BREAKING: package is now ESM-only (`"type": "module"`) and no longer publishes `lib/umd` output + * BREAKING: package entrypoints now use `exports` and `types` from `lib/esm` + * BREAKING: runtime and test output moved to `lib/esm` and source imports use explicit `.js` extensions for NodeNext compatibility + * Build scripts in `build/` are now ESM + * `update-jsbeautify` now writes the ESM formatter source directly to `src/beautify/beautify-css.js` + 6.3.0 / 2022-06-24 ================ * new optional API `fileSystemProvider.getContent` diff --git a/build/copy-jsbeautify.js b/build/copy-jsbeautify.js deleted file mode 100644 index 233fb6e0..00000000 --- a/build/copy-jsbeautify.js +++ /dev/null @@ -1,23 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -function copy(from, to) { - if (!fs.existsSync(to)) { - fs.mkdirSync(to, { recursive: true }); - } - const files = fs.readdirSync(from); - for (let file of files) { - if (path.extname(file) === '.js') { - const fromPath = path.join(from, file); - const toPath = path.join(to, file); - console.log(`copy ${fromPath} to ${toPath}`); - fs.copyFileSync(fromPath, toPath); - } - } -} - -const umdDir = path.join(__dirname, '..', 'lib', 'umd', 'beautify'); -copy(path.join(__dirname, '..', 'src', 'beautify'), umdDir); - -const esmDir = path.join(__dirname, '..', 'lib', 'esm', 'beautify'); -copy(path.join(__dirname, '..', 'src', 'beautify', 'esm'), esmDir); diff --git a/build/generateData.js b/build/generateData.js index f0187acd..c1d5fa18 100644 --- a/build/generateData.js +++ b/build/generateData.js @@ -3,10 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -const fs = require('fs') -const path = require('path') -const os = require('os') +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; +import { createRequire } from 'node:module'; +import { fileURLToPath } from 'node:url'; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const require = createRequire(import.meta.url); const customData = require('@vscode/web-custom-data/data/browsers.css-data.json'); function toJavaScript(obj) { @@ -21,13 +25,13 @@ const output = [ ' *--------------------------------------------------------------------------------------------*/', '// file generated from @vscode/web-custom-data NPM package', '', - `import { ${DATA_TYPE} } from '../cssLanguageTypes';`, + `import { ${DATA_TYPE} } from '../cssLanguageTypes.js';`, '', `export const cssData : ${DATA_TYPE} = ` + toJavaScript(customData) + ';' ]; -var outputPath = path.resolve(__dirname, '../src/data/webCustomData.ts'); +const outputPath = path.resolve(__dirname, '../src/data/webCustomData.ts'); console.log('Writing to: ' + outputPath); -var content = output.join(os.EOL); +const content = output.join(os.EOL); fs.writeFileSync(outputPath, content); console.log('Done'); diff --git a/build/remove-sourcemap-refs.js b/build/remove-sourcemap-refs.js index 89a09974..ed8870f8 100644 --- a/build/remove-sourcemap-refs.js +++ b/build/remove-sourcemap-refs.js @@ -3,8 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -const fs = require('fs'); -const path = require('path'); +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); function deleteRefs(dir) { const files = fs.readdirSync(dir); @@ -27,6 +30,6 @@ function deleteRefs(dir) { } } -let location = path.join(__dirname, '..', 'lib'); +const location = path.join(__dirname, '..', 'lib'); console.log('process ' + location); deleteRefs(location); \ No newline at end of file diff --git a/build/update-jsbeautify.js b/build/update-jsbeautify.js index b5421257..8d6b9c1e 100644 --- a/build/update-jsbeautify.js +++ b/build/update-jsbeautify.js @@ -3,86 +3,82 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; -var path = require('path'); -var fs = require('fs'); +const __dirname = path.dirname(fileURLToPath(import.meta.url)); -function getVersion(moduleName) { - var packageJSONPath = path.join(__dirname, '..', 'node_modules', moduleName, 'package.json'); - return readFile(packageJSONPath).then(function (content) { - try { - return JSON.parse(content).version; - } catch (e) { - return Promise.resolve(null); - } - }); +async function getVersion(moduleName) { + const packageJSONPath = path.join(__dirname, '..', 'node_modules', moduleName, 'package.json'); + const content = await readFile(packageJSONPath); + try { + return JSON.parse(content).version; + } catch { + return null; + } } -function readFile(path) { - return new Promise((s, e) => { - fs.readFile(path, (err, res) => { +function readFile(filePath) { + return new Promise((resolve, reject) => { + fs.readFile(filePath, (err, res) => { if (err) { - e(err); + reject(err); } else { - s(res.toString()); + resolve(res.toString()); } }); }); - } -function update(moduleName, repoPath, dest, addHeader, patch) { - var contentPath = path.join(__dirname, '..', 'node_modules', moduleName, repoPath); +async function update(moduleName, repoPath, dest, addHeader, patch) { + const contentPath = path.join(__dirname, '..', 'node_modules', moduleName, repoPath); console.log('Reading from ' + contentPath); - return readFile(contentPath).then(function (content) { - return getVersion(moduleName).then(function (version) { - let header = ''; - if (addHeader) { - header = '// copied from js-beautify/' + repoPath + '\n'; - if (version) { - header += '// version: ' + version + '\n'; - } - } - try { - if (patch) { - content = patch(content); - } - fs.writeFileSync(dest, header + content); - if (version) { - console.log('Updated ' + path.basename(dest) + ' (' + version + ')'); - } else { - console.log('Updated ' + path.basename(dest)); - } - } catch (e) { - console.error(e); + try { + let content = await readFile(contentPath); + const version = await getVersion(moduleName); + let header = ''; + if (addHeader) { + header = '// copied from js-beautify/' + repoPath + '\n'; + if (version) { + header += '// version: ' + version + '\n'; } - }); - - }, console.error); + } + if (patch) { + content = patch(content); + } + fs.writeFileSync(dest, header + content); + if (version) { + console.log('Updated ' + path.basename(dest) + ' (' + version + ')'); + } else { + console.log('Updated ' + path.basename(dest)); + } + } catch (e) { + console.error(e); + } } -update('js-beautify', 'js/lib/beautify-css.js', './src/beautify/beautify-css.js', true); -update('js-beautify', 'LICENSE', './src/beautify/beautify-license'); - -// ESM version -update('js-beautify', 'js/lib/beautify-css.js', './src/beautify/esm/beautify-css.js', true, function (contents) { - let topLevelFunction = '(function() {'; - let outputVar = 'var legacy_beautify_css'; - let footer = 'var css_beautify = legacy_beautify_css;'; - let index1 = contents.indexOf(topLevelFunction); - let index2 = contents.indexOf(outputVar, index1); - let index3 = contents.indexOf(footer, index2); - if (index1 === -1) { - throw new Error(`Problem patching beautify.css for ESM: '${topLevelFunction}' not found.`); - } - if (index2 === -1) { - throw new Error(`Problem patching beautify.css for ESM: '${outputVar}' not found after '${topLevelFunction}'.`); - } - if (index3 === -1) { - throw new Error(`Problem patching beautify.css for ESM: '${footer}' not found after '${outputVar}'.`); - } - return contents.substring(0, index1) + - contents.substring(index2, index3) + - `\nexport var css_beautify = legacy_beautify_css;`; -}); +await Promise.all([ + update('js-beautify', 'LICENSE', './src/beautify/beautify-license'), + // Write the ESM-compatible variant directly to the main source path. + update('js-beautify', 'js/lib/beautify-css.js', './src/beautify/beautify-css.js', true, (contents) => { + const topLevelFunction = '(function() {'; + const outputVar = 'var legacy_beautify_css'; + const footer = 'var css_beautify = legacy_beautify_css;'; + const index1 = contents.indexOf(topLevelFunction); + const index2 = contents.indexOf(outputVar, index1); + const index3 = contents.indexOf(footer, index2); + if (index1 === -1) { + throw new Error(`Problem patching beautify.css for ESM: '${topLevelFunction}' not found.`); + } + if (index2 === -1) { + throw new Error(`Problem patching beautify.css for ESM: '${outputVar}' not found after '${topLevelFunction}'.`); + } + if (index3 === -1) { + throw new Error(`Problem patching beautify.css for ESM: '${footer}' not found after '${outputVar}'.`); + } + return contents.substring(0, index1) + + contents.substring(index2, index3) + + '\nexport var css_beautify = legacy_beautify_css;'; + }) +]); diff --git a/package-lock.json b/package-lock.json index f3910ec8..3e59c1e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-css-languageservice", - "version": "6.3.10", + "version": "7.0.0-next.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vscode-css-languageservice", - "version": "6.3.10", + "version": "7.0.0-next.1", "license": "MIT", "dependencies": { "@vscode/l10n": "^0.0.18", diff --git a/package.json b/package.json index f55681c6..c6ddfb5b 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,15 @@ { "name": "vscode-css-languageservice", - "version": "6.3.10", + "version": "7.0.0-next.1", "description": "Language service for CSS, LESS and SCSS", - "main": "./lib/umd/cssLanguageService.js", - "typings": "./lib/umd/cssLanguageService", - "module": "./lib/esm/cssLanguageService.js", + "type": "module", + "exports": { + ".": { + "types": "./lib/esm/cssLanguageService.d.ts", + "import": "./lib/esm/cssLanguageService.js" + } + }, + "types": "./lib/esm/cssLanguageService.d.ts", "author": "Microsoft Corporation", "repository": { "type": "git", @@ -31,19 +36,17 @@ "vscode-uri": "^3.1.0" }, "scripts": { - "prepack": "npm run clean && npm run compile-esm && npm run test && npm run remove-sourcemap-refs", - "compile": "tsc -p ./src && npm run copy-jsbeautify && npm run lint", - "compile-esm": "tsc -p ./src/tsconfig.esm.json", + "prepack": "npm run clean && npm run compile && npm run test && npm run remove-sourcemap-refs", + "compile": "tsc -p ./src && npm run lint", "clean": "rimraf lib", "remove-sourcemap-refs": "node ./build/remove-sourcemap-refs.js", - "watch": "npm run copy-jsbeautify && tsc -w -p ./src", + "watch": "tsc -w -p ./src", "test": "npm run compile && npm run node-test", - "node-test": "node --enable-source-maps --test lib/umd/test/**/*.test.js", - "coverage": "npm run compile && npx nyc --reporter=html --reporter=text node --test lib/umd/test/**/*.test.js", + "node-test": "node --enable-source-maps --test lib/esm/test/**/*.test.js", + "coverage": "npm run compile && npx nyc --reporter=html --reporter=text node --test lib/esm/test/**/*.test.js", "lint": "eslint src/**/*.ts", "update-data": "npm install @vscode/web-custom-data -D && node ./build/generateData.js", "install-types-next": "npm install vscode-languageserver-types@next -f -S && npm install vscode-languageserver-textdocument@next -f -S", - "copy-jsbeautify": "node ./build/copy-jsbeautify.js", "update-jsbeautify": "npm install js-beautify && node ./build/update-jsbeautify.js", "update-jsbeautify-next": "npm install js-beautify@next && node ./build/update-jsbeautify.js" } diff --git a/src/beautify/beautify-css.js b/src/beautify/beautify-css.js index 278240e0..9127d653 100644 --- a/src/beautify/beautify-css.js +++ b/src/beautify/beautify-css.js @@ -64,9 +64,6 @@ // http://www.w3.org/TR/CSS21/syndata.html#tokenization // http://www.w3.org/TR/css3-syntax/ -(function() { - -/* GENERATED_BUILD_OUTPUT */ var legacy_beautify_css; /******/ (function() { // webpackBootstrap /******/ "use strict"; @@ -1671,25 +1668,5 @@ module.exports.Options = Options; /******/ /******/ })() ; -var css_beautify = legacy_beautify_css; -/* Footer */ -if (typeof define === "function" && define.amd) { - // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- ) - define([], function() { - return { - css_beautify: css_beautify - }; - }); -} else if (typeof exports !== "undefined") { - // Add support for CommonJS. Just put this file somewhere on your require.paths - // and you will be able to `var html_beautify = require("beautify").html_beautify`. - exports.css_beautify = css_beautify; -} else if (typeof window !== "undefined") { - // If we're running a web page and don't have either of the above, add our one global - window.css_beautify = css_beautify; -} else if (typeof global !== "undefined") { - // If we don't even have window, try global. - global.css_beautify = css_beautify; -} -}()); +export var css_beautify = legacy_beautify_css; \ No newline at end of file diff --git a/src/beautify/esm/beautify-css.js b/src/beautify/esm/beautify-css.js deleted file mode 100644 index 9127d653..00000000 --- a/src/beautify/esm/beautify-css.js +++ /dev/null @@ -1,1672 +0,0 @@ -// copied from js-beautify/js/lib/beautify-css.js -// version: 1.15.4 -/* AUTO-GENERATED. DO NOT MODIFY. */ -/* - - The MIT License (MIT) - - Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - - - CSS Beautifier ---------------- - - Written by Harutyun Amirjanyan, (amirjanyan@gmail.com) - - Based on code initially developed by: Einar Lielmanis, - https://beautifier.io/ - - Usage: - css_beautify(source_text); - css_beautify(source_text, options); - - The options are (default in brackets): - indent_size (4) — indentation size, - indent_char (space) — character to indent with, - selector_separator_newline (true) - separate selectors with newline or - not (e.g. "a,\nbr" or "a, br") - end_with_newline (false) - end with a newline - newline_between_rules (true) - add a new line after every css rule - space_around_selector_separator (false) - ensure space around selector separators: - '>', '+', '~' (e.g. "a>b" -> "a > b") - e.g - - css_beautify(css_source_text, { - 'indent_size': 1, - 'indent_char': '\t', - 'selector_separator': ' ', - 'end_with_newline': false, - 'newline_between_rules': true, - 'space_around_selector_separator': true - }); -*/ - -// http://www.w3.org/TR/CSS21/syndata.html#tokenization -// http://www.w3.org/TR/css3-syntax/ - -var legacy_beautify_css; -/******/ (function() { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ([ -/* 0 */, -/* 1 */, -/* 2 */ -/***/ (function(module) { - -/*jshint node:true */ -/* - The MIT License (MIT) - - Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - - - -function OutputLine(parent) { - this.__parent = parent; - this.__character_count = 0; - // use indent_count as a marker for this.__lines that have preserved indentation - this.__indent_count = -1; - this.__alignment_count = 0; - this.__wrap_point_index = 0; - this.__wrap_point_character_count = 0; - this.__wrap_point_indent_count = -1; - this.__wrap_point_alignment_count = 0; - - this.__items = []; -} - -OutputLine.prototype.clone_empty = function() { - var line = new OutputLine(this.__parent); - line.set_indent(this.__indent_count, this.__alignment_count); - return line; -}; - -OutputLine.prototype.item = function(index) { - if (index < 0) { - return this.__items[this.__items.length + index]; - } else { - return this.__items[index]; - } -}; - -OutputLine.prototype.has_match = function(pattern) { - for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) { - if (this.__items[lastCheckedOutput].match(pattern)) { - return true; - } - } - return false; -}; - -OutputLine.prototype.set_indent = function(indent, alignment) { - if (this.is_empty()) { - this.__indent_count = indent || 0; - this.__alignment_count = alignment || 0; - this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count); - } -}; - -OutputLine.prototype._set_wrap_point = function() { - if (this.__parent.wrap_line_length) { - this.__wrap_point_index = this.__items.length; - this.__wrap_point_character_count = this.__character_count; - this.__wrap_point_indent_count = this.__parent.next_line.__indent_count; - this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count; - } -}; - -OutputLine.prototype._should_wrap = function() { - return this.__wrap_point_index && - this.__character_count > this.__parent.wrap_line_length && - this.__wrap_point_character_count > this.__parent.next_line.__character_count; -}; - -OutputLine.prototype._allow_wrap = function() { - if (this._should_wrap()) { - this.__parent.add_new_line(); - var next = this.__parent.current_line; - next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count); - next.__items = this.__items.slice(this.__wrap_point_index); - this.__items = this.__items.slice(0, this.__wrap_point_index); - - next.__character_count += this.__character_count - this.__wrap_point_character_count; - this.__character_count = this.__wrap_point_character_count; - - if (next.__items[0] === " ") { - next.__items.splice(0, 1); - next.__character_count -= 1; - } - return true; - } - return false; -}; - -OutputLine.prototype.is_empty = function() { - return this.__items.length === 0; -}; - -OutputLine.prototype.last = function() { - if (!this.is_empty()) { - return this.__items[this.__items.length - 1]; - } else { - return null; - } -}; - -OutputLine.prototype.push = function(item) { - this.__items.push(item); - var last_newline_index = item.lastIndexOf('\n'); - if (last_newline_index !== -1) { - this.__character_count = item.length - last_newline_index; - } else { - this.__character_count += item.length; - } -}; - -OutputLine.prototype.pop = function() { - var item = null; - if (!this.is_empty()) { - item = this.__items.pop(); - this.__character_count -= item.length; - } - return item; -}; - - -OutputLine.prototype._remove_indent = function() { - if (this.__indent_count > 0) { - this.__indent_count -= 1; - this.__character_count -= this.__parent.indent_size; - } -}; - -OutputLine.prototype._remove_wrap_indent = function() { - if (this.__wrap_point_indent_count > 0) { - this.__wrap_point_indent_count -= 1; - } -}; -OutputLine.prototype.trim = function() { - while (this.last() === ' ') { - this.__items.pop(); - this.__character_count -= 1; - } -}; - -OutputLine.prototype.toString = function() { - var result = ''; - if (this.is_empty()) { - if (this.__parent.indent_empty_lines) { - result = this.__parent.get_indent_string(this.__indent_count); - } - } else { - result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count); - result += this.__items.join(''); - } - return result; -}; - -function IndentStringCache(options, baseIndentString) { - this.__cache = ['']; - this.__indent_size = options.indent_size; - this.__indent_string = options.indent_char; - if (!options.indent_with_tabs) { - this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char); - } - - // Set to null to continue support for auto detection of base indent - baseIndentString = baseIndentString || ''; - if (options.indent_level > 0) { - baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string); - } - - this.__base_string = baseIndentString; - this.__base_string_length = baseIndentString.length; -} - -IndentStringCache.prototype.get_indent_size = function(indent, column) { - var result = this.__base_string_length; - column = column || 0; - if (indent < 0) { - result = 0; - } - result += indent * this.__indent_size; - result += column; - return result; -}; - -IndentStringCache.prototype.get_indent_string = function(indent_level, column) { - var result = this.__base_string; - column = column || 0; - if (indent_level < 0) { - indent_level = 0; - result = ''; - } - column += indent_level * this.__indent_size; - this.__ensure_cache(column); - result += this.__cache[column]; - return result; -}; - -IndentStringCache.prototype.__ensure_cache = function(column) { - while (column >= this.__cache.length) { - this.__add_column(); - } -}; - -IndentStringCache.prototype.__add_column = function() { - var column = this.__cache.length; - var indent = 0; - var result = ''; - if (this.__indent_size && column >= this.__indent_size) { - indent = Math.floor(column / this.__indent_size); - column -= indent * this.__indent_size; - result = new Array(indent + 1).join(this.__indent_string); - } - if (column) { - result += new Array(column + 1).join(' '); - } - - this.__cache.push(result); -}; - -function Output(options, baseIndentString) { - this.__indent_cache = new IndentStringCache(options, baseIndentString); - this.raw = false; - this._end_with_newline = options.end_with_newline; - this.indent_size = options.indent_size; - this.wrap_line_length = options.wrap_line_length; - this.indent_empty_lines = options.indent_empty_lines; - this.__lines = []; - this.previous_line = null; - this.current_line = null; - this.next_line = new OutputLine(this); - this.space_before_token = false; - this.non_breaking_space = false; - this.previous_token_wrapped = false; - // initialize - this.__add_outputline(); -} - -Output.prototype.__add_outputline = function() { - this.previous_line = this.current_line; - this.current_line = this.next_line.clone_empty(); - this.__lines.push(this.current_line); -}; - -Output.prototype.get_line_number = function() { - return this.__lines.length; -}; - -Output.prototype.get_indent_string = function(indent, column) { - return this.__indent_cache.get_indent_string(indent, column); -}; - -Output.prototype.get_indent_size = function(indent, column) { - return this.__indent_cache.get_indent_size(indent, column); -}; - -Output.prototype.is_empty = function() { - return !this.previous_line && this.current_line.is_empty(); -}; - -Output.prototype.add_new_line = function(force_newline) { - // never newline at the start of file - // otherwise, newline only if we didn't just add one or we're forced - if (this.is_empty() || - (!force_newline && this.just_added_newline())) { - return false; - } - - // if raw output is enabled, don't print additional newlines, - // but still return True as though you had - if (!this.raw) { - this.__add_outputline(); - } - return true; -}; - -Output.prototype.get_code = function(eol) { - this.trim(true); - - // handle some edge cases where the last tokens - // has text that ends with newline(s) - var last_item = this.current_line.pop(); - if (last_item) { - if (last_item[last_item.length - 1] === '\n') { - last_item = last_item.replace(/\n+$/g, ''); - } - this.current_line.push(last_item); - } - - if (this._end_with_newline) { - this.__add_outputline(); - } - - var sweet_code = this.__lines.join('\n'); - - if (eol !== '\n') { - sweet_code = sweet_code.replace(/[\n]/g, eol); - } - return sweet_code; -}; - -Output.prototype.set_wrap_point = function() { - this.current_line._set_wrap_point(); -}; - -Output.prototype.set_indent = function(indent, alignment) { - indent = indent || 0; - alignment = alignment || 0; - - // Next line stores alignment values - this.next_line.set_indent(indent, alignment); - - // Never indent your first output indent at the start of the file - if (this.__lines.length > 1) { - this.current_line.set_indent(indent, alignment); - return true; - } - - this.current_line.set_indent(); - return false; -}; - -Output.prototype.add_raw_token = function(token) { - for (var x = 0; x < token.newlines; x++) { - this.__add_outputline(); - } - this.current_line.set_indent(-1); - this.current_line.push(token.whitespace_before); - this.current_line.push(token.text); - this.space_before_token = false; - this.non_breaking_space = false; - this.previous_token_wrapped = false; -}; - -Output.prototype.add_token = function(printable_token) { - this.__add_space_before_token(); - this.current_line.push(printable_token); - this.space_before_token = false; - this.non_breaking_space = false; - this.previous_token_wrapped = this.current_line._allow_wrap(); -}; - -Output.prototype.__add_space_before_token = function() { - if (this.space_before_token && !this.just_added_newline()) { - if (!this.non_breaking_space) { - this.set_wrap_point(); - } - this.current_line.push(' '); - } -}; - -Output.prototype.remove_indent = function(index) { - var output_length = this.__lines.length; - while (index < output_length) { - this.__lines[index]._remove_indent(); - index++; - } - this.current_line._remove_wrap_indent(); -}; - -Output.prototype.trim = function(eat_newlines) { - eat_newlines = (eat_newlines === undefined) ? false : eat_newlines; - - this.current_line.trim(); - - while (eat_newlines && this.__lines.length > 1 && - this.current_line.is_empty()) { - this.__lines.pop(); - this.current_line = this.__lines[this.__lines.length - 1]; - this.current_line.trim(); - } - - this.previous_line = this.__lines.length > 1 ? - this.__lines[this.__lines.length - 2] : null; -}; - -Output.prototype.just_added_newline = function() { - return this.current_line.is_empty(); -}; - -Output.prototype.just_added_blankline = function() { - return this.is_empty() || - (this.current_line.is_empty() && this.previous_line.is_empty()); -}; - -Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) { - var index = this.__lines.length - 2; - while (index >= 0) { - var potentialEmptyLine = this.__lines[index]; - if (potentialEmptyLine.is_empty()) { - break; - } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 && - potentialEmptyLine.item(-1) !== ends_with) { - this.__lines.splice(index + 1, 0, new OutputLine(this)); - this.previous_line = this.__lines[this.__lines.length - 2]; - break; - } - index--; - } -}; - -module.exports.Output = Output; - - -/***/ }), -/* 3 */, -/* 4 */, -/* 5 */, -/* 6 */ -/***/ (function(module) { - -/*jshint node:true */ -/* - - The MIT License (MIT) - - Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - - - -function Options(options, merge_child_field) { - this.raw_options = _mergeOpts(options, merge_child_field); - - // Support passing the source text back with no change - this.disabled = this._get_boolean('disabled'); - - this.eol = this._get_characters('eol', 'auto'); - this.end_with_newline = this._get_boolean('end_with_newline'); - this.indent_size = this._get_number('indent_size', 4); - this.indent_char = this._get_characters('indent_char', ' '); - this.indent_level = this._get_number('indent_level'); - - this.preserve_newlines = this._get_boolean('preserve_newlines', true); - this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786); - if (!this.preserve_newlines) { - this.max_preserve_newlines = 0; - } - - this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t'); - if (this.indent_with_tabs) { - this.indent_char = '\t'; - - // indent_size behavior changed after 1.8.6 - // It used to be that indent_size would be - // set to 1 for indent_with_tabs. That is no longer needed and - // actually doesn't make sense - why not use spaces? Further, - // that might produce unexpected behavior - tabs being used - // for single-column alignment. So, when indent_with_tabs is true - // and indent_size is 1, reset indent_size to 4. - if (this.indent_size === 1) { - this.indent_size = 4; - } - } - - // Backwards compat with 1.3.x - this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char')); - - this.indent_empty_lines = this._get_boolean('indent_empty_lines'); - - // valid templating languages ['django', 'erb', 'handlebars', 'php', 'smarty', 'angular'] - // For now, 'auto' = all off for javascript, all except angular on for html (and inline javascript/css). - // other values ignored - this.templating = this._get_selection_list('templating', ['auto', 'none', 'angular', 'django', 'erb', 'handlebars', 'php', 'smarty'], ['auto']); -} - -Options.prototype._get_array = function(name, default_value) { - var option_value = this.raw_options[name]; - var result = default_value || []; - if (typeof option_value === 'object') { - if (option_value !== null && typeof option_value.concat === 'function') { - result = option_value.concat(); - } - } else if (typeof option_value === 'string') { - result = option_value.split(/[^a-zA-Z0-9_\/\-]+/); - } - return result; -}; - -Options.prototype._get_boolean = function(name, default_value) { - var option_value = this.raw_options[name]; - var result = option_value === undefined ? !!default_value : !!option_value; - return result; -}; - -Options.prototype._get_characters = function(name, default_value) { - var option_value = this.raw_options[name]; - var result = default_value || ''; - if (typeof option_value === 'string') { - result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t'); - } - return result; -}; - -Options.prototype._get_number = function(name, default_value) { - var option_value = this.raw_options[name]; - default_value = parseInt(default_value, 10); - if (isNaN(default_value)) { - default_value = 0; - } - var result = parseInt(option_value, 10); - if (isNaN(result)) { - result = default_value; - } - return result; -}; - -Options.prototype._get_selection = function(name, selection_list, default_value) { - var result = this._get_selection_list(name, selection_list, default_value); - if (result.length !== 1) { - throw new Error( - "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" + - selection_list + "\nYou passed in: '" + this.raw_options[name] + "'"); - } - - return result[0]; -}; - - -Options.prototype._get_selection_list = function(name, selection_list, default_value) { - if (!selection_list || selection_list.length === 0) { - throw new Error("Selection list cannot be empty."); - } - - default_value = default_value || [selection_list[0]]; - if (!this._is_valid_selection(default_value, selection_list)) { - throw new Error("Invalid Default Value!"); - } - - var result = this._get_array(name, default_value); - if (!this._is_valid_selection(result, selection_list)) { - throw new Error( - "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" + - selection_list + "\nYou passed in: '" + this.raw_options[name] + "'"); - } - - return result; -}; - -Options.prototype._is_valid_selection = function(result, selection_list) { - return result.length && selection_list.length && - !result.some(function(item) { return selection_list.indexOf(item) === -1; }); -}; - - -// merges child options up with the parent options object -// Example: obj = {a: 1, b: {a: 2}} -// mergeOpts(obj, 'b') -// -// Returns: {a: 2} -function _mergeOpts(allOptions, childFieldName) { - var finalOpts = {}; - allOptions = _normalizeOpts(allOptions); - var name; - - for (name in allOptions) { - if (name !== childFieldName) { - finalOpts[name] = allOptions[name]; - } - } - - //merge in the per type settings for the childFieldName - if (childFieldName && allOptions[childFieldName]) { - for (name in allOptions[childFieldName]) { - finalOpts[name] = allOptions[childFieldName][name]; - } - } - return finalOpts; -} - -function _normalizeOpts(options) { - var convertedOpts = {}; - var key; - - for (key in options) { - var newKey = key.replace(/-/g, "_"); - convertedOpts[newKey] = options[key]; - } - return convertedOpts; -} - -module.exports.Options = Options; -module.exports.normalizeOpts = _normalizeOpts; -module.exports.mergeOpts = _mergeOpts; - - -/***/ }), -/* 7 */, -/* 8 */ -/***/ (function(module) { - -/*jshint node:true */ -/* - - The MIT License (MIT) - - Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - - - -var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky'); - -function InputScanner(input_string) { - this.__input = input_string || ''; - this.__input_length = this.__input.length; - this.__position = 0; -} - -InputScanner.prototype.restart = function() { - this.__position = 0; -}; - -InputScanner.prototype.back = function() { - if (this.__position > 0) { - this.__position -= 1; - } -}; - -InputScanner.prototype.hasNext = function() { - return this.__position < this.__input_length; -}; - -InputScanner.prototype.next = function() { - var val = null; - if (this.hasNext()) { - val = this.__input.charAt(this.__position); - this.__position += 1; - } - return val; -}; - -InputScanner.prototype.peek = function(index) { - var val = null; - index = index || 0; - index += this.__position; - if (index >= 0 && index < this.__input_length) { - val = this.__input.charAt(index); - } - return val; -}; - -// This is a JavaScript only helper function (not in python) -// Javascript doesn't have a match method -// and not all implementation support "sticky" flag. -// If they do not support sticky then both this.match() and this.test() method -// must get the match and check the index of the match. -// If sticky is supported and set, this method will use it. -// Otherwise it will check that global is set, and fall back to the slower method. -InputScanner.prototype.__match = function(pattern, index) { - pattern.lastIndex = index; - var pattern_match = pattern.exec(this.__input); - - if (pattern_match && !(regexp_has_sticky && pattern.sticky)) { - if (pattern_match.index !== index) { - pattern_match = null; - } - } - - return pattern_match; -}; - -InputScanner.prototype.test = function(pattern, index) { - index = index || 0; - index += this.__position; - - if (index >= 0 && index < this.__input_length) { - return !!this.__match(pattern, index); - } else { - return false; - } -}; - -InputScanner.prototype.testChar = function(pattern, index) { - // test one character regex match - var val = this.peek(index); - pattern.lastIndex = 0; - return val !== null && pattern.test(val); -}; - -InputScanner.prototype.match = function(pattern) { - var pattern_match = this.__match(pattern, this.__position); - if (pattern_match) { - this.__position += pattern_match[0].length; - } else { - pattern_match = null; - } - return pattern_match; -}; - -InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) { - var val = ''; - var match; - if (starting_pattern) { - match = this.match(starting_pattern); - if (match) { - val += match[0]; - } - } - if (until_pattern && (match || !starting_pattern)) { - val += this.readUntil(until_pattern, until_after); - } - return val; -}; - -InputScanner.prototype.readUntil = function(pattern, until_after) { - var val = ''; - var match_index = this.__position; - pattern.lastIndex = this.__position; - var pattern_match = pattern.exec(this.__input); - if (pattern_match) { - match_index = pattern_match.index; - if (until_after) { - match_index += pattern_match[0].length; - } - } else { - match_index = this.__input_length; - } - - val = this.__input.substring(this.__position, match_index); - this.__position = match_index; - return val; -}; - -InputScanner.prototype.readUntilAfter = function(pattern) { - return this.readUntil(pattern, true); -}; - -InputScanner.prototype.get_regexp = function(pattern, match_from) { - var result = null; - var flags = 'g'; - if (match_from && regexp_has_sticky) { - flags = 'y'; - } - // strings are converted to regexp - if (typeof pattern === "string" && pattern !== '') { - // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags); - result = new RegExp(pattern, flags); - } else if (pattern) { - result = new RegExp(pattern.source, flags); - } - return result; -}; - -InputScanner.prototype.get_literal_regexp = function(literal_string) { - return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')); -}; - -/* css beautifier legacy helpers */ -InputScanner.prototype.peekUntilAfter = function(pattern) { - var start = this.__position; - var val = this.readUntilAfter(pattern); - this.__position = start; - return val; -}; - -InputScanner.prototype.lookBack = function(testVal) { - var start = this.__position - 1; - return start >= testVal.length && this.__input.substring(start - testVal.length, start) - .toLowerCase() === testVal; -}; - -module.exports.InputScanner = InputScanner; - - -/***/ }), -/* 9 */, -/* 10 */, -/* 11 */, -/* 12 */, -/* 13 */ -/***/ (function(module) { - -/*jshint node:true */ -/* - - The MIT License (MIT) - - Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - - - -function Directives(start_block_pattern, end_block_pattern) { - start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source; - end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source; - this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g'); - this.__directive_pattern = / (\w+)[:](\w+)/g; - - this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g'); -} - -Directives.prototype.get_directives = function(text) { - if (!text.match(this.__directives_block_pattern)) { - return null; - } - - var directives = {}; - this.__directive_pattern.lastIndex = 0; - var directive_match = this.__directive_pattern.exec(text); - - while (directive_match) { - directives[directive_match[1]] = directive_match[2]; - directive_match = this.__directive_pattern.exec(text); - } - - return directives; -}; - -Directives.prototype.readIgnored = function(input) { - return input.readUntilAfter(this.__directives_end_ignore_pattern); -}; - - -module.exports.Directives = Directives; - - -/***/ }), -/* 14 */, -/* 15 */ -/***/ (function(module, __unused_webpack_exports, __webpack_require__) { - -/*jshint node:true */ -/* - - The MIT License (MIT) - - Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - - - -var Beautifier = (__webpack_require__(16).Beautifier), - Options = (__webpack_require__(17).Options); - -function css_beautify(source_text, options) { - var beautifier = new Beautifier(source_text, options); - return beautifier.beautify(); -} - -module.exports = css_beautify; -module.exports.defaultOptions = function() { - return new Options(); -}; - - -/***/ }), -/* 16 */ -/***/ (function(module, __unused_webpack_exports, __webpack_require__) { - -/*jshint node:true */ -/* - - The MIT License (MIT) - - Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - - - -var Options = (__webpack_require__(17).Options); -var Output = (__webpack_require__(2).Output); -var InputScanner = (__webpack_require__(8).InputScanner); -var Directives = (__webpack_require__(13).Directives); - -var directives_core = new Directives(/\/\*/, /\*\//); - -var lineBreak = /\r\n|[\r\n]/; -var allLineBreaks = /\r\n|[\r\n]/g; - -// tokenizer -var whitespaceChar = /\s/; -var whitespacePattern = /(?:\s|\n)+/g; -var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g; -var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g; - -function Beautifier(source_text, options) { - this._source_text = source_text || ''; - // Allow the setting of language/file-type specific options - // with inheritance of overall settings - this._options = new Options(options); - this._ch = null; - this._input = null; - - // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule - this.NESTED_AT_RULE = { - "page": true, - "font-face": true, - "keyframes": true, - // also in CONDITIONAL_GROUP_RULE below - "media": true, - "supports": true, - "document": true - }; - this.CONDITIONAL_GROUP_RULE = { - "media": true, - "supports": true, - "document": true - }; - this.NON_SEMICOLON_NEWLINE_PROPERTY = [ - "grid-template-areas", - "grid-template" - ]; - -} - -Beautifier.prototype.eatString = function(endChars) { - var result = ''; - this._ch = this._input.next(); - while (this._ch) { - result += this._ch; - if (this._ch === "\\") { - result += this._input.next(); - } else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") { - break; - } - this._ch = this._input.next(); - } - return result; -}; - -// Skips any white space in the source text from the current position. -// When allowAtLeastOneNewLine is true, will output new lines for each -// newline character found; if the user has preserve_newlines off, only -// the first newline will be output -Beautifier.prototype.eatWhitespace = function(allowAtLeastOneNewLine) { - var result = whitespaceChar.test(this._input.peek()); - var newline_count = 0; - while (whitespaceChar.test(this._input.peek())) { - this._ch = this._input.next(); - if (allowAtLeastOneNewLine && this._ch === '\n') { - if (newline_count === 0 || newline_count < this._options.max_preserve_newlines) { - newline_count++; - this._output.add_new_line(true); - } - } - } - return result; -}; - -// Nested pseudo-class if we are insideRule -// and the next special character found opens -// a new block -Beautifier.prototype.foundNestedPseudoClass = function() { - var openParen = 0; - var i = 1; - var ch = this._input.peek(i); - while (ch) { - if (ch === "{") { - return true; - } else if (ch === '(') { - // pseudoclasses can contain () - openParen += 1; - } else if (ch === ')') { - if (openParen === 0) { - return false; - } - openParen -= 1; - } else if (ch === ";" || ch === "}") { - return false; - } - i++; - ch = this._input.peek(i); - } - return false; -}; - -Beautifier.prototype.print_string = function(output_string) { - this._output.set_indent(this._indentLevel); - this._output.non_breaking_space = true; - this._output.add_token(output_string); -}; - -Beautifier.prototype.preserveSingleSpace = function(isAfterSpace) { - if (isAfterSpace) { - this._output.space_before_token = true; - } -}; - -Beautifier.prototype.indent = function() { - this._indentLevel++; -}; - -Beautifier.prototype.outdent = function() { - if (this._indentLevel > 0) { - this._indentLevel--; - } -}; - -/*_____________________--------------------_____________________*/ - -Beautifier.prototype.beautify = function() { - if (this._options.disabled) { - return this._source_text; - } - - var source_text = this._source_text; - var eol = this._options.eol; - if (eol === 'auto') { - eol = '\n'; - if (source_text && lineBreak.test(source_text || '')) { - eol = source_text.match(lineBreak)[0]; - } - } - - - // HACK: newline parsing inconsistent. This brute force normalizes the this._input. - source_text = source_text.replace(allLineBreaks, '\n'); - - // reset - var baseIndentString = source_text.match(/^[\t ]*/)[0]; - - this._output = new Output(this._options, baseIndentString); - this._input = new InputScanner(source_text); - this._indentLevel = 0; - this._nestedLevel = 0; - - this._ch = null; - var parenLevel = 0; - - var insideRule = false; - // This is the value side of a property value pair (blue in the following ex) - // label { content: blue } - var insidePropertyValue = false; - var enteringConditionalGroup = false; - var insideNonNestedAtRule = false; - var insideScssMap = false; - var topCharacter = this._ch; - var insideNonSemiColonValues = false; - var whitespace; - var isAfterSpace; - var previous_ch; - - while (true) { - whitespace = this._input.read(whitespacePattern); - isAfterSpace = whitespace !== ''; - previous_ch = topCharacter; - this._ch = this._input.next(); - if (this._ch === '\\' && this._input.hasNext()) { - this._ch += this._input.next(); - } - topCharacter = this._ch; - - if (!this._ch) { - break; - } else if (this._ch === '/' && this._input.peek() === '*') { - // /* css comment */ - // Always start block comments on a new line. - // This handles scenarios where a block comment immediately - // follows a property definition on the same line or where - // minified code is being beautified. - this._output.add_new_line(); - this._input.back(); - - var comment = this._input.read(block_comment_pattern); - - // Handle ignore directive - var directives = directives_core.get_directives(comment); - if (directives && directives.ignore === 'start') { - comment += directives_core.readIgnored(this._input); - } - - this.print_string(comment); - - // Ensures any new lines following the comment are preserved - this.eatWhitespace(true); - - // Block comments are followed by a new line so they don't - // share a line with other properties - this._output.add_new_line(); - } else if (this._ch === '/' && this._input.peek() === '/') { - // // single line comment - // Preserves the space before a comment - // on the same line as a rule - this._output.space_before_token = true; - this._input.back(); - this.print_string(this._input.read(comment_pattern)); - - // Ensures any new lines following the comment are preserved - this.eatWhitespace(true); - } else if (this._ch === '$') { - this.preserveSingleSpace(isAfterSpace); - - this.print_string(this._ch); - - // strip trailing space, if present, for hash property checks - var variable = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g); - - if (variable.match(/[ :]$/)) { - // we have a variable or pseudo-class, add it and insert one space before continuing - variable = this.eatString(": ").replace(/\s+$/, ''); - this.print_string(variable); - this._output.space_before_token = true; - } - - // might be sass variable - if (parenLevel === 0 && variable.indexOf(':') !== -1) { - insidePropertyValue = true; - this.indent(); - } - } else if (this._ch === '@') { - this.preserveSingleSpace(isAfterSpace); - - // deal with less property mixins @{...} - if (this._input.peek() === '{') { - this.print_string(this._ch + this.eatString('}')); - } else { - this.print_string(this._ch); - - // strip trailing space, if present, for hash property checks - var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g); - - if (variableOrRule.match(/[ :]$/)) { - // we have a variable or pseudo-class, add it and insert one space before continuing - variableOrRule = this.eatString(": ").replace(/\s+$/, ''); - this.print_string(variableOrRule); - this._output.space_before_token = true; - } - - // might be less variable - if (parenLevel === 0 && variableOrRule.indexOf(':') !== -1) { - insidePropertyValue = true; - this.indent(); - - // might be a nesting at-rule - } else if (variableOrRule in this.NESTED_AT_RULE) { - this._nestedLevel += 1; - if (variableOrRule in this.CONDITIONAL_GROUP_RULE) { - enteringConditionalGroup = true; - } - - // might be a non-nested at-rule - } else if (parenLevel === 0 && !insidePropertyValue) { - insideNonNestedAtRule = true; - } - } - } else if (this._ch === '#' && this._input.peek() === '{') { - this.preserveSingleSpace(isAfterSpace); - this.print_string(this._ch + this.eatString('}')); - } else if (this._ch === '{') { - if (insidePropertyValue) { - insidePropertyValue = false; - this.outdent(); - } - - // non nested at rule becomes nested - insideNonNestedAtRule = false; - - // when entering conditional groups, only rulesets are allowed - if (enteringConditionalGroup) { - enteringConditionalGroup = false; - insideRule = (this._indentLevel >= this._nestedLevel); - } else { - // otherwise, declarations are also allowed - insideRule = (this._indentLevel >= this._nestedLevel - 1); - } - if (this._options.newline_between_rules && insideRule) { - if (this._output.previous_line && this._output.previous_line.item(-1) !== '{') { - this._output.ensure_empty_line_above('/', ','); - } - } - - this._output.space_before_token = true; - - // The difference in print_string and indent order is necessary to indent the '{' correctly - if (this._options.brace_style === 'expand') { - this._output.add_new_line(); - this.print_string(this._ch); - this.indent(); - this._output.set_indent(this._indentLevel); - } else { - // inside mixin and first param is object - if (previous_ch === '(') { - this._output.space_before_token = false; - } else if (previous_ch !== ',') { - this.indent(); - } - this.print_string(this._ch); - } - - this.eatWhitespace(true); - this._output.add_new_line(); - } else if (this._ch === '}') { - this.outdent(); - this._output.add_new_line(); - if (previous_ch === '{') { - this._output.trim(true); - } - - if (insidePropertyValue) { - this.outdent(); - insidePropertyValue = false; - } - this.print_string(this._ch); - insideRule = false; - if (this._nestedLevel) { - this._nestedLevel--; - } - - this.eatWhitespace(true); - this._output.add_new_line(); - - if (this._options.newline_between_rules && !this._output.just_added_blankline()) { - if (this._input.peek() !== '}') { - this._output.add_new_line(true); - } - } - if (this._input.peek() === ')') { - this._output.trim(true); - if (this._options.brace_style === "expand") { - this._output.add_new_line(true); - } - } - } else if (this._ch === ":") { - - for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) { - if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) { - insideNonSemiColonValues = true; - break; - } - } - - if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideNonNestedAtRule && parenLevel === 0) { - // 'property: value' delimiter - // which could be in a conditional group query - - this.print_string(':'); - if (!insidePropertyValue) { - insidePropertyValue = true; - this._output.space_before_token = true; - this.eatWhitespace(true); - this.indent(); - } - } else { - // sass/less parent reference don't use a space - // sass nested pseudo-class don't use a space - - // preserve space before pseudoclasses/pseudoelements, as it means "in any child" - if (this._input.lookBack(" ")) { - this._output.space_before_token = true; - } - if (this._input.peek() === ":") { - // pseudo-element - this._ch = this._input.next(); - this.print_string("::"); - } else { - // pseudo-class - this.print_string(':'); - } - } - } else if (this._ch === '"' || this._ch === '\'') { - var preserveQuoteSpace = previous_ch === '"' || previous_ch === '\''; - this.preserveSingleSpace(preserveQuoteSpace || isAfterSpace); - this.print_string(this._ch + this.eatString(this._ch)); - this.eatWhitespace(true); - } else if (this._ch === ';') { - insideNonSemiColonValues = false; - if (parenLevel === 0) { - if (insidePropertyValue) { - this.outdent(); - insidePropertyValue = false; - } - insideNonNestedAtRule = false; - this.print_string(this._ch); - this.eatWhitespace(true); - - // This maintains single line comments on the same - // line. Block comments are also affected, but - // a new line is always output before one inside - // that section - if (this._input.peek() !== '/') { - this._output.add_new_line(); - } - } else { - this.print_string(this._ch); - this.eatWhitespace(true); - this._output.space_before_token = true; - } - } else if (this._ch === '(') { // may be a url - if (this._input.lookBack("url")) { - this.print_string(this._ch); - this.eatWhitespace(); - parenLevel++; - this.indent(); - this._ch = this._input.next(); - if (this._ch === ')' || this._ch === '"' || this._ch === '\'') { - this._input.back(); - } else if (this._ch) { - this.print_string(this._ch + this.eatString(')')); - if (parenLevel) { - parenLevel--; - this.outdent(); - } - } - } else { - var space_needed = false; - if (this._input.lookBack("with")) { - // look back is not an accurate solution, we need tokens to confirm without whitespaces - space_needed = true; - } - this.preserveSingleSpace(isAfterSpace || space_needed); - this.print_string(this._ch); - - // handle scss/sass map - if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) { - this._output.add_new_line(); - insideScssMap = true; - } else { - this.eatWhitespace(); - parenLevel++; - this.indent(); - } - } - } else if (this._ch === ')') { - if (parenLevel) { - parenLevel--; - this.outdent(); - } - if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) { - insideScssMap = false; - this.outdent(); - this._output.add_new_line(); - } - this.print_string(this._ch); - } else if (this._ch === ',') { - this.print_string(this._ch); - this.eatWhitespace(true); - if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideNonNestedAtRule) { - this._output.add_new_line(); - } else { - this._output.space_before_token = true; - } - } else if ((this._ch === '>' || this._ch === '+' || this._ch === '~') && !insidePropertyValue && parenLevel === 0) { - //handle combinator spacing - if (this._options.space_around_combinator) { - this._output.space_before_token = true; - this.print_string(this._ch); - this._output.space_before_token = true; - } else { - this.print_string(this._ch); - this.eatWhitespace(); - // squash extra whitespace - if (this._ch && whitespaceChar.test(this._ch)) { - this._ch = ''; - } - } - } else if (this._ch === ']') { - this.print_string(this._ch); - } else if (this._ch === '[') { - this.preserveSingleSpace(isAfterSpace); - this.print_string(this._ch); - } else if (this._ch === '=') { // no whitespace before or after - this.eatWhitespace(); - this.print_string('='); - if (whitespaceChar.test(this._ch)) { - this._ch = ''; - } - } else if (this._ch === '!' && !this._input.lookBack("\\")) { // !important - this._output.space_before_token = true; - this.print_string(this._ch); - } else { - var preserveAfterSpace = previous_ch === '"' || previous_ch === '\''; - this.preserveSingleSpace(preserveAfterSpace || isAfterSpace); - this.print_string(this._ch); - - if (!this._output.just_added_newline() && this._input.peek() === '\n' && insideNonSemiColonValues) { - this._output.add_new_line(); - } - } - } - - var sweetCode = this._output.get_code(eol); - - return sweetCode; -}; - -module.exports.Beautifier = Beautifier; - - -/***/ }), -/* 17 */ -/***/ (function(module, __unused_webpack_exports, __webpack_require__) { - -/*jshint node:true */ -/* - - The MIT License (MIT) - - Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation files - (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, - publish, distribute, sublicense, and/or sell copies of the Software, - and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - - - -var BaseOptions = (__webpack_require__(6).Options); - -function Options(options) { - BaseOptions.call(this, options, 'css'); - - this.selector_separator_newline = this._get_boolean('selector_separator_newline', true); - this.newline_between_rules = this._get_boolean('newline_between_rules', true); - var space_around_selector_separator = this._get_boolean('space_around_selector_separator'); - this.space_around_combinator = this._get_boolean('space_around_combinator') || space_around_selector_separator; - - var brace_style_split = this._get_selection_list('brace_style', ['collapse', 'expand', 'end-expand', 'none', 'preserve-inline']); - this.brace_style = 'collapse'; - for (var bs = 0; bs < brace_style_split.length; bs++) { - if (brace_style_split[bs] !== 'expand') { - // default to collapse, as only collapse|expand is implemented for now - this.brace_style = 'collapse'; - } else { - this.brace_style = brace_style_split[bs]; - } - } -} -Options.prototype = new BaseOptions(); - - - -module.exports.Options = Options; - - -/***/ }) -/******/ ]); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ -/******/ // startup -/******/ // Load entry module and return exports -/******/ // This entry module is referenced by other modules so it can't be inlined -/******/ var __webpack_exports__ = __webpack_require__(15); -/******/ legacy_beautify_css = __webpack_exports__; -/******/ -/******/ })() -; - -export var css_beautify = legacy_beautify_css; \ No newline at end of file diff --git a/src/cssLanguageService.ts b/src/cssLanguageService.ts index ea4017cc..010f2cf2 100644 --- a/src/cssLanguageService.ts +++ b/src/cssLanguageService.ts @@ -4,19 +4,19 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { Parser } from './parser/cssParser'; -import { CSSCompletion } from './services/cssCompletion'; -import { CSSHover } from './services/cssHover'; -import { CSSNavigation } from './services/cssNavigation'; -import { CSSCodeActions } from './services/cssCodeActions'; -import { CSSValidation } from './services/cssValidation'; +import { Parser } from './parser/cssParser.js'; +import { CSSCompletion } from './services/cssCompletion.js'; +import { CSSHover } from './services/cssHover.js'; +import { CSSNavigation } from './services/cssNavigation.js'; +import { CSSCodeActions } from './services/cssCodeActions.js'; +import { CSSValidation } from './services/cssValidation.js'; -import { SCSSParser } from './parser/scssParser'; -import { SCSSCompletion } from './services/scssCompletion'; -import { LESSParser } from './parser/lessParser'; -import { LESSCompletion } from './services/lessCompletion'; -import { getFoldingRanges } from './services/cssFolding'; -import { format } from './services/cssFormatter'; +import { SCSSParser } from './parser/scssParser.js'; +import { SCSSCompletion } from './services/scssCompletion.js'; +import { LESSParser } from './parser/lessParser.js'; +import { LESSCompletion } from './services/lessCompletion.js'; +import { getFoldingRanges } from './services/cssFolding.js'; +import { format } from './services/cssFormatter.js'; import { LanguageSettings, ICompletionParticipant, DocumentContext, LanguageServiceOptions, @@ -24,16 +24,16 @@ import { SymbolInformation, Range, CodeActionContext, Command, CodeAction, ColorInformation, Color, ColorPresentation, WorkspaceEdit, FoldingRange, SelectionRange, TextDocument, ICSSDataProvider, CSSDataV1, HoverSettings, CompletionSettings, TextEdit, CSSFormatConfiguration, DocumentSymbol -} from './cssLanguageTypes'; +} from './cssLanguageTypes.js'; -import { CSSDataManager } from './languageFacts/dataManager'; -import { CSSDataProvider } from './languageFacts/dataProvider'; -import { getSelectionRanges } from './services/cssSelectionRange'; -import { SCSSNavigation } from './services/scssNavigation'; -import { cssData } from './data/webCustomData'; +import { CSSDataManager } from './languageFacts/dataManager.js'; +import { CSSDataProvider } from './languageFacts/dataProvider.js'; +import { getSelectionRanges } from './services/cssSelectionRange.js'; +import { SCSSNavigation } from './services/scssNavigation.js'; +import { cssData } from './data/webCustomData.js'; export type Stylesheet = {}; -export * from './cssLanguageTypes'; +export * from './cssLanguageTypes.js'; export interface LanguageService { configure(raw?: LanguageSettings): void; diff --git a/src/data/webCustomData.ts b/src/data/webCustomData.ts index 8d6c5a71..6363c511 100644 --- a/src/data/webCustomData.ts +++ b/src/data/webCustomData.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ // file generated from @vscode/web-custom-data NPM package -import { CSSDataV1 } from '../cssLanguageTypes'; +import { CSSDataV1 } from '../cssLanguageTypes.js'; export const cssData : CSSDataV1 = { "version": 1.1, diff --git a/src/languageFacts/colors.ts b/src/languageFacts/colors.ts index 5c6c8e1c..0c2bdfa5 100644 --- a/src/languageFacts/colors.ts +++ b/src/languageFacts/colors.ts @@ -3,9 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { Color } from '../cssLanguageService'; +import { Color } from '../cssLanguageService.js'; -import * as nodes from '../parser/cssNodes'; +import * as nodes from '../parser/cssNodes.js'; import * as l10n from '@vscode/l10n'; diff --git a/src/languageFacts/dataManager.ts b/src/languageFacts/dataManager.ts index bec293ca..388dfc91 100644 --- a/src/languageFacts/dataManager.ts +++ b/src/languageFacts/dataManager.ts @@ -10,11 +10,11 @@ import { IAtDirectiveData, IPseudoClassData, IPseudoElementData, -} from '../cssLanguageTypes'; +} from '../cssLanguageTypes.js'; -import * as objects from '../utils/objects'; -import { cssData } from '../data/webCustomData'; -import { CSSDataProvider } from './dataProvider'; +import * as objects from '../utils/objects.js'; +import { cssData } from '../data/webCustomData.js'; +import { CSSDataProvider } from './dataProvider.js'; export class CSSDataManager { private dataProviders: ICSSDataProvider[] = []; diff --git a/src/languageFacts/dataProvider.ts b/src/languageFacts/dataProvider.ts index 84720753..9b053d39 100644 --- a/src/languageFacts/dataProvider.ts +++ b/src/languageFacts/dataProvider.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { CSSDataV1, ICSSDataProvider, IPropertyData, IAtDirectiveData, IPseudoClassData, IPseudoElementData } from '../cssLanguageTypes'; +import { CSSDataV1, ICSSDataProvider, IPropertyData, IAtDirectiveData, IPseudoClassData, IPseudoElementData } from '../cssLanguageTypes.js'; export class CSSDataProvider implements ICSSDataProvider { private _properties: IPropertyData[] = []; diff --git a/src/languageFacts/entry.ts b/src/languageFacts/entry.ts index f5324c89..2318d3b2 100644 --- a/src/languageFacts/entry.ts +++ b/src/languageFacts/entry.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { EntryStatus, BaselineStatus, IPropertyData, IAtDirectiveData, IPseudoClassData, IPseudoElementData, IValueData, MarkupContent, MarkupKind, MarkedString, HoverSettings } from '../cssLanguageTypes'; +import { EntryStatus, BaselineStatus, IPropertyData, IAtDirectiveData, IPseudoClassData, IPseudoElementData, IValueData, MarkupContent, MarkupKind, MarkedString, HoverSettings } from '../cssLanguageTypes.js'; export const browserNames = { 'C': { diff --git a/src/languageFacts/facts.ts b/src/languageFacts/facts.ts index a8c6d872..9988e65c 100644 --- a/src/languageFacts/facts.ts +++ b/src/languageFacts/facts.ts @@ -4,6 +4,6 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -export * from './entry'; -export * from './colors'; -export * from './builtinData'; \ No newline at end of file +export * from './entry.js'; +export * from './colors.js'; +export * from './builtinData.js'; \ No newline at end of file diff --git a/src/parser/cssErrors.ts b/src/parser/cssErrors.ts index 690b2491..8af84232 100644 --- a/src/parser/cssErrors.ts +++ b/src/parser/cssErrors.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as nodes from './cssNodes'; +import * as nodes from './cssNodes.js'; import * as l10n from '@vscode/l10n'; diff --git a/src/parser/cssNodes.ts b/src/parser/cssNodes.ts index d7ebd7df..a8979a6a 100644 --- a/src/parser/cssNodes.ts +++ b/src/parser/cssNodes.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { trim } from "../utils/strings"; +import { trim } from "../utils/strings.js"; /// /// Nodes for the css 2.1 specification. See for reference: diff --git a/src/parser/cssParser.ts b/src/parser/cssParser.ts index 2059487c..bfffb4f4 100644 --- a/src/parser/cssParser.ts +++ b/src/parser/cssParser.ts @@ -3,12 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { TokenType, Scanner, IToken } from './cssScanner'; -import * as nodes from './cssNodes'; -import { ParseError, CSSIssueType } from './cssErrors'; -import * as languageFacts from '../languageFacts/facts'; -import { TextDocument } from '../cssLanguageTypes'; -import { isDefined } from '../utils/objects'; +import { TokenType, Scanner, IToken } from './cssScanner.js'; +import * as nodes from './cssNodes.js'; +import { ParseError, CSSIssueType } from './cssErrors.js'; +import * as languageFacts from '../languageFacts/facts.js'; +import { TextDocument } from '../cssLanguageTypes.js'; +import { isDefined } from '../utils/objects.js'; export interface IMark { prev?: IToken; diff --git a/src/parser/cssSymbolScope.ts b/src/parser/cssSymbolScope.ts index 3e833e80..80b934c4 100644 --- a/src/parser/cssSymbolScope.ts +++ b/src/parser/cssSymbolScope.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as nodes from './cssNodes'; -import { findFirst } from '../utils/arrays'; +import * as nodes from './cssNodes.js'; +import { findFirst } from '../utils/arrays.js'; export class Scope { diff --git a/src/parser/lessParser.ts b/src/parser/lessParser.ts index ad5259ac..e401cb0f 100644 --- a/src/parser/lessParser.ts +++ b/src/parser/lessParser.ts @@ -4,11 +4,11 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as lessScanner from './lessScanner'; -import { TokenType } from './cssScanner'; -import * as cssParser from './cssParser'; -import * as nodes from './cssNodes'; -import { ParseError } from './cssErrors'; +import * as lessScanner from './lessScanner.js'; +import { TokenType } from './cssScanner.js'; +import * as cssParser from './cssParser.js'; +import * as nodes from './cssNodes.js'; +import { ParseError } from './cssErrors.js'; /// /// A parser for LESS diff --git a/src/parser/lessScanner.ts b/src/parser/lessScanner.ts index 8c1e0e92..5e83b969 100644 --- a/src/parser/lessScanner.ts +++ b/src/parser/lessScanner.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as scanner from './cssScanner'; +import * as scanner from './cssScanner.js'; const _FSL = '/'.charCodeAt(0); const _NWL = '\n'.charCodeAt(0); diff --git a/src/parser/scssErrors.ts b/src/parser/scssErrors.ts index ef92fc00..1436fcbf 100644 --- a/src/parser/scssErrors.ts +++ b/src/parser/scssErrors.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as nodes from './cssNodes'; +import * as nodes from './cssNodes.js'; import * as l10n from '@vscode/l10n'; diff --git a/src/parser/scssParser.ts b/src/parser/scssParser.ts index ad3eddfe..6b31dbb4 100644 --- a/src/parser/scssParser.ts +++ b/src/parser/scssParser.ts @@ -3,13 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as scssScanner from './scssScanner'; -import { TokenType } from './cssScanner'; -import * as cssParser from './cssParser'; -import * as nodes from './cssNodes'; +import * as scssScanner from './scssScanner.js'; +import { TokenType } from './cssScanner.js'; +import * as cssParser from './cssParser.js'; +import * as nodes from './cssNodes.js'; -import { SCSSParseError } from './scssErrors'; -import { ParseError } from './cssErrors'; +import { SCSSParseError } from './scssErrors.js'; +import { ParseError } from './cssErrors.js'; /// /// A parser for scss diff --git a/src/parser/scssScanner.ts b/src/parser/scssScanner.ts index cdd8d308..f193f9b6 100644 --- a/src/parser/scssScanner.ts +++ b/src/parser/scssScanner.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { TokenType, Scanner, IToken } from './cssScanner'; +import { TokenType, Scanner, IToken } from './cssScanner.js'; const _FSL = '/'.charCodeAt(0); const _NWL = '\n'.charCodeAt(0); diff --git a/src/services/cssCodeActions.ts b/src/services/cssCodeActions.ts index 731cb31d..0aecdf75 100644 --- a/src/services/cssCodeActions.ts +++ b/src/services/cssCodeActions.ts @@ -4,15 +4,15 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as nodes from '../parser/cssNodes'; -import { difference } from '../utils/strings'; -import { Rules } from '../services/lintRules'; +import * as nodes from '../parser/cssNodes.js'; +import { difference } from '../utils/strings.js'; +import { Rules } from '../services/lintRules.js'; import { Range, CodeActionContext, Diagnostic, Command, TextEdit, CodeAction, WorkspaceEdit, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier, TextDocument, ICSSDataProvider -} from '../cssLanguageTypes'; +} from '../cssLanguageTypes.js'; import * as l10n from '@vscode/l10n'; -import { CSSDataManager } from '../languageFacts/dataManager'; +import { CSSDataManager } from '../languageFacts/dataManager.js'; export class CSSCodeActions { diff --git a/src/services/cssCompletion.ts b/src/services/cssCompletion.ts index cfda4123..e8b94a29 100644 --- a/src/services/cssCompletion.ts +++ b/src/services/cssCompletion.ts @@ -4,20 +4,20 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as nodes from '../parser/cssNodes'; -import { Symbols, Symbol } from '../parser/cssSymbolScope'; -import * as languageFacts from '../languageFacts/facts'; -import * as strings from '../utils/strings'; +import * as nodes from '../parser/cssNodes.js'; +import { Symbols, Symbol } from '../parser/cssSymbolScope.js'; +import * as languageFacts from '../languageFacts/facts.js'; +import * as strings from '../utils/strings.js'; import { ICompletionParticipant, LanguageSettings, TextDocument, Command, Position, CompletionList, CompletionItem, CompletionItemKind, Range, TextEdit, InsertTextFormat, MarkupKind, CompletionItemTag, DocumentContext, LanguageServiceOptions, IPropertyData, CompletionSettings, IDescriptorData -} from '../cssLanguageTypes'; +} from '../cssLanguageTypes.js'; import * as l10n from '@vscode/l10n'; -import { isDefined } from '../utils/objects'; -import { CSSDataManager } from '../languageFacts/dataManager'; -import { PathCompletionParticipant } from './pathCompletion'; +import { isDefined } from '../utils/objects.js'; +import { CSSDataManager } from '../languageFacts/dataManager.js'; +import { PathCompletionParticipant } from './pathCompletion.js'; const SnippetFormat = InsertTextFormat.Snippet; diff --git a/src/services/cssFolding.ts b/src/services/cssFolding.ts index 61a8258d..2a87101c 100644 --- a/src/services/cssFolding.ts +++ b/src/services/cssFolding.ts @@ -4,10 +4,10 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { TextDocument, FoldingRange, FoldingRangeKind } from '../cssLanguageTypes'; -import { TokenType, Scanner, IToken } from '../parser/cssScanner'; -import { SCSSScanner, InterpolationFunction } from '../parser/scssScanner'; -import { LESSScanner } from '../parser/lessScanner'; +import { TextDocument, FoldingRange, FoldingRangeKind } from '../cssLanguageTypes.js'; +import { TokenType, Scanner, IToken } from '../parser/cssScanner.js'; +import { SCSSScanner, InterpolationFunction } from '../parser/scssScanner.js'; +import { LESSScanner } from '../parser/lessScanner.js'; type DelimiterType = 'brace' | 'comment'; type Delimiter = { line: number, type: DelimiterType, isStart: boolean }; diff --git a/src/services/cssFormatter.ts b/src/services/cssFormatter.ts index e379e2a8..b9f31960 100644 --- a/src/services/cssFormatter.ts +++ b/src/services/cssFormatter.ts @@ -3,9 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { CSSFormatConfiguration, Range, TextEdit, Position, TextDocument } from '../cssLanguageTypes'; -import { css_beautify, IBeautifyCSSOptions } from '../beautify/beautify-css'; -import { repeat } from '../utils/strings'; +import { CSSFormatConfiguration, Range, TextEdit, Position, TextDocument } from '../cssLanguageTypes.js'; +import { css_beautify, IBeautifyCSSOptions } from '../beautify/beautify-css.js'; +import { repeat } from '../utils/strings.js'; export function format(document: TextDocument, range: Range | undefined, options: CSSFormatConfiguration): TextEdit[] { let value = document.getText(); diff --git a/src/services/cssHover.ts b/src/services/cssHover.ts index dbcbd097..35c4cd23 100644 --- a/src/services/cssHover.ts +++ b/src/services/cssHover.ts @@ -4,13 +4,13 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as nodes from '../parser/cssNodes'; -import * as languageFacts from '../languageFacts/facts'; -import { SelectorPrinting } from './selectorPrinting'; -import { startsWith } from '../utils/strings'; -import { TextDocument, Range, Position, Hover, MarkedString, MarkupContent, MarkupKind, ClientCapabilities, HoverSettings } from '../cssLanguageTypes'; -import { isDefined } from '../utils/objects'; -import { CSSDataManager } from '../languageFacts/dataManager'; +import * as nodes from '../parser/cssNodes.js'; +import * as languageFacts from '../languageFacts/facts.js'; +import { SelectorPrinting } from './selectorPrinting.js'; +import { startsWith } from '../utils/strings.js'; +import { TextDocument, Range, Position, Hover, MarkedString, MarkupContent, MarkupKind, ClientCapabilities, HoverSettings } from '../cssLanguageTypes.js'; +import { isDefined } from '../utils/objects.js'; +import { CSSDataManager } from '../languageFacts/dataManager.js'; export class CSSHover { private supportsMarkdown: boolean | undefined; diff --git a/src/services/cssNavigation.ts b/src/services/cssNavigation.ts index 663f9125..b61d564c 100644 --- a/src/services/cssNavigation.ts +++ b/src/services/cssNavigation.ts @@ -7,10 +7,10 @@ import { AliasSettings, Color, ColorInformation, ColorPresentation, DocumentHighlight, DocumentHighlightKind, DocumentLink, Location, Position, Range, SymbolInformation, SymbolKind, TextEdit, WorkspaceEdit, TextDocument, DocumentContext, FileSystemProvider, FileType, DocumentSymbol -} from '../cssLanguageTypes'; +} from '../cssLanguageTypes.js'; import * as l10n from '@vscode/l10n'; -import * as nodes from '../parser/cssNodes'; -import { Symbols } from '../parser/cssSymbolScope'; +import * as nodes from '../parser/cssNodes.js'; +import { Symbols } from '../parser/cssSymbolScope.js'; import { getColorValue, hslFromColor, @@ -19,9 +19,9 @@ import { lchFromColor, oklabFromColor, oklchFromColor, -} from '../languageFacts/facts'; -import { startsWith } from '../utils/strings'; -import { dirname, joinPath } from '../utils/resources'; +} from '../languageFacts/facts.js'; +import { startsWith } from '../utils/strings.js'; +import { dirname, joinPath } from '../utils/resources.js'; type UnresolvedLinkData = { link: DocumentLink, isRawLink: boolean }; diff --git a/src/services/cssSelectionRange.ts b/src/services/cssSelectionRange.ts index 215be43d..fa786c02 100644 --- a/src/services/cssSelectionRange.ts +++ b/src/services/cssSelectionRange.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { Range, Position, SelectionRange, TextDocument } from '../cssLanguageTypes'; -import { Stylesheet, NodeType } from '../parser/cssNodes'; +import { Range, Position, SelectionRange, TextDocument } from '../cssLanguageTypes.js'; +import { Stylesheet, NodeType } from '../parser/cssNodes.js'; export function getSelectionRanges(document: TextDocument, positions: Position[], stylesheet: Stylesheet): SelectionRange[] { function getSelectionRange(position: Position): SelectionRange { diff --git a/src/services/cssValidation.ts b/src/services/cssValidation.ts index e51cc846..a5870cf3 100644 --- a/src/services/cssValidation.ts +++ b/src/services/cssValidation.ts @@ -4,11 +4,11 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as nodes from '../parser/cssNodes'; -import { LintConfigurationSettings, Rules } from './lintRules'; -import { LintVisitor } from './lint'; -import { TextDocument, Range, Diagnostic, DiagnosticSeverity, LanguageSettings } from '../cssLanguageTypes'; -import { CSSDataManager } from '../languageFacts/dataManager'; +import * as nodes from '../parser/cssNodes.js'; +import { LintConfigurationSettings, Rules } from './lintRules.js'; +import { LintVisitor } from './lint.js'; +import { TextDocument, Range, Diagnostic, DiagnosticSeverity, LanguageSettings } from '../cssLanguageTypes.js'; +import { CSSDataManager } from '../languageFacts/dataManager.js'; export class CSSValidation { diff --git a/src/services/lessCompletion.ts b/src/services/lessCompletion.ts index 6679e7a8..64f01cee 100644 --- a/src/services/lessCompletion.ts +++ b/src/services/lessCompletion.ts @@ -4,12 +4,12 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as nodes from '../parser/cssNodes'; -import { CSSCompletion } from './cssCompletion'; -import { CompletionList, CompletionItemKind, InsertTextFormat, TextEdit, CompletionItem, LanguageServiceOptions, IPropertyData } from '../cssLanguageTypes'; +import * as nodes from '../parser/cssNodes.js'; +import { CSSCompletion } from './cssCompletion.js'; +import { CompletionList, CompletionItemKind, InsertTextFormat, TextEdit, CompletionItem, LanguageServiceOptions, IPropertyData } from '../cssLanguageTypes.js'; import * as l10n from '@vscode/l10n'; -import { CSSDataManager } from '../languageFacts/dataManager'; +import { CSSDataManager } from '../languageFacts/dataManager.js'; interface IFunctionInfo { name: string; diff --git a/src/services/lint.ts b/src/services/lint.ts index fe717072..075c6725 100644 --- a/src/services/lint.ts +++ b/src/services/lint.ts @@ -5,13 +5,13 @@ 'use strict'; import * as l10n from '@vscode/l10n'; -import { TextDocument } from '../cssLanguageTypes'; -import { CSSDataManager } from '../languageFacts/dataManager'; -import * as languageFacts from '../languageFacts/facts'; -import * as nodes from '../parser/cssNodes'; -import { union } from '../utils/arrays'; -import { LintConfigurationSettings, Rule, Rules, Settings } from './lintRules'; -import calculateBoxModel, { Element } from './lintUtil'; +import { TextDocument } from '../cssLanguageTypes.js'; +import { CSSDataManager } from '../languageFacts/dataManager.js'; +import * as languageFacts from '../languageFacts/facts.js'; +import * as nodes from '../parser/cssNodes.js'; +import { union } from '../utils/arrays.js'; +import { LintConfigurationSettings, Rule, Rules, Settings } from './lintRules.js'; +import calculateBoxModel, { Element } from './lintUtil.js'; diff --git a/src/services/lintRules.ts b/src/services/lintRules.ts index e91f5906..0ad7f12b 100644 --- a/src/services/lintRules.ts +++ b/src/services/lintRules.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as nodes from '../parser/cssNodes'; -import { LintSettings } from '../cssLanguageTypes'; +import * as nodes from '../parser/cssNodes.js'; +import { LintSettings } from '../cssLanguageTypes.js'; import * as l10n from '@vscode/l10n'; diff --git a/src/services/lintUtil.ts b/src/services/lintUtil.ts index c4e09e1e..a65639ae 100644 --- a/src/services/lintUtil.ts +++ b/src/services/lintUtil.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as nodes from '../parser/cssNodes'; -import { includes } from '../utils/arrays'; +import * as nodes from '../parser/cssNodes.js'; +import { includes } from '../utils/arrays.js'; export class Element { diff --git a/src/services/pathCompletion.ts b/src/services/pathCompletion.ts index fda40e62..5bbe2a77 100644 --- a/src/services/pathCompletion.ts +++ b/src/services/pathCompletion.ts @@ -4,10 +4,10 @@ *--------------------------------------------------------------------------------------------*/ import { DocumentUri } from 'vscode-languageserver-types'; -import { ICompletionParticipant, URILiteralCompletionContext, ImportPathCompletionContext, FileType, DocumentContext, TextDocument, CompletionList, CompletionItemKind, CompletionItem, TextEdit, Range, Position } from '../cssLanguageTypes'; +import { ICompletionParticipant, URILiteralCompletionContext, ImportPathCompletionContext, FileType, DocumentContext, TextDocument, CompletionList, CompletionItemKind, CompletionItem, TextEdit, Range, Position } from '../cssLanguageTypes.js'; -import { startsWith, endsWith } from '../utils/strings'; -import { joinPath } from '../utils/resources'; +import { startsWith, endsWith } from '../utils/strings.js'; +import { joinPath } from '../utils/resources.js'; export class PathCompletionParticipant implements ICompletionParticipant { private literalCompletions: URILiteralCompletionContext[] = []; diff --git a/src/services/scssCompletion.ts b/src/services/scssCompletion.ts index 14486eec..fe20610d 100644 --- a/src/services/scssCompletion.ts +++ b/src/services/scssCompletion.ts @@ -4,11 +4,11 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { CSSCompletion } from './cssCompletion'; -import * as nodes from '../parser/cssNodes'; -import { CompletionList, CompletionItemKind, TextEdit, InsertTextFormat, CompletionItem, MarkupContent, IReference, LanguageServiceOptions, IPropertyData } from '../cssLanguageTypes'; +import { CSSCompletion } from './cssCompletion.js'; +import * as nodes from '../parser/cssNodes.js'; +import { CompletionList, CompletionItemKind, TextEdit, InsertTextFormat, CompletionItem, MarkupContent, IReference, LanguageServiceOptions, IPropertyData } from '../cssLanguageTypes.js'; import * as l10n from '@vscode/l10n'; -import { CSSDataManager } from '../languageFacts/dataManager'; +import { CSSDataManager } from '../languageFacts/dataManager.js'; interface IFunctionInfo { func: string; diff --git a/src/services/scssNavigation.ts b/src/services/scssNavigation.ts index 38536a09..84fb6599 100644 --- a/src/services/scssNavigation.ts +++ b/src/services/scssNavigation.ts @@ -4,12 +4,12 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { CSSNavigation, getModuleNameFromPath } from './cssNavigation'; -import { FileSystemProvider, DocumentContext, FileType, DocumentUri } from '../cssLanguageTypes'; -import * as nodes from '../parser/cssNodes'; +import { CSSNavigation, getModuleNameFromPath } from './cssNavigation.js'; +import { FileSystemProvider, DocumentContext, FileType, DocumentUri } from '../cssLanguageTypes.js'; +import * as nodes from '../parser/cssNodes.js'; import { URI, Utils } from 'vscode-uri'; -import { convertSimple2RegExpPattern, startsWith } from '../utils/strings'; -import { dirname, joinPath } from '../utils/resources'; +import { convertSimple2RegExpPattern, startsWith } from '../utils/strings.js'; +import { dirname, joinPath } from '../utils/resources.js'; export class SCSSNavigation extends CSSNavigation { constructor(fileSystemProvider: FileSystemProvider | undefined) { diff --git a/src/services/selectorPrinting.ts b/src/services/selectorPrinting.ts index c4ca8dee..4138e7a8 100644 --- a/src/services/selectorPrinting.ts +++ b/src/services/selectorPrinting.ts @@ -4,12 +4,12 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as nodes from '../parser/cssNodes'; -import { MarkedString } from '../cssLanguageTypes'; -import { Scanner } from '../parser/cssScanner'; +import * as nodes from '../parser/cssNodes.js'; +import { MarkedString } from '../cssLanguageTypes.js'; +import { Scanner } from '../parser/cssScanner.js'; import * as l10n from '@vscode/l10n'; -import { CSSDataManager } from '../languageFacts/dataManager'; -import { Parser } from '../parser/cssParser'; +import { CSSDataManager } from '../languageFacts/dataManager.js'; +import { Parser } from '../parser/cssParser.js'; export class Element { public parent: Element | null = null; diff --git a/src/test/css/codeActions.test.ts b/src/test/css/codeActions.test.ts index 37360caf..f161bb01 100644 --- a/src/test/css/codeActions.test.ts +++ b/src/test/css/codeActions.test.ts @@ -7,7 +7,7 @@ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import { getCSSLanguageService, TextDocument, TextEdit, Range, Command, CodeAction, TextDocumentEdit } from '../../cssLanguageService'; +import { getCSSLanguageService, TextDocument, TextEdit, Range, Command, CodeAction, TextDocumentEdit } from '../../cssLanguageService.js'; suite('CSS - Code Actions', () => { diff --git a/src/test/css/completion.test.ts b/src/test/css/completion.test.ts index bd422754..b0848b65 100644 --- a/src/test/css/completion.test.ts +++ b/src/test/css/completion.test.ts @@ -7,17 +7,20 @@ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; import * as path from 'path'; +import { fileURLToPath } from 'node:url'; import { getCSSLanguageService, LanguageSettings, PropertyCompletionContext, PropertyValueCompletionContext, URILiteralCompletionContext, ImportPathCompletionContext, TextDocument, CompletionList, Position, CompletionItemKind, InsertTextFormat, Range, Command, MarkupContent, MixinReferenceCompletionContext, getSCSSLanguageService, getLESSLanguageService, ICSSDataProvider, newCSSDataProvider -} from '../../cssLanguageService'; -import { BaselineImages } from '../../languageFacts/facts'; -import { getDocumentContext } from '../testUtil/documentContext'; +} from '../../cssLanguageService.js'; +import { BaselineImages } from '../../languageFacts/facts.js'; +import { getDocumentContext } from '../testUtil/documentContext.js'; import { URI } from 'vscode-uri'; -import { getFsProvider } from '../testUtil/fsProvider'; +import { getFsProvider } from '../testUtil/fsProvider.js'; import { TextEdit } from 'vscode-languageserver-types'; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + export interface ItemDescription { label: string; detail?: string; diff --git a/src/test/css/customData.test.ts b/src/test/css/customData.test.ts index a1892b4a..972b95ac 100644 --- a/src/test/css/customData.test.ts +++ b/src/test/css/customData.test.ts @@ -7,8 +7,8 @@ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import { testCompletionFor } from './completion.test'; -import { getCSSLanguageService, TextDocument, newCSSDataProvider, LanguageSettings } from '../../cssLanguageService'; +import { testCompletionFor } from './completion.test.js'; +import { getCSSLanguageService, TextDocument, newCSSDataProvider, LanguageSettings } from '../../cssLanguageService.js'; suite('CSS - Custom Data', async () => { diff --git a/src/test/css/folding.test.ts b/src/test/css/folding.test.ts index e328dcbe..be71b4ee 100644 --- a/src/test/css/folding.test.ts +++ b/src/test/css/folding.test.ts @@ -7,7 +7,7 @@ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import { TextDocument, FoldingRange, FoldingRangeKind, getCSSLanguageService } from '../../cssLanguageService'; +import { TextDocument, FoldingRange, FoldingRangeKind, getCSSLanguageService } from '../../cssLanguageService.js'; function assertRanges(lines: string[], expected: FoldingRange[], languageId = 'css', rangeLimit: number | null = null): void { const document = TextDocument.create(`test://foo/bar.${languageId}`, languageId, 1, lines.join('\n')); diff --git a/src/test/css/formatter.test.ts b/src/test/css/formatter.test.ts index 153af05a..909bcd53 100644 --- a/src/test/css/formatter.test.ts +++ b/src/test/css/formatter.test.ts @@ -2,10 +2,10 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { getCSSLanguageService, TextDocument, Range, getLESSLanguageService, LanguageService } from '../../cssLanguageService'; +import { getCSSLanguageService, TextDocument, Range, getLESSLanguageService, LanguageService } from '../../cssLanguageService.js'; import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import { CSSFormatConfiguration } from '../../cssLanguageTypes'; +import { CSSFormatConfiguration } from '../../cssLanguageTypes.js'; export function assertFormat(unformatted: string, expected: string, options: CSSFormatConfiguration = { tabSize: 2, insertSpaces: true }, ls: LanguageService = getCSSLanguageService()) { diff --git a/src/test/css/hover.test.ts b/src/test/css/hover.test.ts index 96a2e6be..34b69288 100644 --- a/src/test/css/hover.test.ts +++ b/src/test/css/hover.test.ts @@ -7,9 +7,9 @@ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import { Hover, TextDocument, getCSSLanguageService, getLESSLanguageService, getSCSSLanguageService } from '../../cssLanguageService'; -import { HoverSettings } from '../../cssLanguageTypes'; -import { BaselineImages } from '../../languageFacts/facts'; +import { Hover, TextDocument, getCSSLanguageService, getLESSLanguageService, getSCSSLanguageService } from '../../cssLanguageService.js'; +import { HoverSettings } from '../../cssLanguageTypes.js'; +import { BaselineImages } from '../../languageFacts/facts.js'; function assertHover(value: string, expected: Hover, languageId = 'css', hoverSettings?: HoverSettings): void { let offset = value.indexOf('|'); @@ -18,7 +18,7 @@ function assertHover(value: string, expected: Hover, languageId = 'css', hoverSe const document = TextDocument.create(`test://foo/bar.${languageId}`, languageId, 1, value); const hoverResult = ls.doHover(document, document.positionAt(offset), ls.parseStylesheet(document), hoverSettings); - assert(hoverResult); + assert.ok(hoverResult); if (hoverResult!.range && expected.range) { assert.equal(hoverResult!.range, expected.range); diff --git a/src/test/css/languageFacts.test.ts b/src/test/css/languageFacts.test.ts index a139d1cf..bddfa5cf 100644 --- a/src/test/css/languageFacts.test.ts +++ b/src/test/css/languageFacts.test.ts @@ -30,18 +30,18 @@ import { xyzFromOKLAB, XYZtoOKLAB, xyzToRGB, -} from '../../languageFacts/facts'; +} from '../../languageFacts/facts.js'; import type { HSLA, HWBA, LAB, LCH, XYZ, -} from '../../languageFacts/facts'; -import { Parser } from '../../parser/cssParser'; -import * as nodes from '../../parser/cssNodes'; -import { TextDocument, Color } from '../../cssLanguageTypes'; -import { CSSDataManager } from '../../languageFacts/dataManager'; +} from '../../languageFacts/facts.js'; +import { Parser } from '../../parser/cssParser.js'; +import * as nodes from '../../parser/cssNodes.js'; +import { TextDocument, Color } from '../../cssLanguageTypes.js'; +import { CSSDataManager } from '../../languageFacts/dataManager.js'; export function assertColor(parser: Parser, text: string, selection: string, expected: Color | null, isColor = expected !== null): void { let document = TextDocument.create('test://test/test.css', 'css', 0, text); @@ -49,7 +49,7 @@ export function assertColor(parser: Parser, text: string, selection: string, exp assert.equal(nodes.ParseErrorCollector.entries(stylesheet).length, 0, 'compile errors'); let node = nodes.getNodeAtOffset(stylesheet, text.indexOf(selection)); - assert(node); + assert.ok(node); if (node!.parent && node!.parent.type === nodes.NodeType.Function) { node = node!.parent; } diff --git a/src/test/css/lint.test.ts b/src/test/css/lint.test.ts index cc0fa2ed..f1fe81a3 100644 --- a/src/test/css/lint.test.ts +++ b/src/test/css/lint.test.ts @@ -6,14 +6,14 @@ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import { Node, IRule, Level } from '../../parser/cssNodes'; -import { Parser } from '../../parser/cssParser'; -import { LintVisitor } from '../../services/lint'; -import { Rule, Rules, LintConfigurationSettings } from '../../services/lintRules'; -import { TextDocument } from '../../cssLanguageTypes'; -import { SCSSParser } from '../../parser/scssParser'; -import { LESSParser } from '../../parser/lessParser'; -import { CSSDataManager } from '../../languageFacts/dataManager'; +import { Node, IRule, Level } from '../../parser/cssNodes.js'; +import { Parser } from '../../parser/cssParser.js'; +import { LintVisitor } from '../../services/lint.js'; +import { Rule, Rules, LintConfigurationSettings } from '../../services/lintRules.js'; +import { TextDocument } from '../../cssLanguageTypes.js'; +import { SCSSParser } from '../../parser/scssParser.js'; +import { LESSParser } from '../../parser/lessParser.js'; +import { CSSDataManager } from '../../languageFacts/dataManager.js'; const cssDataManager = new CSSDataManager({ useDefaultDataProvider: true }); diff --git a/src/test/css/navigation.test.ts b/src/test/css/navigation.test.ts index 9fb8da1b..9670ac40 100644 --- a/src/test/css/navigation.test.ts +++ b/src/test/css/navigation.test.ts @@ -6,19 +6,22 @@ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import { join } from 'path'; -import { Scope, GlobalScope, ScopeBuilder } from '../../parser/cssSymbolScope'; -import * as nodes from '../../parser/cssNodes'; -import { colorFrom256RGB, colorFromHSL, colorFromHWB } from '../../languageFacts/facts'; +import { dirname, join } from 'path'; +import { fileURLToPath } from 'node:url'; +import { Scope, GlobalScope, ScopeBuilder } from '../../parser/cssSymbolScope.js'; +import * as nodes from '../../parser/cssNodes.js'; +import { colorFrom256RGB, colorFromHSL, colorFromHWB } from '../../languageFacts/facts.js'; import { TextDocument, DocumentHighlightKind, Range, Position, TextEdit, Color, ColorInformation, DocumentLink, SymbolKind, SymbolInformation, Location, LanguageService, Stylesheet, getCSSLanguageService, DocumentSymbol, LanguageSettings, -} from '../../cssLanguageService'; +} from '../../cssLanguageService.js'; import { URI } from 'vscode-uri'; -import { getFsProvider } from '../testUtil/fsProvider'; -import { getDocumentContext } from '../testUtil/documentContext'; +import { getFsProvider } from '../testUtil/fsProvider.js'; +import { getDocumentContext } from '../testUtil/documentContext.js'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); export function assertScopesAndSymbols(ls: LanguageService, input: string, expected: string): void { const global = createScope(ls, input); diff --git a/src/test/css/nodes.test.ts b/src/test/css/nodes.test.ts index bd176c9a..6db04dbf 100644 --- a/src/test/css/nodes.test.ts +++ b/src/test/css/nodes.test.ts @@ -6,8 +6,8 @@ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import * as nodes from '../../parser/cssNodes'; -import { Parser } from '../../parser/cssParser'; +import * as nodes from '../../parser/cssNodes.js'; +import { Parser } from '../../parser/cssParser.js'; export class PrintingVisitor implements nodes.IVisitor { diff --git a/src/test/css/parser.test.ts b/src/test/css/parser.test.ts index fd8a9352..54116fb4 100644 --- a/src/test/css/parser.test.ts +++ b/src/test/css/parser.test.ts @@ -6,10 +6,10 @@ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import { Parser } from '../../parser/cssParser'; -import { TokenType } from '../../parser/cssScanner'; -import * as nodes from '../../parser/cssNodes'; -import { ParseError } from '../../parser/cssErrors'; +import { Parser } from '../../parser/cssParser.js'; +import { TokenType } from '../../parser/cssScanner.js'; +import * as nodes from '../../parser/cssNodes.js'; +import { ParseError } from '../../parser/cssErrors.js'; export function assertNode(text: string, parser: Parser, f: (...args: any[]) => nodes.Node | null): nodes.Node { const node = parser.internalParse(text, f)!; diff --git a/src/test/css/scanner.test.ts b/src/test/css/scanner.test.ts index 7780136e..f579d13f 100644 --- a/src/test/css/scanner.test.ts +++ b/src/test/css/scanner.test.ts @@ -6,7 +6,7 @@ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import { Scanner, TokenType } from '../../parser/cssScanner'; +import { Scanner, TokenType } from '../../parser/cssScanner.js'; suite('CSS - Scanner', () => { @@ -65,7 +65,7 @@ suite('CSS - Scanner', () => { function assertURLArgument(source: string, text: string, tokenType: TokenType): void { scanner.setSource(source); let token = scanner.scanUnquotedString(); - assert(token); + assert.ok(token); assert.equal(token!.len, text.length); assert.equal(token!.offset, 0); assert.equal(token!.text, text); diff --git a/src/test/css/selectionRange.test.ts b/src/test/css/selectionRange.test.ts index ad09447b..d1a681b5 100644 --- a/src/test/css/selectionRange.test.ts +++ b/src/test/css/selectionRange.test.ts @@ -6,7 +6,7 @@ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import { getCSSLanguageService, TextDocument, SelectionRange } from '../../cssLanguageService'; +import { getCSSLanguageService, TextDocument, SelectionRange } from '../../cssLanguageService.js'; function assertRanges(content: string, expected: (number | string)[][]): void { let message = `${content} gives selection range:\n`; diff --git a/src/test/css/selectorPrinting.test.ts b/src/test/css/selectorPrinting.test.ts index 1cb413fb..ac3e3974 100644 --- a/src/test/css/selectorPrinting.test.ts +++ b/src/test/css/selectorPrinting.test.ts @@ -6,11 +6,11 @@ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import { Parser } from '../../parser/cssParser'; -import * as nodes from '../../parser/cssNodes'; -import * as selectorPrinting from '../../services/selectorPrinting'; -import { TextDocument, MarkedString } from '../../cssLanguageTypes'; -import { CSSDataManager } from '../../languageFacts/dataManager'; +import { Parser } from '../../parser/cssParser.js'; +import * as nodes from '../../parser/cssNodes.js'; +import * as selectorPrinting from '../../services/selectorPrinting.js'; +import { TextDocument, MarkedString } from '../../cssLanguageTypes.js'; +import { CSSDataManager } from '../../languageFacts/dataManager.js'; const cssDataManager = new CSSDataManager({ useDefaultDataProvider: true }); @@ -57,10 +57,10 @@ function doParse(p: Parser, input: string, selectorName: string): nodes.Selector export function assertSelector(p: Parser, input: string, selectorName: string, expected: string): void { let selector = doParse(p, input, selectorName); - assert(selector); + assert.ok(selector); let element = selectorPrinting.selectorToElement(selector!); - assert(element); + assert.ok(element); assert.equal(elementToString(element!), expected); } @@ -79,7 +79,7 @@ function assertSelectorMarkdown( expected: MarkedString[] ): void { let selector = doParse(p, input, selectorName); - assert(selector); + assert.ok(selector); const selectorPrinter = new selectorPrinting.SelectorPrinting(cssDataManager); let printedElement = selectorPrinter.selectorToMarkedString(selector!); diff --git a/src/test/less/formatter.test.ts b/src/test/less/formatter.test.ts index c7afb7e5..bd2bde76 100644 --- a/src/test/less/formatter.test.ts +++ b/src/test/less/formatter.test.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import { suite, test } from 'node:test'; -import { getLESSLanguageService } from '../../cssLanguageService'; -import { assertFormat } from '../css/formatter.test'; +import { getLESSLanguageService } from '../../cssLanguageService.js'; +import { assertFormat } from '../css/formatter.test.js'; suite('LESS - Formatter', () => { diff --git a/src/test/less/lessCompletion.test.ts b/src/test/less/lessCompletion.test.ts index a0b8b252..fc3fe7ba 100644 --- a/src/test/less/lessCompletion.test.ts +++ b/src/test/less/lessCompletion.test.ts @@ -5,9 +5,9 @@ 'use strict'; import { suite, test } from 'node:test'; -import { testCompletionFor as testCSSCompletionFor, ExpectedCompetions } from '../css/completion.test'; -import { LanguageSettings } from '../../cssLanguageService'; -import { newRange } from '../css/navigation.test'; +import { testCompletionFor as testCSSCompletionFor, ExpectedCompetions } from '../css/completion.test.js'; +import { LanguageSettings } from '../../cssLanguageService.js'; +import { newRange } from '../css/navigation.test.js'; function testCompletionFor( value: string, diff --git a/src/test/less/lessNavigation.test.ts b/src/test/less/lessNavigation.test.ts index e7fff379..a81a1180 100644 --- a/src/test/less/lessNavigation.test.ts +++ b/src/test/less/lessNavigation.test.ts @@ -5,10 +5,10 @@ 'use strict'; import { suite, test } from 'node:test'; -import * as nodes from '../../parser/cssNodes'; -import { assertScopeBuilding, assertSymbolsInScope, assertScopesAndSymbols, assertHighlights, assertSymbolInfos, newRange, assertColorSymbols, assertDocumentSymbols } from '../css/navigation.test'; -import { getLESSLanguageService, SymbolKind, Location } from '../../cssLanguageService'; -import { colorFrom256RGB } from '../../languageFacts/facts'; +import * as nodes from '../../parser/cssNodes.js'; +import { assertScopeBuilding, assertSymbolsInScope, assertScopesAndSymbols, assertHighlights, assertSymbolInfos, newRange, assertColorSymbols, assertDocumentSymbols } from '../css/navigation.test.js'; +import { getLESSLanguageService, SymbolKind, Location } from '../../cssLanguageService.js'; +import { colorFrom256RGB } from '../../languageFacts/facts.js'; suite('LESS - Symbols', () => { diff --git a/src/test/less/lint.test.ts b/src/test/less/lint.test.ts index fcbe71ea..253f9aa1 100644 --- a/src/test/less/lint.test.ts +++ b/src/test/less/lint.test.ts @@ -5,10 +5,10 @@ 'use strict'; import { suite, test } from 'node:test'; -import { Rule } from '../../services/lintRules'; -import { assertEntries } from '../css/lint.test'; -import { SCSSParser } from '../../parser/scssParser'; -import { TextDocument } from '../../cssLanguageTypes'; +import { Rule } from '../../services/lintRules.js'; +import { assertEntries } from '../css/lint.test.js'; +import { SCSSParser } from '../../parser/scssParser.js'; +import { TextDocument } from '../../cssLanguageTypes.js'; function assertRuleSet(input: string, ...rules: Rule[]): void { let p = new SCSSParser(); diff --git a/src/test/less/nodes.test.ts b/src/test/less/nodes.test.ts index 02e3f865..d079979a 100644 --- a/src/test/less/nodes.test.ts +++ b/src/test/less/nodes.test.ts @@ -5,9 +5,9 @@ 'use strict'; import { suite, test } from 'node:test'; -import { assertNodes } from '../css/nodes.test'; -import * as nodes from '../../parser/cssNodes'; -import { LESSParser } from '../../parser/lessParser'; +import { assertNodes } from '../css/nodes.test.js'; +import * as nodes from '../../parser/cssNodes.js'; +import { LESSParser } from '../../parser/lessParser.js'; suite('LESS - Nodes', () => { diff --git a/src/test/less/parser.test.ts b/src/test/less/parser.test.ts index 34d28364..417e7ebc 100644 --- a/src/test/less/parser.test.ts +++ b/src/test/less/parser.test.ts @@ -5,10 +5,10 @@ 'use strict'; import { suite, test } from 'node:test'; -import { ParseError } from '../../parser/cssErrors'; -import { LESSParser } from '../../parser/lessParser'; +import { ParseError } from '../../parser/cssErrors.js'; +import { LESSParser } from '../../parser/lessParser.js'; -import { assertNode, assertNoNode, assertError } from '../css/parser.test'; +import { assertNode, assertNoNode, assertError } from '../css/parser.test.js'; suite('LESS - Parser', () => { diff --git a/src/test/less/scanner.test.ts b/src/test/less/scanner.test.ts index a742b4d5..d7d24119 100644 --- a/src/test/less/scanner.test.ts +++ b/src/test/less/scanner.test.ts @@ -7,8 +7,8 @@ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import { TokenType } from '../../parser/cssScanner'; -import { LESSScanner } from '../../parser/lessScanner'; +import { TokenType } from '../../parser/cssScanner.js'; +import { LESSScanner } from '../../parser/lessScanner.js'; function assertSingleToken(source: string, len: number, offset: number, text: string, type: TokenType): void { let scan = new LESSScanner(); diff --git a/src/test/scss/formatter.test.ts b/src/test/scss/formatter.test.ts index 4f424391..0896558c 100644 --- a/src/test/scss/formatter.test.ts +++ b/src/test/scss/formatter.test.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import { suite, test } from 'node:test'; -import { getSCSSLanguageService } from '../../cssLanguageService'; -import { assertFormat } from '../css/formatter.test'; +import { getSCSSLanguageService } from '../../cssLanguageService.js'; +import { assertFormat } from '../css/formatter.test.js'; suite('SCSS - Formatter', () => { diff --git a/src/test/scss/languageFacts.test.ts b/src/test/scss/languageFacts.test.ts index 40ad94ea..15dde905 100644 --- a/src/test/scss/languageFacts.test.ts +++ b/src/test/scss/languageFacts.test.ts @@ -5,9 +5,9 @@ 'use strict'; import { suite, test } from 'node:test'; -import { SCSSParser } from '../../parser/scssParser'; -import { assertColor } from '../css/languageFacts.test'; -import { colorFrom256RGB as newColor } from '../../languageFacts/facts'; +import { SCSSParser } from '../../parser/scssParser.js'; +import { assertColor } from '../css/languageFacts.test.js'; +import { colorFrom256RGB as newColor } from '../../languageFacts/facts.js'; suite('SCSS - Language facts', () => { diff --git a/src/test/scss/lint.test.ts b/src/test/scss/lint.test.ts index e6edb2e1..497e48a2 100644 --- a/src/test/scss/lint.test.ts +++ b/src/test/scss/lint.test.ts @@ -5,10 +5,10 @@ 'use strict'; import { suite, test } from 'node:test'; -import { TextDocument } from '../../cssLanguageTypes'; -import { SCSSParser } from '../../parser/scssParser'; -import { Rule, Rules } from '../../services/lintRules'; -import { assertEntries } from '../css/lint.test'; +import { TextDocument } from '../../cssLanguageTypes.js'; +import { SCSSParser } from '../../parser/scssParser.js'; +import { Rule, Rules } from '../../services/lintRules.js'; +import { assertEntries } from '../css/lint.test.js'; function assertFontFace(input: string, ...rules: Rule[]): void { let p = new SCSSParser(); diff --git a/src/test/scss/parser.test.ts b/src/test/scss/parser.test.ts index 669547f0..9e73f9ba 100644 --- a/src/test/scss/parser.test.ts +++ b/src/test/scss/parser.test.ts @@ -6,11 +6,11 @@ 'use strict'; import { suite, test } from 'node:test'; -import { SCSSParser } from '../../parser/scssParser'; -import { ParseError } from '../../parser/cssErrors'; -import { SCSSParseError } from '../../parser/scssErrors'; +import { SCSSParser } from '../../parser/scssParser.js'; +import { ParseError } from '../../parser/cssErrors.js'; +import { SCSSParseError } from '../../parser/scssErrors.js'; -import { assertNode, assertError } from '../css/parser.test'; +import { assertNode, assertError } from '../css/parser.test.js'; suite('SCSS - Parser', () => { diff --git a/src/test/scss/scssCompletion.test.ts b/src/test/scss/scssCompletion.test.ts index 9def2dfb..4b3e03df 100644 --- a/src/test/scss/scssCompletion.test.ts +++ b/src/test/scss/scssCompletion.test.ts @@ -6,12 +6,15 @@ import { suite, test } from 'node:test'; import * as path from 'path'; +import { fileURLToPath } from 'node:url'; -import { Position, InsertTextFormat, CompletionItemKind, LanguageSettings } from '../../cssLanguageService'; -import { testCompletionFor as testCSSCompletionFor, ExpectedCompetions } from '../css/completion.test'; -import { newRange } from '../css/navigation.test'; +import { Position, InsertTextFormat, CompletionItemKind, LanguageSettings } from '../../cssLanguageService.js'; +import { testCompletionFor as testCSSCompletionFor, ExpectedCompetions } from '../css/completion.test.js'; +import { newRange } from '../css/navigation.test.js'; import { URI } from 'vscode-uri'; +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + function testCompletionFor( value: string, expected: ExpectedCompetions, diff --git a/src/test/scss/scssNavigation.test.ts b/src/test/scss/scssNavigation.test.ts index aff95a3a..1b52f988 100644 --- a/src/test/scss/scssNavigation.test.ts +++ b/src/test/scss/scssNavigation.test.ts @@ -4,15 +4,18 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as nodes from '../../parser/cssNodes'; -import { assertSymbolsInScope, assertScopesAndSymbols, assertHighlights, assertColorSymbols, assertLinks, newRange, getTestResource, assertDocumentSymbols } from '../css/navigation.test'; -import { getSCSSLanguageService, DocumentLink, TextDocument, SymbolKind, LanguageSettings } from '../../cssLanguageService'; +import * as nodes from '../../parser/cssNodes.js'; +import { assertSymbolsInScope, assertScopesAndSymbols, assertHighlights, assertColorSymbols, assertLinks, newRange, getTestResource, assertDocumentSymbols } from '../css/navigation.test.js'; +import { getSCSSLanguageService, DocumentLink, TextDocument, SymbolKind, LanguageSettings } from '../../cssLanguageService.js'; import { suite, test } from 'node:test'; import * as assert from 'node:assert'; import * as path from 'path'; +import { fileURLToPath } from 'node:url'; import { URI } from 'vscode-uri'; -import { getFsProvider } from '../testUtil/fsProvider'; -import { getDocumentContext } from '../testUtil/documentContext'; +import { getFsProvider } from '../testUtil/fsProvider.js'; +import { getDocumentContext } from '../testUtil/documentContext.js'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); function getSCSSLS() { return getSCSSLanguageService({ fileSystemProvider: getFsProvider() }); diff --git a/src/test/scss/selectorPrinting.test.ts b/src/test/scss/selectorPrinting.test.ts index 8abeb415..df56122f 100644 --- a/src/test/scss/selectorPrinting.test.ts +++ b/src/test/scss/selectorPrinting.test.ts @@ -6,8 +6,8 @@ 'use strict'; import { suite, test } from 'node:test'; -import { SCSSParser } from '../../parser/scssParser'; -import { assertSelector } from '../css/selectorPrinting.test'; +import { SCSSParser } from '../../parser/scssParser.js'; +import { assertSelector } from '../css/selectorPrinting.test.js'; suite('SCSS - Selector Printing', () => { diff --git a/src/test/testUtil/documentContext.ts b/src/test/testUtil/documentContext.ts index 42df3933..639ea44d 100644 --- a/src/test/testUtil/documentContext.ts +++ b/src/test/testUtil/documentContext.ts @@ -5,9 +5,9 @@ import * as url from 'url'; -import { DocumentContext } from '../../cssLanguageTypes'; -import { startsWith } from '../../utils/strings'; -import { joinPath } from '../../utils/resources'; +import { DocumentContext } from '../../cssLanguageTypes.js'; +import { startsWith } from '../../utils/strings.js'; +import { joinPath } from '../../utils/resources.js'; export function getDocumentContext(workspaceFolder?: string): DocumentContext { return { diff --git a/src/test/testUtil/fsProvider.ts b/src/test/testUtil/fsProvider.ts index d3b300b8..16323df9 100644 --- a/src/test/testUtil/fsProvider.ts +++ b/src/test/testUtil/fsProvider.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { FileSystemProvider, FileType } from "../../cssLanguageTypes"; +import { FileSystemProvider, FileType } from "../../cssLanguageTypes.js"; import { URI } from 'vscode-uri'; import { promises as fs } from 'fs'; diff --git a/src/test/util.test.ts b/src/test/util.test.ts index 565b5f59..bebb9f87 100644 --- a/src/test/util.test.ts +++ b/src/test/util.test.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { suite, test } from 'node:test'; import * as assert from 'node:assert'; -import { trim } from '../utils/strings'; +import { trim } from '../utils/strings.js'; suite('Util', () => { diff --git a/src/tsconfig.esm.json b/src/tsconfig.esm.json deleted file mode 100644 index ac181667..00000000 --- a/src/tsconfig.esm.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "es6", - "outDir": "../lib/esm" - } -} diff --git a/src/tsconfig.json b/src/tsconfig.json index 31425e6f..2432c2cb 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -1,13 +1,14 @@ { "compilerOptions": { "target": "es2020", - "module": "umd", - "moduleResolution": "node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "sourceMap": true, "declaration": true, "strict": true, "stripInternal": true, - "outDir": "../lib/umd", + "allowJs": true, + "outDir": "../lib/esm", "lib": [ "es2020" ]