littoral-templates 0.4.2-alpha.0 → 0.5.0-beta.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/CHANGELOG.md +9 -2
- package/README.md +1 -1
- package/dist/eol.d.ts +0 -4
- package/dist/eol.d.ts.map +1 -1
- package/dist/eol.js +0 -71
- package/dist/eol.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +18 -31
- package/.eslintrc.cjs +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 0.5.0 [not yet released]
|
|
4
|
+
|
|
5
|
+
* Separated out `setEOLStyleFromOS` to a separate package `littoral-templates-node`.
|
|
6
|
+
* Expose the `setEOLExplicitly` function.
|
|
7
|
+
|
|
8
|
+
|
|
3
9
|
## 0.4.2
|
|
4
10
|
|
|
5
|
-
* Synchronous style of `setEOLStyleFromOS` caused problems with bundlers — in particular: Vite.
|
|
6
|
-
That function is now
|
|
11
|
+
* Synchronous style of `setEOLStyleFromOS` caused problems with web bundlers — in particular: Vite’s.
|
|
12
|
+
That function is now asynchronous again, so should typically be `await`ed.
|
|
13
|
+
It also should give warnings on the console when `setEOLStyleFromOS` is called when running in a browser.
|
|
7
14
|
|
|
8
15
|
|
|
9
16
|
## 0.4.1
|
package/README.md
CHANGED
|
@@ -170,7 +170,7 @@ EOLs – AKA “newlines” or “line endings” – vary between OS’s: Windo
|
|
|
170
170
|
Not taking that into account can cause content being generated differently across OS’s, potentially confusing tools like Git — especially if these are not configured correctly.
|
|
171
171
|
Since generated content is often large, this causes additional confusion and friction in the software development process.
|
|
172
172
|
|
|
173
|
-
To prevent such issues, you can set the EOL style by calling the `setEOLStyleFromOS` function before any calls to `asString`.
|
|
173
|
+
To prevent such issues, you can set the EOL style by calling the `setEOLStyleFromOS` function (which resides in the separate `littoral-templates-node` package) before any calls to `asString`.
|
|
174
174
|
The default value for the EOL style is `lf` – meaning `\n`.
|
|
175
175
|
I’ll use the notation `<eol>` for the currently-set EOL value throughout the rest of the documentation.
|
|
176
176
|
|
package/dist/eol.d.ts
CHANGED
|
@@ -12,10 +12,6 @@ export declare const eolStyles: {
|
|
|
12
12
|
* The value of the EOL string: typically, either "\n" (=LF-style, compatible with POSIX/Linux/macOS), or "\r\n" (=CRLF-style, compatible with Windows).
|
|
13
13
|
*/
|
|
14
14
|
export declare let eol: string;
|
|
15
|
-
/**
|
|
16
|
-
* Sets the EOL to the OS-dependent value.
|
|
17
|
-
*/
|
|
18
|
-
export declare const setEOLStyleFromOS: () => Promise<void>;
|
|
19
15
|
/**
|
|
20
16
|
* Sets the EOL explicitly to the given value.
|
|
21
17
|
* (This is especially useful for testing.)
|
package/dist/eol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eol.d.ts","sourceRoot":"","sources":["../src/eol.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;;;CAGZ,CAAA;AAGV;;GAEG;AACH,eAAO,IAAI,GAAG,EAAE,MAAqB,CAAA;AAGrC
|
|
1
|
+
{"version":3,"file":"eol.d.ts","sourceRoot":"","sources":["../src/eol.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;;;CAGZ,CAAA;AAGV;;GAEG;AACH,eAAO,IAAI,GAAG,EAAE,MAAqB,CAAA;AAGrC;;;GAGG;AACH,eAAO,MAAM,gBAAgB,WAAY,MAAM,SAE9C,CAAA;AAKD;;;GAGG;AACH,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,MAAM,EACtB,CAAA"}
|
package/dist/eol.js
CHANGED
|
@@ -1,42 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* EOL-related constants and functions.
|
|
3
3
|
*/
|
|
4
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
14
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
15
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
16
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
17
|
-
function step(op) {
|
|
18
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
19
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
20
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
21
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
22
|
-
switch (op[0]) {
|
|
23
|
-
case 0: case 1: t = op; break;
|
|
24
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
25
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
26
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
27
|
-
default:
|
|
28
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
29
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
30
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
31
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
32
|
-
if (t[2]) _.ops.pop();
|
|
33
|
-
_.trys.pop(); continue;
|
|
34
|
-
}
|
|
35
|
-
op = body.call(thisArg, _);
|
|
36
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
37
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
4
|
/**
|
|
41
5
|
* Common EOL styles.
|
|
42
6
|
*/
|
|
@@ -48,41 +12,6 @@ export var eolStyles = {
|
|
|
48
12
|
* The value of the EOL string: typically, either "\n" (=LF-style, compatible with POSIX/Linux/macOS), or "\r\n" (=CRLF-style, compatible with Windows).
|
|
49
13
|
*/
|
|
50
14
|
export var eol = eolStyles.lf;
|
|
51
|
-
/**
|
|
52
|
-
* Sets the EOL to the OS-dependent value.
|
|
53
|
-
*/
|
|
54
|
-
export var setEOLStyleFromOS = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
|
-
var printWarningOnConsole;
|
|
56
|
-
return __generator(this, function (_a) {
|
|
57
|
-
switch (_a.label) {
|
|
58
|
-
case 0:
|
|
59
|
-
printWarningOnConsole = function () {
|
|
60
|
-
console.error("The \"os\" package was not available for import, so couldn't set EOL from OS \u2014 previous value is kept. Are you executing this in the browser, by any chance?");
|
|
61
|
-
};
|
|
62
|
-
return [4 /*yield*/, import("os")
|
|
63
|
-
.then(function (osPackage) {
|
|
64
|
-
if (osPackage) {
|
|
65
|
-
eol = osPackage.EOL;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
printWarningOnConsole();
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
.catch(function (reason) {
|
|
72
|
-
if (reason instanceof TypeError && reason.message.indexOf("'os'") > -1) {
|
|
73
|
-
printWarningOnConsole();
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
console.error("Couldn't set EOL from OS after trying to import \"os\" package dynamically. Reason:");
|
|
77
|
-
console.dir(reason);
|
|
78
|
-
}
|
|
79
|
-
})];
|
|
80
|
-
case 1:
|
|
81
|
-
_a.sent();
|
|
82
|
-
return [2 /*return*/];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}); };
|
|
86
15
|
/**
|
|
87
16
|
* Sets the EOL explicitly to the given value.
|
|
88
17
|
* (This is especially useful for testing.)
|
package/dist/eol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eol.js","sourceRoot":"","sources":["../src/eol.ts"],"names":[],"mappings":"AAAA;;GAEG
|
|
1
|
+
{"version":3,"file":"eol.js","sourceRoot":"","sources":["../src/eol.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAC,IAAM,SAAS,GAAG;IACrB,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,MAAM;CACN,CAAA;AAGV;;GAEG;AACH,MAAM,CAAC,IAAI,GAAG,GAAW,SAAS,CAAC,EAAE,CAAA;AAGrC;;;GAGG;AACH,MAAM,CAAC,IAAM,gBAAgB,GAAG,UAAC,MAAc;IAC3C,GAAG,GAAG,MAAM,CAAA;AAChB,CAAC,CAAA;AAGD,IAAM,UAAU,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAA;AAEtC;;;GAGG;AACH,MAAM,CAAC,IAAM,UAAU,GAAG,UAAC,GAAW;IAClC,OAAA,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC;AAArB,CAAqB,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { asString, commaSeparated, commonIndentations, indentWith,
|
|
1
|
+
export { asString, commaSeparated, commonIndentations, indentWith, setEOLExplicitly, when, withEmptyLineAppended, withNewlineAppended } from "./index-internal.js";
|
|
2
2
|
export type { Template, NestedString } from "./index-internal.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,IAAI,EACJ,qBAAqB,EACrB,mBAAmB,EACtB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACR,QAAQ,EACR,YAAY,EACf,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { asString, commaSeparated, commonIndentations, indentWith,
|
|
1
|
+
export { asString, commaSeparated, commonIndentations, indentWith, setEOLExplicitly, when, withEmptyLineAppended, withNewlineAppended // (legacy alias)
|
|
2
2
|
} from "./index-internal.js";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,IAAI,EACJ,qBAAqB,EACrB,mBAAmB,CAAK,iBAAiB;EAC5C,MAAM,qBAAqB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,48 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "littoral-templates",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A small JavaScript/TypeScript framework to do templating comfortably using the template literal syntax in either JavaScript or TypeScript
|
|
3
|
+
"version": "0.5.0-beta.0",
|
|
4
|
+
"description": "A small JavaScript/TypeScript framework to do templating comfortably using the template literal syntax in either JavaScript or TypeScript",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Meinte Boersma",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"template",
|
|
9
|
+
"engine"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/dslmeinte/littoral-templates.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/dslmeinte/littoral-templates/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/dslmeinte/littoral-templates#readme",
|
|
5
19
|
"type": "module",
|
|
6
20
|
"main": "dist/index.js",
|
|
7
21
|
"types": "dist/index.d.ts",
|
|
8
22
|
"scripts": {
|
|
23
|
+
"clean": "rm -rf dist node_modules",
|
|
9
24
|
"build": "tsc",
|
|
10
25
|
"watch-build": "tsc --watch",
|
|
11
|
-
"clean": "rm -rf dist node_modules",
|
|
12
|
-
"pretest": "npm run build",
|
|
13
|
-
"test": "mocha dist/test/*.js",
|
|
14
|
-
"watch-test": "mocha --watch dist/test/*.js",
|
|
15
26
|
"lint": "eslint src",
|
|
16
|
-
"prep:pre-release": "npm run clean && npm install && npm
|
|
27
|
+
"prep:pre-release": "npm run clean && npm install && npm run build",
|
|
17
28
|
"prerelease": "npm run prep:pre-release",
|
|
18
29
|
"release": "npm publish",
|
|
19
30
|
"prerelease-alpha": "npm run prep:pre-release",
|
|
20
31
|
"release-alpha": "npm publish --tag beta",
|
|
21
32
|
"prerelease-beta": "npm run prep:pre-release",
|
|
22
33
|
"release-beta": "npm publish --tag beta"
|
|
23
|
-
},
|
|
24
|
-
"repository": {
|
|
25
|
-
"type": "git",
|
|
26
|
-
"url": "git+https://github.com/dslmeinte/littoral-templates.git"
|
|
27
|
-
},
|
|
28
|
-
"keywords": [
|
|
29
|
-
"template",
|
|
30
|
-
"engine"
|
|
31
|
-
],
|
|
32
|
-
"author": "Meinte Boersma",
|
|
33
|
-
"license": "MIT",
|
|
34
|
-
"bugs": {
|
|
35
|
-
"url": "https://github.com/dslmeinte/littoral-templates/issues"
|
|
36
|
-
},
|
|
37
|
-
"homepage": "https://github.com/dslmeinte/littoral-templates#readme",
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"@types/chai": "5.2.2",
|
|
40
|
-
"@types/mocha": "10.0.10",
|
|
41
|
-
"@types/node": "18.19.112",
|
|
42
|
-
"@typescript-eslint/eslint-plugin": "6.21.0",
|
|
43
|
-
"@typescript-eslint/parser": "6.21.0",
|
|
44
|
-
"chai": "5.2.0",
|
|
45
|
-
"mocha": "10.8.2",
|
|
46
|
-
"typescript": "5.3.3"
|
|
47
34
|
}
|
|
48
35
|
}
|
package/.eslintrc.cjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/* eslint-env node */
|
|
2
|
-
module.exports = {
|
|
3
|
-
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
|
4
|
-
parser: "@typescript-eslint/parser",
|
|
5
|
-
plugins: ["@typescript-eslint"],
|
|
6
|
-
root: true,
|
|
7
|
-
rules: {
|
|
8
|
-
"@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "^_"}],
|
|
9
|
-
"@typescript-eslint/ban-ts-ignore": "off",
|
|
10
|
-
"@typescript-eslint/prefer-spread": ["off"]
|
|
11
|
-
},
|
|
12
|
-
env: {
|
|
13
|
-
browser: true,
|
|
14
|
-
node: true
|
|
15
|
-
}}
|