volar-service-prettyhtml 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # volar-service-prettyhtml
2
+
3
+ Volar plugin for [PrettyHtml](https://prettyhtml.netlify.app/).
4
+
5
+ ## Usage
6
+
7
+ `package.json`
8
+
9
+ ```json
10
+ {
11
+ "devDependencies": {
12
+ "volar-service-prettyhtml": "latest"
13
+ }
14
+ }
15
+ ```
16
+
17
+ `volar.config.js`
18
+
19
+ ```js
20
+ module.exports = {
21
+ plugins: [
22
+ require('volar-service-prettyhtml').default({ printWidth: 100 }),
23
+ ],
24
+ };
25
+ ```
package/out/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import type { Service } from '@volar/language-service';
2
+ import prettyhtml from '@starptech/prettyhtml';
3
+ declare const _default: (configs: NonNullable<Parameters<typeof prettyhtml>[1]>) => Service;
4
+ export default _default;
package/out/index.js ADDED
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const prettyhtml_1 = __importDefault(require("@starptech/prettyhtml"));
7
+ exports.default = (configs) => () => ({
8
+ provideDocumentFormattingEdits(document, range, options) {
9
+ if (document.languageId !== 'html')
10
+ return;
11
+ const oldRangeText = document.getText(range);
12
+ const newRangeText = (0, prettyhtml_1.default)(oldRangeText, {
13
+ ...configs,
14
+ tabWidth: options.tabSize,
15
+ useTabs: !options.insertSpaces,
16
+ }).contents;
17
+ if (newRangeText === oldRangeText)
18
+ return [];
19
+ const newText = document.getText({
20
+ start: document.positionAt(0),
21
+ end: range.start,
22
+ })
23
+ + newRangeText
24
+ + document.getText({
25
+ start: range.end,
26
+ end: document.positionAt(document.getText().length),
27
+ });
28
+ return [{
29
+ newText,
30
+ range: {
31
+ start: document.positionAt(0),
32
+ end: document.positionAt(document.getText().length),
33
+ },
34
+ }];
35
+ },
36
+ });
37
+ //# sourceMappingURL=index.js.map
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "volar-service-prettyhtml",
3
+ "version": "0.0.0",
4
+ "main": "out/index.js",
5
+ "license": "MIT",
6
+ "files": [
7
+ "out/**/*.js",
8
+ "out/**/*.d.ts"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/volarjs/services.git",
13
+ "directory": "packages/prettyhtml"
14
+ },
15
+ "dependencies": {
16
+ "@starptech/prettyhtml": "^0.10.0"
17
+ },
18
+ "peerDependencies": {
19
+ "@volar/language-service": "*"
20
+ },
21
+ "peerDependenciesMeta": {
22
+ "@volar/language-service": {
23
+ "optional": true
24
+ }
25
+ },
26
+ "gitHead": "1011561ac4bbf79c53c3b80c27692569bf861519"
27
+ }