Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"request": "attach",
"port": 6004,
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/lib/umd/**"]
"outFiles": ["${workspaceRoot}/lib/esm/**"]
},
{
"name": "Unit Tests",
Expand All @@ -18,11 +18,11 @@
"--test"
],
"args": [
"./lib/umd/test/*.js"
"./lib/esm/test/*.js"
],
"cwd": "${workspaceRoot}",
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/lib/umd/**"],
"outFiles": ["${workspaceRoot}/lib/esm/**"],
"preLaunchTask": "npm: compile"
}
]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ License

Copyright 2016-2023, Microsoft

`src/languageFacts/data/webCustomData.ts` (shipped as `lib/esm/languageFacts/data/webCustomData.ts` and `lib/umd/languageFacts/data/webCustomData.ts`)
`src/languageFacts/data/webCustomData.ts` (shipped as `lib/esm/languageFacts/data/webCustomData.ts`)
are built upon content from [Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web) and distributed under CC BY-SA 2.5.
23 changes: 0 additions & 23 deletions build/copy-jsbeautify.js

This file was deleted.

16 changes: 10 additions & 6 deletions build/generateData.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
* 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 path from 'node:path';
import os from 'node:os';
import { createRequire } from 'node:module';
import { fileURLToPath } from 'node:url';

const require = createRequire(import.meta.url);
const customData = require('@vscode/web-custom-data/data/browsers.html-data.json');
const __dirname = path.dirname(fileURLToPath(import.meta.url));

function toJavaScript(obj) {
return JSON.stringify(obj, null, '\t');
Expand All @@ -21,13 +25,13 @@ const output = [
' *--------------------------------------------------------------------------------------------*/',
'// file generated from @vscode/web-custom-data NPM package',
'',
`import { ${DATA_TYPE} } from '../../htmlLanguageTypes';`,
`import { ${DATA_TYPE} } from '../../htmlLanguageTypes.js';`,
'',
`export const htmlData : ${DATA_TYPE} = ` + toJavaScript(customData) + ';'
];

var outputPath = path.resolve(__dirname, '../src/languageFacts/data/webCustomData.ts');
const outputPath = path.resolve(__dirname, '../src/languageFacts/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');
7 changes: 5 additions & 2 deletions build/remove-sourcemap-refs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 12 additions & 13 deletions build/update-jsbeautify.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

'use strict';
import path from 'node:path';
import fs from 'node:fs';
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');
const 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);
return null;
}
});
}

