@nsis/dent 0.4.0 → 0.4.2
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 +3 -0
- package/dist/{dent.d.ts → dent.d.mts} +3 -2
- package/dist/dent.mjs +5 -0
- package/package.json +49 -59
- package/types/index.d.ts +1 -1
- package/dist/dent.js +0 -10
package/README.md
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
[](https://www.npmjs.org/package/@nsis/dent)
|
|
7
7
|
[](https://github.com/idleberg/node-dent/actions)
|
|
8
8
|
|
|
9
|
+
> [!NOTE]
|
|
10
|
+
> This is the repository for the formatting library. Chances are you are looking for the [CLI tool](https://www.npmjs.com/package/@nsis/dent-cli) instead.
|
|
11
|
+
|
|
9
12
|
## Installation
|
|
10
13
|
|
|
11
14
|
`npm install @nsis/dent`
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/dent.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Formats the given file contents using the Dent formatting style.
|
|
3
4
|
*
|
|
@@ -6,5 +7,5 @@
|
|
|
6
7
|
* @throws {Error} Throws an error if the options are invalid.
|
|
7
8
|
*/
|
|
8
9
|
declare function createFormatter(options?: NsisDent.Options): (fileContents: string) => string;
|
|
9
|
-
|
|
10
|
-
export { createFormatter };
|
|
10
|
+
//#endregion
|
|
11
|
+
export { createFormatter };
|
package/dist/dent.mjs
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{platform as e}from"node:os";import{detectNewline as t}from"detect-newline";const n={indenters:"!if.!ifdef.!ifmacrodef.!ifmacrondef.!ifndef.!macro.${Case}.${Case2}.${Case3}.${Case4}.${Case5}.${CaseElse}.${Default}.${Do}.${DoUntil}.${DoWhile}.${For}.${ForEach}.${If}.${IfNot}.${MementoSection}.${MementoUnselectedSection}.${Select}.${Switch}.${Unless}.Function.PageEx.Section.SectionGroup".split(`.`).map(e=>e.toLowerCase()),dedenters:[`!endif`,`!macroend`,"${EndIf}","${EndSelect}","${EndSwitch}","${EndWhile}","${Loop}","${LoopUntil}","${LoopWhile}","${MementoSectionEnd}","${Next}","${While}",`FunctionEnd`,`PageExEnd`,`SectionEnd`,`SectionGroupEnd`].map(e=>e.toLowerCase()),specialIndenters:[`!else`,`!elseif`,"${Else}","${ElseIf}","${ElseIfNot}","${ElseUnless}","${AndIf}","${AndIfNot}","${AndUnless}","${OrIf}","${OrIfNot}","${OrUnless}"].map(e=>e.toLowerCase()),specialDedenters:["${Break}"].map(e=>e.toLowerCase())};function r(r={}){let i={indentSize:2,trimEmptyLines:!0,useTabs:!0,...r};if(i.useTabs===!1&&(!i.indentSize||Number.isNaN(i.indentSize)||i.indentSize<=0))throw Error(`The indentSize option expects a positive integer`);function a(e){let t=0,r=0,a=s(e),l=c(e),u=[];return(i.trimEmptyLines===!0?e.trim().replaceAll(/^(\s*\r?\n){2,}/gm,a).split(a):e.split(a)).forEach(e=>{let i=e.trim().split(` `).at(0)??``;switch(i.toLowerCase()==="${switch}"&&(r=t),!0){case i.toLowerCase()==="${endswitch}":t=r,u.push(o(e,t));break;case n.specialIndenters.includes(i.toLowerCase()):u.push(o(e,t-1));break;case n.specialDedenters.includes(i.toLowerCase()):u.push(o(e,t)),t=t===0?0:t-1;break;case n.indenters.includes(i.toLowerCase()):u.push(o(e,t)),t++;break;case n.dedenters.includes(i.toLowerCase()):t=t===0?0:t-1,u.push(o(e,t));break;default:u.push(o(e,t));break}}),u.join(l)+l}function o(e,t){return e.length?`${l(t)}${e.trim()}`:``}function s(n){let r=t(n);return r===void 0?e()===`win32`?`\r
|
|
2
|
+
`:`
|
|
3
|
+
`:r}function c(e){return i.endOfLines?i.endOfLines===`crlf`?`\r
|
|
4
|
+
`:`
|
|
5
|
+
`:s(e)}function l(e){return(i.useTabs?` `:` `.repeat(i.indentSize||2)).repeat(e)}return a}export{r as createFormatter};
|
package/package.json
CHANGED
|
@@ -1,60 +1,50 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"tslib": "^2.6.2",
|
|
52
|
-
"tsm": "^2.3.0",
|
|
53
|
-
"tsup": "^8.0.1",
|
|
54
|
-
"typescript": "^5.3.3",
|
|
55
|
-
"uvu": "^0.5.6"
|
|
56
|
-
},
|
|
57
|
-
"lint-staged": {
|
|
58
|
-
"*.(json|ts)": "eslint --cache --fix"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
2
|
+
"name": "@nsis/dent",
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"description": "An opinionated code formatter for NSIS scripts",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/",
|
|
8
|
+
"types/",
|
|
9
|
+
"LICENSE",
|
|
10
|
+
"package.json",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"typings": "dist/dent.d.mts",
|
|
15
|
+
"exports": "./dist/dent.mjs",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18.0.0"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/idleberg/node-dent.git"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"nsis",
|
|
25
|
+
"formatter"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"detect-newline": "^4.0.1"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@idleberg/configs": "^0.4.2",
|
|
32
|
+
"@types/node": "^24.11.0",
|
|
33
|
+
"concurrently": "^9.2.1",
|
|
34
|
+
"np": "^11.0.2",
|
|
35
|
+
"tsdown": "^0.20.3",
|
|
36
|
+
"tsm": "^2.3.0",
|
|
37
|
+
"typescript": "^5.3.3",
|
|
38
|
+
"uvu": "^0.5.6"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsdown",
|
|
42
|
+
"dev": "tsdown --watch",
|
|
43
|
+
"lint": "concurrently --prefix-colors blue,green,magenta npm:lint:*",
|
|
44
|
+
"lint:biome": "biome check",
|
|
45
|
+
"lint:e18e": "e18e-cli analyze",
|
|
46
|
+
"publish:jsr": "deno publish",
|
|
47
|
+
"publish:npm": "np",
|
|
48
|
+
"test": "uvu -r tsm tests"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/types/index.d.ts
CHANGED
package/dist/dent.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { detectNewline } from 'detect-newline';
|
|
2
|
-
import { platform } from 'node:os';
|
|
3
|
-
|
|
4
|
-
var d={indenters:["!if","!ifdef","!ifmacrodef","!ifmacrondef","!ifndef","!macro","${Case}","${Case2}","${Case3}","${Case4}","${Case5}","${CaseElse}","${Default}","${Do}","${DoUntil}","${DoWhile}","${For}","${ForEach}","${If}","${IfNot}","${MementoSection}","${MementoUnselectedSection}","${Select}","${Switch}","${Unless}","Function","PageEx","Section","SectionGroup"].map(s=>s.toLowerCase()),dedenters:["!endif","!macroend","${EndIf}","${EndSelect}","${EndSwitch}","${EndWhile}","${Loop}","${LoopUntil}","${LoopWhile}","${MementoSectionEnd}","${Next}","${While}","FunctionEnd","PageExEnd","SectionEnd","SectionGroupEnd"].map(s=>s.toLowerCase()),specialIndenters:["!else","!elseif","${Else}","${ElseIf}","${ElseIfNot}","${ElseUnless}","${AndIf}","${AndIfNot}","${AndUnless}","${OrIf}","${OrIfNot}","${OrUnless}"].map(s=>s.toLowerCase()),specialDedenters:["${Break}"].map(s=>s.toLowerCase())};var f=2;function C(s={}){let n={endOfLines:platform()==="win32"?"crlf":"lf",indentSize:f,trimEmptyLines:!0,useTabs:!0,...s};if(n.useTabs===!1&&n.indentSize&&(isNaN(n.indentSize)||n.indentSize<=0))throw Error("The indentSize option expects a positive integer");function p(t){let e=0,l=0,c=u(t),i=[];return (n.trimEmptyLines===!0?t.trim().replaceAll(/^(\s*\r?\n){2,}/gm,c).split(c):t.split(c)).forEach(r=>{let a=r.trim().split(" ").at(0)??"";switch(a.toLowerCase()==="${Switch}"&&(l=e),!0){case a.toLowerCase()==="${EndSwitch}":e=l,i.push(o(r,e)),e=e===0?0:e-1;break;case d.specialIndenters.includes(a.toLowerCase()):i.push(o(r,e-1));break;case d.specialDedenters.includes(a.toLowerCase()):i.push(o(r,e)),e--;break;case d.indenters.includes(a.toLowerCase()):i.push(o(r,e)),e++;break;case d.dedenters.includes(a.toLowerCase()):e=e===0?0:e-1,i.push(o(r,e));break;default:i.push(o(r,e));break}}),i.join(c)}function o(t,e){return t.length?`${m(e)}${t.trim()}`:""}function u(t){if(n.endOfLines)return n.endOfLines==="crlf"?`\r
|
|
5
|
-
`:`
|
|
6
|
-
`;let e=detectNewline(t);return e!==void 0?e:platform()==="win32"?`\r
|
|
7
|
-
`:`
|
|
8
|
-
`}function m(t){return (n.useTabs?" ".repeat(n.indentSize||f):" ".repeat(n.indentSize||f)).repeat(t)}return p}
|
|
9
|
-
|
|
10
|
-
export { C as createFormatter };
|