littoral-templates 0.4.1 → 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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.4.2
4
+
5
+ * Synchronous style of `setEOLStyleFromOS` caused problems with bundlers — in particular: Vite.
6
+ That function is now asynchronous again, so should typically be `await`ed.
7
+ It also should give warnings on the console when `setEOLStyleFromOS` is called when running in a browser.
8
+
9
+
3
10
  ## 0.4.1
4
11
 
5
12
  * The `setEOLStyleFromOS` is now synchronous.
package/dist/eol.d.ts CHANGED
@@ -15,7 +15,7 @@ export declare let eol: string;
15
15
  /**
16
16
  * Sets the EOL to the OS-dependent value.
17
17
  */
18
- export declare const setEOLStyleFromOS: () => void;
18
+ export declare const setEOLStyleFromOS: () => Promise<void>;
19
19
  /**
20
20
  * Sets the EOL explicitly to the given value.
21
21
  * (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;AAIH;;GAEG;AACH,eAAO,MAAM,SAAS;;;CAGZ,CAAA;AAGV;;GAEG;AACH,eAAO,IAAI,GAAG,EAAE,MAAqB,CAAA;AAGrC;;GAEG;AACH,eAAO,MAAM,iBAAiB,YAE7B,CAAA;AAGD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,WAAY,MAAM,SAE9C,CAAA;AAKD;;;GAGG;AACH,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,MAAM,EACtB,CAAA"}
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;;GAEG;AACH,eAAO,MAAM,iBAAiB,qBAoB7B,CAAA;AAGD;;;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,7 +1,42 @@
1
1
  /**
2
2
  * EOL-related constants and functions.
3
3
  */
4
- import { EOL } from "os";
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
+ };
5
40
  /**
6
41
  * Common EOL styles.
7
42
  */
@@ -16,9 +51,38 @@ export var eol = eolStyles.lf;
16
51
  /**
17
52
  * Sets the EOL to the OS-dependent value.
18
53
  */
19
- export var setEOLStyleFromOS = function () {
20
- eol = EOL;
21
- };
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
+ }); };
22
86
  /**
23
87
  * Sets the EOL explicitly to the given value.
24
88
  * (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;AAEH,OAAO,EAAC,GAAG,EAAC,MAAM,IAAI,CAAA;AAEtB;;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;;GAEG;AACH,MAAM,CAAC,IAAM,iBAAiB,GAAG;IAC7B,GAAG,GAAG,GAAG,CAAA;AACb,CAAC,CAAA;AAGD;;;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"}
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;;GAEG;AACH,MAAM,CAAC,IAAM,iBAAiB,GAAG;;;;;gBACvB,qBAAqB,GAAG;oBAC1B,OAAO,CAAC,KAAK,CAAC,mKAA4J,CAAC,CAAA;gBAC/K,CAAC,CAAA;gBACD,qBAAM,MAAM,CAAC,IAAI,CAAC;yBACb,IAAI,CAAC,UAAC,SAAS;wBACZ,IAAI,SAAS,EAAE,CAAC;4BACZ,GAAG,GAAG,SAAS,CAAC,GAAG,CAAA;wBACvB,CAAC;6BAAM,CAAC;4BACJ,qBAAqB,EAAE,CAAA;wBAC3B,CAAC;oBACL,CAAC,CAAC;yBACD,KAAK,CAAC,UAAC,MAAM;wBACV,IAAI,MAAM,YAAY,SAAS,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;4BACrE,qBAAqB,EAAE,CAAA;wBAC3B,CAAC;6BAAM,CAAC;4BACJ,OAAO,CAAC,KAAK,CAAC,qFAAmF,CAAC,CAAA;4BAClG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;wBACvB,CAAC;oBACL,CAAC,CAAC,EAAA;;gBAfN,SAeM,CAAA;;;;KACT,CAAA;AAGD;;;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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "littoral-templates",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "A small JavaScript/TypeScript framework to do templating comfortably using the template literal syntax in either JavaScript or TypeScript.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",