function readFile(path) {
function readFile(filePath) {
return new Promise((s, e) => {
fs.readFile(path, (err, res) => {
fs.readFile(filePath, (err, res) => {
if (err) {
e(err);
} else {
Expand All @@ -33,7 +34,7 @@ function readFile(path) {
}

function update(moduleName, repoPath, dest, addHeader, patch) {
var contentPath = path.join(__dirname, '..', 'node_modules', moduleName, repoPath);
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) {
Expand Down Expand Up @@ -62,12 +63,10 @@ function update(moduleName, repoPath, dest, addHeader, patch) {
}, console.error);
}

update('js-beautify', 'js/lib/beautify-html.js', './src/beautify/beautify-html.js', true);
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-html.js', './src/beautify/esm/beautify-html.js', true, function (contents) {
update('js-beautify', 'js/lib/beautify-html.js', './src/beautify/beautify-html.js', true, function (contents) {
let topLevelFunction = '(function() {';
let outputVar = 'var legacy_beautify_html';
let footer = 'var style_html = legacy_beautify_html;';
Expand All @@ -84,14 +83,14 @@ update('js-beautify', 'js/lib/beautify-html.js', './src/beautify/esm/beautify-ht
throw new Error(`Problem patching beautify.html for ESM: '${footer}' not found after '${outputVar}'.`);
}
return contents.substring(0, index1) +
`import { js_beautify } from "./beautify";\nimport { css_beautify } from "./beautify-css";\n\n`
`import { js_beautify } from "./beautify.js";\nimport { css_beautify } from "./beautify-css.js";\n\n`
+ contents.substring(index2, index3) +
`
export function html_beautify(html_source, options) {
return legacy_beautify_html(html_source, options, js_beautify, css_beautify);
}`;
});
update('js-beautify', 'js/lib/beautify-css.js', './src/beautify/esm/beautify-css.js', true, function (contents) {
update('js-beautify', 'js/lib/beautify-css.js', './src/beautify/beautify-css.js', true, function (contents) {
let topLevelFunction = '(function() {';
let outputVar = 'var legacy_beautify_css';
let footer = 'var css_beautify = legacy_beautify_css;';
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "vscode-html-languageservice",
"version": "5.6.2",
"version": "6.0.0-next.1",
"description": "Language service for HTML",
"main": "./lib/umd/htmlLanguageService.js",
"typings": "./lib/umd/htmlLanguageService",
"type": "module",
"main": "./lib/esm/htmlLanguageService.js",
"typings": "./lib/esm/htmlLanguageService",
"module": "./lib/esm/htmlLanguageService.js",
"author": "Microsoft Corporation",
"repository": {
Expand Down Expand Up @@ -31,16 +32,14 @@
"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",
"compile-esm": "tsc -p ./src/tsconfig.esm.json",
"watch": "tsc -w -p ./src && npm run copy-jsbeautify",
"prepack": "npm run clean && npm run compile && npm run test && npm run remove-sourcemap-refs",
"compile": "tsc -p ./src",
"watch": "tsc -w -p ./src",
"clean": "rimraf lib",
"remove-sourcemap-refs": "node ./build/remove-sourcemap-refs.js",
"test": "npm run compile && node --enable-source-maps --test ./lib/umd/test/*.js && npm run lint",
"test": "npm run compile && node --enable-source-maps --test ./lib/esm/test/*.js && npm run lint",
"lint": "eslint src/**/*.ts",
"install-types-next": "npm i vscode-languageserver-types@next -f -S && npm i vscode-languageserver-textdocument@next -f -S",
"copy-jsbeautify": "node ./build/copy-jsbeautify.js",
"update-jsbeautify": "npm i js-beautify && node ./build/update-jsbeautify.js",
"update-jsbeautify-next": "npm i js-beautify@next && node ./build/update-jsbeautify.js",
"update-data": "npm i @vscode/web-custom-data -D && node ./build/generateData.js"
Expand Down
25 changes: 1 addition & 24 deletions src/beautify/beautify-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
42 changes: 5 additions & 37 deletions src/beautify/beautify-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
});
*/

(function() {
import { js_beautify } from "./beautify.js";
import { css_beautify } from "./beautify-css.js";

/* GENERATED_BUILD_OUTPUT */
var legacy_beautify_html;
/******/ (function() { // webpackBootstrap
/******/ "use strict";
Expand Down Expand Up @@ -3206,39 +3206,7 @@ module.exports.TOKEN = TOKEN;
/******/
/******/ })()
;
var style_html = legacy_beautify_html;
/* Footer */
if (typeof define === "function" && define.amd) {
// Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
define(["require", "./beautify", "./beautify-css"], function(requireamd) {
var js_beautify = requireamd("./beautify");
var css_beautify = requireamd("./beautify-css");

return {
html_beautify: function(html_source, options) {
return style_html(html_source, options, js_beautify.js_beautify, 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`.
var js_beautify = require('./beautify.js');
var css_beautify = require('./beautify-css.js');

exports.html_beautify = function(html_source, options) {
return style_html(html_source, options, js_beautify.js_beautify, 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.html_beautify = function(html_source, options) {
return style_html(html_source, options, window.js_beautify, window.css_beautify);
};
} else if (typeof global !== "undefined") {
// If we don't even have window, try global.
global.html_beautify = function(html_source, options) {
return style_html(html_source, options, global.js_beautify, global.css_beautify);
};
}

}());
export function html_beautify(html_source, options) {
return legacy_beautify_html(html_source, options, js_beautify, css_beautify);
}
Loading