node-tao 0.0.1
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 +230 -0
- package/checks.d.ts +8 -0
- package/checks.d.ts.map +1 -0
- package/checks.js +37 -0
- package/checks.js.map +1 -0
- package/const.d.ts +24 -0
- package/const.d.ts.map +1 -0
- package/const.js +51 -0
- package/const.js.map +1 -0
- package/default-config.d.ts +4 -0
- package/default-config.d.ts.map +1 -0
- package/default-config.js +25 -0
- package/default-config.js.map +1 -0
- package/error/error.html +259 -0
- package/error-utils.d.ts +21 -0
- package/error-utils.d.ts.map +1 -0
- package/error-utils.js +163 -0
- package/error-utils.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +6 -0
- package/index.js.map +1 -0
- package/init.d.ts +12 -0
- package/init.d.ts.map +1 -0
- package/init.js +31 -0
- package/init.js.map +1 -0
- package/interfaces.d.ts +170 -0
- package/interfaces.d.ts.map +1 -0
- package/interfaces.js +3 -0
- package/interfaces.js.map +1 -0
- package/metrics.d.ts +16 -0
- package/metrics.d.ts.map +1 -0
- package/metrics.js +80 -0
- package/metrics.js.map +1 -0
- package/package.json +45 -0
- package/parsing-helpers.d.ts +8 -0
- package/parsing-helpers.d.ts.map +1 -0
- package/parsing-helpers.js +60 -0
- package/parsing-helpers.js.map +1 -0
- package/store.d.ts +29 -0
- package/store.d.ts.map +1 -0
- package/store.js +52 -0
- package/store.js.map +1 -0
- package/tao.d.ts +81 -0
- package/tao.d.ts.map +1 -0
- package/tao.js +533 -0
- package/tao.js.map +1 -0
- package/templates-access.d.ts +15 -0
- package/templates-access.d.ts.map +1 -0
- package/templates-access.js +38 -0
- package/templates-access.js.map +1 -0
- package/utils.d.ts +45 -0
- package/utils.d.ts.map +1 -0
- package/utils.js +227 -0
- package/utils.js.map +1 -0
package/error-utils.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ErrorData } from './interfaces';
|
|
2
|
+
declare function findOriginalLineNumberWithMessage(error: ErrorData, compiledAnonymousFnContent: string, originalFileContent: string): [string, string[], number | null];
|
|
3
|
+
declare function getErrorMessageAndSource(error: any): [string, string];
|
|
4
|
+
/**
|
|
5
|
+
* Calling new Function(...) is an anonymous function.
|
|
6
|
+
*/
|
|
7
|
+
declare function getLineFromAnonymousFunction(source: string): number;
|
|
8
|
+
declare function extractContentFromAnonymousFunction(compiledAnonymousFnContent: string, line: number): string;
|
|
9
|
+
declare function getOriginalLineNumber(compiledJoined: string): number;
|
|
10
|
+
/**
|
|
11
|
+
* Error occurred while parsing the template (unclosed string)
|
|
12
|
+
*/
|
|
13
|
+
declare function handleParseError(error: any): any;
|
|
14
|
+
declare function getParsingErrorData(expression: string, index: number, message: string, fileContent: string): ErrorData;
|
|
15
|
+
declare function infiniteInclusionError(filename: string, children: string[]): any;
|
|
16
|
+
declare function handleNonUniqueFile(files: string[], filename: string): any;
|
|
17
|
+
declare function handleWrongTypeOfTemplate(template: string): any;
|
|
18
|
+
declare function handleNotFoundDynamicTemplate(template: string): any;
|
|
19
|
+
declare function handleNoTemplateFilesFound(views: string, extension: string): any;
|
|
20
|
+
export { getErrorMessageAndSource, getLineFromAnonymousFunction, extractContentFromAnonymousFunction, getOriginalLineNumber, findOriginalLineNumberWithMessage, handleParseError, getParsingErrorData, handleNonUniqueFile, infiniteInclusionError, handleWrongTypeOfTemplate, handleNotFoundDynamicTemplate, handleNoTemplateFilesFound, };
|
|
21
|
+
//# sourceMappingURL=error-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-utils.d.ts","sourceRoot":"","sources":["../src/error-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,cAAc,CAAC;AAEpD,iBAAS,iCAAiC,CACxC,KAAK,EAAE,SAAS,EAChB,0BAA0B,EAAE,MAAM,EAClC,mBAAmB,EAAE,MAAM,GAC1B,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC,CAkCnC;AAED,iBAAS,wBAAwB,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAI9D;AAED;;GAEG;AACH,iBAAS,4BAA4B,CAAC,MAAM,EAAE,MAAM,UAKnD;AAED,iBAAS,mCAAmC,CAAC,0BAA0B,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAS5F;AAiBD,iBAAS,qBAAqB,CAAC,cAAc,EAAE,MAAM,UAMpD;AAWD;;GAEG;AACH,iBAAS,gBAAgB,CAAC,KAAK,EAAE,GAAG,OAMnC;AAED,iBAAS,mBAAmB,CAC1B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,SAAS,CAWX;AAQD,iBAAS,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAWnE;AAED,iBAAS,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,OAgB7D;AAED,iBAAS,yBAAyB,CAAC,QAAQ,EAAE,MAAM,OAUlD;AAED,iBAAS,6BAA6B,CAAC,QAAQ,EAAE,MAAM,OAUtD;AAED,iBAAS,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAUnE;AAED,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,mCAAmC,EACnC,qBAAqB,EACrB,iCAAiC,EACjC,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,6BAA6B,EAC7B,0BAA0B,GAC3B,CAAC"}
|
package/error-utils.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleNoTemplateFilesFound = exports.handleNotFoundDynamicTemplate = exports.handleWrongTypeOfTemplate = exports.infiniteInclusionError = exports.handleNonUniqueFile = exports.getParsingErrorData = exports.handleParseError = exports.findOriginalLineNumberWithMessage = exports.getOriginalLineNumber = exports.extractContentFromAnonymousFunction = exports.getLineFromAnonymousFunction = exports.getErrorMessageAndSource = void 0;
|
|
4
|
+
function findOriginalLineNumberWithMessage(error, compiledAnonymousFnContent, originalFileContent) {
|
|
5
|
+
const basicErrorTypes = [
|
|
6
|
+
'Template Type Error',
|
|
7
|
+
'Not Found Error',
|
|
8
|
+
'Precompilation Error',
|
|
9
|
+
'Inclusion Error',
|
|
10
|
+
];
|
|
11
|
+
if (basicErrorTypes.includes(error.type)) {
|
|
12
|
+
return [error.message, [], null];
|
|
13
|
+
}
|
|
14
|
+
if (error.type === 'Parse Error') {
|
|
15
|
+
handleParseError(error);
|
|
16
|
+
return [error.message, error.fileContent, error.lineNumber];
|
|
17
|
+
}
|
|
18
|
+
if (error.type === 'ReadFile Error') {
|
|
19
|
+
return ['Error while reading template file', [], null];
|
|
20
|
+
}
|
|
21
|
+
const [message, source] = getErrorMessageAndSource(error);
|
|
22
|
+
const lineFromAnonymousFn = getLineFromAnonymousFunction(source);
|
|
23
|
+
if (error.type === 'Compilation Error') {
|
|
24
|
+
const fileContent = splitByLine(originalFileContent);
|
|
25
|
+
return [message, fileContent, lineFromAnonymousFn];
|
|
26
|
+
}
|
|
27
|
+
const compiledContent = extractContentFromAnonymousFunction(compiledAnonymousFnContent, lineFromAnonymousFn);
|
|
28
|
+
const lineNumber = getOriginalLineNumber(compiledContent);
|
|
29
|
+
const fileContent = splitByLine(originalFileContent);
|
|
30
|
+
return [message, fileContent, lineNumber];
|
|
31
|
+
}
|
|
32
|
+
exports.findOriginalLineNumberWithMessage = findOriginalLineNumberWithMessage;
|
|
33
|
+
function getErrorMessageAndSource(error) {
|
|
34
|
+
const [message, source] = error.stack.split('\n');
|
|
35
|
+
return [message, source];
|
|
36
|
+
}
|
|
37
|
+
exports.getErrorMessageAndSource = getErrorMessageAndSource;
|
|
38
|
+
/**
|
|
39
|
+
* Calling new Function(...) is an anonymous function.
|
|
40
|
+
*/
|
|
41
|
+
function getLineFromAnonymousFunction(source) {
|
|
42
|
+
const splitLastLineError = source.split('<anonymous>');
|
|
43
|
+
const [_, line] = splitLastLineError[1].split(':');
|
|
44
|
+
return Number(line);
|
|
45
|
+
}
|
|
46
|
+
exports.getLineFromAnonymousFunction = getLineFromAnonymousFunction;
|
|
47
|
+
function extractContentFromAnonymousFunction(compiledAnonymousFnContent, line) {
|
|
48
|
+
const LINES_CORRECTION = 2;
|
|
49
|
+
const lines = compiledAnonymousFnContent.split('\n');
|
|
50
|
+
const compiledContentUntilError = lines.slice(0, line - LINES_CORRECTION);
|
|
51
|
+
const compiledContent = compiledContentUntilError.join('\n');
|
|
52
|
+
return compiledContent;
|
|
53
|
+
}
|
|
54
|
+
exports.extractContentFromAnonymousFunction = extractContentFromAnonymousFunction;
|
|
55
|
+
/**
|
|
56
|
+
* Small lineCounter correction.
|
|
57
|
+
*/
|
|
58
|
+
function isolatedCarriageReturn(compiledAnonymousFnContent) {
|
|
59
|
+
const regex = /\r/g;
|
|
60
|
+
let match = null;
|
|
61
|
+
let lineCount = 0;
|
|
62
|
+
while ((match = regex.exec(compiledAnonymousFnContent))) {
|
|
63
|
+
lineCount++;
|
|
64
|
+
}
|
|
65
|
+
return lineCount;
|
|
66
|
+
}
|
|
67
|
+
function getOriginalLineNumber(compiledJoined) {
|
|
68
|
+
let lineCount = 1;
|
|
69
|
+
lineCount += isolatedCarriageReturn(compiledJoined);
|
|
70
|
+
lineCount += (compiledJoined.match(/\\n/g) || []).length;
|
|
71
|
+
return lineCount;
|
|
72
|
+
}
|
|
73
|
+
exports.getOriginalLineNumber = getOriginalLineNumber;
|
|
74
|
+
function splitByLine(fileContent) {
|
|
75
|
+
const fileSplittedByNewLine = fileContent.split('\n');
|
|
76
|
+
const lastLine = fileSplittedByNewLine.at(-1) || '';
|
|
77
|
+
const lastLineIsEmpty = !lastLine.trim();
|
|
78
|
+
if (lastLineIsEmpty)
|
|
79
|
+
return fileSplittedByNewLine.slice(0, -1);
|
|
80
|
+
return fileSplittedByNewLine;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Error occurred while parsing the template (unclosed string)
|
|
84
|
+
*/
|
|
85
|
+
function handleParseError(error) {
|
|
86
|
+
const { fileContent } = error;
|
|
87
|
+
const content = splitByLine(fileContent);
|
|
88
|
+
error.fileContent = content;
|
|
89
|
+
return error;
|
|
90
|
+
}
|
|
91
|
+
exports.handleParseError = handleParseError;
|
|
92
|
+
function getParsingErrorData(expression, index, message, fileContent) {
|
|
93
|
+
const lineNumber = getTemplateParsedLineNumber(expression, index);
|
|
94
|
+
const type = 'Parse Error';
|
|
95
|
+
const error = new Error();
|
|
96
|
+
error.message = message;
|
|
97
|
+
error.lineNumber = lineNumber;
|
|
98
|
+
error.fileContent = fileContent;
|
|
99
|
+
error.type = type;
|
|
100
|
+
return error;
|
|
101
|
+
}
|
|
102
|
+
exports.getParsingErrorData = getParsingErrorData;
|
|
103
|
+
function getTemplateParsedLineNumber(expression, index) {
|
|
104
|
+
const splitIntoLines = expression.slice(0, index).split(/\n/);
|
|
105
|
+
const line = splitIntoLines.length;
|
|
106
|
+
return line;
|
|
107
|
+
}
|
|
108
|
+
function infiniteInclusionError(filename, children) {
|
|
109
|
+
const error = new Error();
|
|
110
|
+
const errorType = 'Inclusion Error';
|
|
111
|
+
error.message = `Possible infinite inclusion detected in ${filename} with children: ${children.join(' - ')}`;
|
|
112
|
+
error.lineNumber = null;
|
|
113
|
+
error.fileContent = '';
|
|
114
|
+
error.type = errorType;
|
|
115
|
+
return error;
|
|
116
|
+
}
|
|
117
|
+
exports.infiniteInclusionError = infiniteInclusionError;
|
|
118
|
+
function handleNonUniqueFile(files, filename) {
|
|
119
|
+
const errorType = 'Precompilation Error';
|
|
120
|
+
let errorMessage = `Non existing template or template out of scope (reading "${filename}")`;
|
|
121
|
+
if (files.length > 1) {
|
|
122
|
+
errorMessage = `Non unique template given "${filename}". Possible:\n- ${files.join('\n- ')}`;
|
|
123
|
+
}
|
|
124
|
+
const error = new Error();
|
|
125
|
+
error.message = errorMessage;
|
|
126
|
+
error.lineNumber = null;
|
|
127
|
+
error.fileContent = '';
|
|
128
|
+
error.filename = filename;
|
|
129
|
+
error.type = errorType;
|
|
130
|
+
return error;
|
|
131
|
+
}
|
|
132
|
+
exports.handleNonUniqueFile = handleNonUniqueFile;
|
|
133
|
+
function handleWrongTypeOfTemplate(template) {
|
|
134
|
+
const errorType = 'Template Type Error';
|
|
135
|
+
const error = new Error();
|
|
136
|
+
error.message = `Provided template "${template}" should be of type string`;
|
|
137
|
+
error.lineNumber = null;
|
|
138
|
+
error.fileContent = '';
|
|
139
|
+
error.type = errorType;
|
|
140
|
+
return error;
|
|
141
|
+
}
|
|
142
|
+
exports.handleWrongTypeOfTemplate = handleWrongTypeOfTemplate;
|
|
143
|
+
function handleNotFoundDynamicTemplate(template) {
|
|
144
|
+
const errorType = 'Not Found Error';
|
|
145
|
+
const error = new Error();
|
|
146
|
+
error.message = `Failed to get programmaticaly defined template "${template}" from cache`;
|
|
147
|
+
error.lineNumber = null;
|
|
148
|
+
error.fileContent = '';
|
|
149
|
+
error.type = errorType;
|
|
150
|
+
return error;
|
|
151
|
+
}
|
|
152
|
+
exports.handleNotFoundDynamicTemplate = handleNotFoundDynamicTemplate;
|
|
153
|
+
function handleNoTemplateFilesFound(views, extension) {
|
|
154
|
+
const errorType = 'Not Found Error';
|
|
155
|
+
const error = new Error();
|
|
156
|
+
error.message = `No template files found in ${views} with extension ${extension}`;
|
|
157
|
+
error.lineNumber = null;
|
|
158
|
+
error.fileContent = '';
|
|
159
|
+
error.type = errorType;
|
|
160
|
+
return error;
|
|
161
|
+
}
|
|
162
|
+
exports.handleNoTemplateFilesFound = handleNoTemplateFilesFound;
|
|
163
|
+
//# sourceMappingURL=error-utils.js.map
|
|
@@ -0,0 +1 @@
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AAK,CAAC;AACf,CAAC;AAcC,gEAA0B"}
|
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tao = void 0;
|
|
4
|
+
var tao_1 = require("./tao");
|
|
5
|
+
Object.defineProperty(exports, "Tao", { enumerable: true, get: function () { return tao_1.Tao; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6BAA4B;AAAnB,0FAAA,GAAG,OAAA"}
|
package/init.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DebugData, Parse, Tags } from './interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration tag options can be partial, so definitive assignation is required to maintain all properties.
|
|
4
|
+
*/
|
|
5
|
+
declare function assignTags(tags: Tags): Required<Tags>;
|
|
6
|
+
/**
|
|
7
|
+
* Configuration parse options can be partial, so definitive assignation is required to maintain all properties.
|
|
8
|
+
*/
|
|
9
|
+
declare function assignParse(parse: Parse): Required<Parse>;
|
|
10
|
+
declare function initDebugData(): DebugData;
|
|
11
|
+
export { assignTags, assignParse, initDebugData };
|
|
12
|
+
//# sourceMappingURL=init.d.ts.map
|
package/init.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAStD;;GAEG;AACH,iBAAS,UAAU,CAAC,IAAI,EAAE,IAAI,kBAK7B;AAED;;GAEG;AACH,iBAAS,WAAW,CAAC,KAAK,EAAE,KAAK,mBAKhC;AAED,iBAAS,aAAa,cAOrB;AAED,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC"}
|
package/init.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initDebugData = exports.assignParse = exports.assignTags = void 0;
|
|
4
|
+
const const_1 = require("./const");
|
|
5
|
+
/**
|
|
6
|
+
* Configuration tag options can be partial, so definitive assignation is required to maintain all properties.
|
|
7
|
+
*/
|
|
8
|
+
function assignTags(tags) {
|
|
9
|
+
const { opening = const_1.DEFAULT_OPENING, closing = const_1.DEFAULT_CLOSING } = tags;
|
|
10
|
+
const definitiveTags = { opening, closing };
|
|
11
|
+
return definitiveTags;
|
|
12
|
+
}
|
|
13
|
+
exports.assignTags = assignTags;
|
|
14
|
+
/**
|
|
15
|
+
* Configuration parse options can be partial, so definitive assignation is required to maintain all properties.
|
|
16
|
+
*/
|
|
17
|
+
function assignParse(parse) {
|
|
18
|
+
const { exec = const_1.DEFAULT_EXEC, interpolate = const_1.DEFAULT_INTERPOLATE, raw = const_1.DEFAULT_RAW } = parse;
|
|
19
|
+
const definitiveParse = { exec, interpolate, raw };
|
|
20
|
+
return definitiveParse;
|
|
21
|
+
}
|
|
22
|
+
exports.assignParse = assignParse;
|
|
23
|
+
function initDebugData() {
|
|
24
|
+
const debugData = {
|
|
25
|
+
compiledAnonymousFnContent: '',
|
|
26
|
+
fileContent: '',
|
|
27
|
+
};
|
|
28
|
+
return debugData;
|
|
29
|
+
}
|
|
30
|
+
exports.initDebugData = initDebugData;
|
|
31
|
+
//# sourceMappingURL=init.js.map
|
package/init.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;AACA,mCAMiB;AAEjB;;GAEG;AACH,SAAS,UAAU,CAAC,IAAU;IAC5B,MAAM,EAAE,OAAO,GAAG,uBAAe,EAAE,OAAO,GAAG,uBAAe,EAAE,GAAG,IAAI,CAAC;IACtE,MAAM,cAAc,GAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAE5D,OAAO,cAAc,CAAC;AACxB,CAAC;AAqBQ,gCAAU;AAnBnB;;GAEG;AACH,SAAS,WAAW,CAAC,KAAY;IAC/B,MAAM,EAAE,IAAI,GAAG,oBAAY,EAAE,WAAW,GAAG,2BAAmB,EAAE,GAAG,GAAG,mBAAW,EAAE,GAAG,KAAK,CAAC;IAC5F,MAAM,eAAe,GAAoB,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;IAEpE,OAAO,eAAe,CAAC;AACzB,CAAC;AAWoB,kCAAW;AAThC,SAAS,aAAa;IACpB,MAAM,SAAS,GAAc;QAC3B,0BAA0B,EAAE,EAAE;QAC9B,WAAW,EAAE,EAAE;KAChB,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC;AAEiC,sCAAa"}
|
package/interfaces.d.ts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
export type ErrorType = 'Parse Error' | 'ReadFile Error' | 'Compilation Error' | 'Execution Error' | 'Inclusion Error' | 'Precompilation Error' | 'Template Type Error' | 'Not Found Error';
|
|
2
|
+
export interface DebugData {
|
|
3
|
+
compiledAnonymousFnContent: string;
|
|
4
|
+
fileContent: string;
|
|
5
|
+
}
|
|
6
|
+
export interface Parse {
|
|
7
|
+
/**
|
|
8
|
+
* Which prefix to use for evaluation.
|
|
9
|
+
* @default ""
|
|
10
|
+
*/
|
|
11
|
+
exec?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Which prefix to use for interpolation.
|
|
14
|
+
* @default "="
|
|
15
|
+
*/
|
|
16
|
+
interpolate?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Which prefix to use for raw interpolation.
|
|
19
|
+
* @default "~"
|
|
20
|
+
*/
|
|
21
|
+
raw?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface Tags {
|
|
24
|
+
/**
|
|
25
|
+
* @default "<%"
|
|
26
|
+
*/
|
|
27
|
+
opening?: string;
|
|
28
|
+
/**
|
|
29
|
+
* @default "%>"
|
|
30
|
+
*/
|
|
31
|
+
closing?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* HTML content or template data.
|
|
35
|
+
*/
|
|
36
|
+
export type AstObject = string | TemplateData;
|
|
37
|
+
export type TagType = 'raw' | 'execute' | 'interpolate';
|
|
38
|
+
export type FileResolution = 'strict' | 'flexible';
|
|
39
|
+
export interface TemplateData {
|
|
40
|
+
type: TagType;
|
|
41
|
+
content: string;
|
|
42
|
+
}
|
|
43
|
+
export type ChildTemplateFunction = (data: object, helpers: Helpers) => string;
|
|
44
|
+
export type TemplateFunction = (data: object, helpers: Helpers, ɵɵstart: number, ɵɵcacheHit: boolean) => string;
|
|
45
|
+
export interface ErrorData {
|
|
46
|
+
filename: string;
|
|
47
|
+
fileContent: string[];
|
|
48
|
+
message: string;
|
|
49
|
+
lineNumber: number | null;
|
|
50
|
+
type: ErrorType;
|
|
51
|
+
isAChildError: boolean;
|
|
52
|
+
errorHTML: string;
|
|
53
|
+
}
|
|
54
|
+
export interface Data {
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
}
|
|
57
|
+
export type Helpers = {
|
|
58
|
+
[fnName: string]: HelperFunction;
|
|
59
|
+
};
|
|
60
|
+
export type HelperFunction = (...args: any[]) => any;
|
|
61
|
+
export interface Metrics {
|
|
62
|
+
development: boolean;
|
|
63
|
+
files: string[];
|
|
64
|
+
cacheEnabled: boolean;
|
|
65
|
+
filename: string;
|
|
66
|
+
}
|
|
67
|
+
export interface LoadedChildTemplateData {
|
|
68
|
+
templateLoaded: string;
|
|
69
|
+
data: Data;
|
|
70
|
+
helpers: Helpers;
|
|
71
|
+
filename: string;
|
|
72
|
+
}
|
|
73
|
+
export interface LoadedTemplateData {
|
|
74
|
+
templateLoaded: string;
|
|
75
|
+
data: Data;
|
|
76
|
+
helpers: Helpers;
|
|
77
|
+
ɵɵstart: number;
|
|
78
|
+
filename: string;
|
|
79
|
+
ɵɵcacheHit: boolean;
|
|
80
|
+
}
|
|
81
|
+
export interface CompileChildExecuteData {
|
|
82
|
+
fullPath: string;
|
|
83
|
+
data: Data;
|
|
84
|
+
helpers: Helpers;
|
|
85
|
+
filename: string;
|
|
86
|
+
}
|
|
87
|
+
export interface CompileExecuteData {
|
|
88
|
+
fullPath: string;
|
|
89
|
+
data: Data;
|
|
90
|
+
helpers: Helpers;
|
|
91
|
+
ɵɵstart: number;
|
|
92
|
+
filename: string;
|
|
93
|
+
ɵɵcacheHit: boolean;
|
|
94
|
+
}
|
|
95
|
+
export interface ExecuteChildFunction {
|
|
96
|
+
compiledContent: string;
|
|
97
|
+
data: Data;
|
|
98
|
+
helpers: Helpers;
|
|
99
|
+
filename: string;
|
|
100
|
+
}
|
|
101
|
+
export interface ExecuteFunction {
|
|
102
|
+
compiledContent: string;
|
|
103
|
+
data: Data;
|
|
104
|
+
helpers: Helpers;
|
|
105
|
+
ɵɵstart: number;
|
|
106
|
+
filename: string;
|
|
107
|
+
ɵɵcacheHit: boolean;
|
|
108
|
+
}
|
|
109
|
+
export interface options {
|
|
110
|
+
/**
|
|
111
|
+
* Automatically XML-escape interpolations.
|
|
112
|
+
*
|
|
113
|
+
* @default true
|
|
114
|
+
*/
|
|
115
|
+
autoEscape?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Enable template lazy cache.
|
|
118
|
+
*
|
|
119
|
+
* @default true
|
|
120
|
+
*/
|
|
121
|
+
cache?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Display a visual error representation and activate metrics. Provided data is available in the console. Add infinite inclusion protection.
|
|
124
|
+
*
|
|
125
|
+
* @default false
|
|
126
|
+
*/
|
|
127
|
+
development?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Function to XML-sanitize interpolations.
|
|
130
|
+
*/
|
|
131
|
+
escapeFunction?: (str: unknown) => string;
|
|
132
|
+
/**
|
|
133
|
+
* Parsing options.
|
|
134
|
+
*/
|
|
135
|
+
parse?: Parse;
|
|
136
|
+
/**
|
|
137
|
+
* Default opening '<%', default closing '%>'.
|
|
138
|
+
*/
|
|
139
|
+
tags?: Tags;
|
|
140
|
+
/**
|
|
141
|
+
* Directory that contains templates.
|
|
142
|
+
*
|
|
143
|
+
* @default process.cwd()
|
|
144
|
+
*/
|
|
145
|
+
views?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Template file extension.
|
|
148
|
+
*
|
|
149
|
+
* @default 'html'
|
|
150
|
+
*/
|
|
151
|
+
extension?: string;
|
|
152
|
+
/**
|
|
153
|
+
* File mode resolution. Strict means you have to define the template path relative to the view provided, flexible allow you to define only the end of your path (make sure it is unique).
|
|
154
|
+
*
|
|
155
|
+
* @default "flexible"
|
|
156
|
+
*/
|
|
157
|
+
fileResolution?: FileResolution;
|
|
158
|
+
}
|
|
159
|
+
export interface DefinitiveOptions {
|
|
160
|
+
autoEscape: boolean;
|
|
161
|
+
cache: boolean;
|
|
162
|
+
development: boolean;
|
|
163
|
+
escapeFunction: (str: unknown) => string;
|
|
164
|
+
parse: Required<Parse>;
|
|
165
|
+
tags: Required<Tags>;
|
|
166
|
+
views: string;
|
|
167
|
+
extension: string;
|
|
168
|
+
fileResolution: FileResolution;
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,aAAa,GACb,gBAAgB,GACh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|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
|
package/metrics.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Metrics } from './interfaces';
|
|
2
|
+
import { Store } from './store';
|
|
3
|
+
declare function includeRenderTime(development: boolean): "" | "const ɵɵrenderDuration = (performance.now() - ɵɵstart).toFixed(2);";
|
|
4
|
+
declare function includeChildren(development: boolean): "" | "const ɵɵchildren = this.childrenStore.get(this.parentTemplate) || [];";
|
|
5
|
+
declare function updateChildrenStore(childrenStore: Store<string[]>, filename: string, parentTemplate: string, development: boolean): void;
|
|
6
|
+
/**
|
|
7
|
+
* Display metrics in the browser. Do not include logs if disabled or if the current template is included in another template. Make data available in the console.
|
|
8
|
+
*/
|
|
9
|
+
declare function includeMetrics(metricsData: Metrics): string;
|
|
10
|
+
/**
|
|
11
|
+
* Takes into account the parent directory.
|
|
12
|
+
*/
|
|
13
|
+
declare function getFileNameAndAbsPath(files: string[]): string[];
|
|
14
|
+
declare function getNormalStyle(): string;
|
|
15
|
+
export { getFileNameAndAbsPath, getNormalStyle, includeMetrics, includeRenderTime, includeChildren, updateChildrenStore, };
|
|
16
|
+
//# sourceMappingURL=metrics.d.ts.map
|
package/metrics.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,iBAAS,iBAAiB,CAAC,WAAW,EAAE,OAAO,6EAI9C;AAED,iBAAS,eAAe,CAAC,WAAW,EAAE,OAAO,gFAI5C;AAED,iBAAS,mBAAmB,CAC1B,aAAa,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,EAC9B,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,OAAO,QAYrB;AAED;;GAEG;AACH,iBAAS,cAAc,CAAC,WAAW,EAAE,OAAO,UAW3C;AAoCD;;GAEG;AACH,iBAAS,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,YAS7C;AAED,iBAAS,cAAc,WAEtB;AAED,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,mBAAmB,GACpB,CAAC"}
|
package/metrics.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateChildrenStore = exports.includeChildren = exports.includeRenderTime = exports.includeMetrics = exports.getNormalStyle = exports.getFileNameAndAbsPath = void 0;
|
|
4
|
+
const const_1 = require("./const");
|
|
5
|
+
const error_utils_1 = require("./error-utils");
|
|
6
|
+
function includeRenderTime(development) {
|
|
7
|
+
if (!development)
|
|
8
|
+
return '';
|
|
9
|
+
return `const ɵɵrenderDuration = (performance.now() - ɵɵstart).toFixed(2);`;
|
|
10
|
+
}
|
|
11
|
+
exports.includeRenderTime = includeRenderTime;
|
|
12
|
+
function includeChildren(development) {
|
|
13
|
+
if (!development)
|
|
14
|
+
return '';
|
|
15
|
+
return `const ɵɵchildren = this.childrenStore.get(this.parentTemplate) || [];`;
|
|
16
|
+
}
|
|
17
|
+
exports.includeChildren = includeChildren;
|
|
18
|
+
function updateChildrenStore(childrenStore, filename, parentTemplate, development) {
|
|
19
|
+
if (!development)
|
|
20
|
+
return;
|
|
21
|
+
const children = childrenStore.get(parentTemplate) || [];
|
|
22
|
+
if (children.includes(filename)) {
|
|
23
|
+
const error = (0, error_utils_1.infiniteInclusionError)(filename, children);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
children.push(filename);
|
|
27
|
+
childrenStore.set(parentTemplate, children);
|
|
28
|
+
}
|
|
29
|
+
exports.updateChildrenStore = updateChildrenStore;
|
|
30
|
+
/**
|
|
31
|
+
* Display metrics in the browser. Do not include logs if disabled or if the current template is included in another template. Make data available in the console.
|
|
32
|
+
*/
|
|
33
|
+
function includeMetrics(metricsData) {
|
|
34
|
+
const { cacheEnabled, filename: filename, files, development } = metricsData;
|
|
35
|
+
if (!development)
|
|
36
|
+
return '""';
|
|
37
|
+
const templatesPathWithDirectory = getFileNameAndAbsPath(files);
|
|
38
|
+
return `'<script>const data = ' + JSON.stringify(${const_1.TEMPLATE_VARNAME}) + ';console.log(${logRendered(filename)});${logChildTemplatesCount()};${logRenderTime()};console.log(${logCache(cacheEnabled)});${logCacheHit()};${logMappedTemplates(templatesPathWithDirectory)}</script>'`;
|
|
39
|
+
}
|
|
40
|
+
exports.includeMetrics = includeMetrics;
|
|
41
|
+
function logMappedTemplates(templates) {
|
|
42
|
+
const logs = templates
|
|
43
|
+
.map((template, i) => `console.log("%c#${i + 1} %c${template}", "color: #888", "color: #87cefa");`)
|
|
44
|
+
.join('');
|
|
45
|
+
return `console.group("%cMAPPED TEMPLATES (${templates.length})", "color: #00ffcc; font-weight: bold");${logs}console.groupEnd();`;
|
|
46
|
+
}
|
|
47
|
+
function logCacheHit() {
|
|
48
|
+
return `console.log("%c[CACHE HIT]%c ' + ɵɵcacheHit + '", "color:rgb(255, 0, 221);font-weight:bold",${getNormalStyle()})`;
|
|
49
|
+
}
|
|
50
|
+
function logCache(cacheEnabled) {
|
|
51
|
+
const isEnabled = cacheEnabled ? 'enabled' : 'disabled';
|
|
52
|
+
return `"%c[CACHE]%c ${isEnabled}", "color: #ff4d4d;font-weight:bold", ${getNormalStyle()}`;
|
|
53
|
+
}
|
|
54
|
+
function logRendered(template) {
|
|
55
|
+
return `"%c[RENDERED]%c ${template}", "color: #00ff99;font-weight:bold", ${getNormalStyle()}`;
|
|
56
|
+
}
|
|
57
|
+
function logChildTemplatesCount() {
|
|
58
|
+
const children = `(ɵɵchildren.length ? ɵɵchildren.join(", ") : "")`;
|
|
59
|
+
return `console.log("%c[CHILDREN]%c ' + ${children} + '", "color: #66ccff;font-weight:bold",${getNormalStyle()})`;
|
|
60
|
+
}
|
|
61
|
+
function logRenderTime() {
|
|
62
|
+
return `console.log("%c[RENDER TIME]%c ' + ɵɵrenderDuration + 'ms", "color: #ffa500;font-weight:bold",${getNormalStyle()})`;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Takes into account the parent directory.
|
|
66
|
+
*/
|
|
67
|
+
function getFileNameAndAbsPath(files) {
|
|
68
|
+
const templatesPathWithDirectory = [];
|
|
69
|
+
for (const file of files) {
|
|
70
|
+
const fileName = file.split('/').slice(-2).join('/');
|
|
71
|
+
templatesPathWithDirectory.push(fileName);
|
|
72
|
+
}
|
|
73
|
+
return templatesPathWithDirectory;
|
|
74
|
+
}
|
|
75
|
+
exports.getFileNameAndAbsPath = getFileNameAndAbsPath;
|
|
76
|
+
function getNormalStyle() {
|
|
77
|
+
return `"color: #fff"`;
|
|
78
|
+
}
|
|
79
|
+
exports.getNormalStyle = getNormalStyle;
|
|
80
|
+
//# sourceMappingURL=metrics.js.map
|
package/metrics.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":";;;AAAA,mCAA2C;AAC3C,+CAAuD;AAIvD,SAAS,iBAAiB,CAAC,WAAoB;IAC7C,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,CAAC;IAE5B,OAAO,oEAAoE,CAAC;AAC9E,CAAC;AAkGC,8CAAiB;AAhGnB,SAAS,eAAe,CAAC,WAAoB;IAC3C,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,CAAC;IAE5B,OAAO,uEAAuE,CAAC;AACjF,CAAC;AA6FC,0CAAe;AA3FjB,SAAS,mBAAmB,CAC1B,aAA8B,EAC9B,QAAgB,EAChB,cAAsB,EACtB,WAAoB;IAEpB,IAAI,CAAC,WAAW;QAAE,OAAO;IAEzB,MAAM,QAAQ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AQ,CAAC,YAAqB;IACrC,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;IAExD,OAAO,sBAAsB,SAAS,yCAAyC,cAAc,EAAE,EAAE,CAAC;AACpG,CAAC;AAED,SAAS,WAAW,CAAC,QAAgB;IACnC,OAAO,sBAAsB,QAAQ,yCAAyC,cAAc,EAAE,EAAE,CAAC;AACnG,CAAC;AAED,SAAS,sBAAsB;IAC7B,MAAM,QAAQ,GAAG,kDAAkD,CAAC;IAEpE,OAAO,sCAAsC,QAAQ,4CAA4C,cAAc,EAAE,GAAG,CAAC;AACvH,CAAC;AAED,SAAS,aAAa;IACpB,OAAO,iGAAiG,cAAc,EAAE,GAAG,CAAC;AAC9H,CAAC;AAED;;GAEG;AACH,SAAS,qBAAqB,CAAC,KAAe;IAC5C,MAAM,0BAA0B,GAAa,EAAE,CAAC;IAEhD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACrD,0BAA0B,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC3C;IAED,OAAO,0BAA0B,CAAC;AACpC,CAAC;AAOC,sDAAqB;AALvB,SAAS,cAAc;IACrB,OAAO,eAAe,CAAC;AACzB,CAAC;AAIC,wCAAc"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "node-tao",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Lightweight, fast, and powerful embedded JS template engine",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"template engine",
|
|
7
|
+
"embedded template engine",
|
|
8
|
+
"partials",
|
|
9
|
+
"node template engine"
|
|
10
|
+
],
|
|
11
|
+
"main": "index",
|
|
12
|
+
"author": "Manu Claeys <unam31@gmail.com>",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/node-tao/node-tao.git"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/node-tao/node-tao/issues"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=17.0.0"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "jest",
|
|
26
|
+
"build": "rimraf dist && tsc && cpx src/public/**/* dist/public && cpx \"src/templates/**/*\" dist/templates && cpx src/error/**/* dist/error",
|
|
27
|
+
"build-for-publish": "rimraf dist && tsc && cpx src/error/error.html dist/error && cpx package.json dist/ && cpx README.md dist/",
|
|
28
|
+
"startNodemon": "nodemon --ext ts,js,json,css,html --watch src --exec \"tsc && cpx src/templates/**/* dist/templates && cpx src/error/**/* dist/error && node dist/server.js\""
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/jest": "29.4.0",
|
|
32
|
+
"@types/node": "18.14.2",
|
|
33
|
+
"cpx2": "8.0.0",
|
|
34
|
+
"jest": "29.7.0",
|
|
35
|
+
"nodemon": "3.1.9",
|
|
36
|
+
"rimraf": "4.1.2",
|
|
37
|
+
"ts-jest": "29.3.2",
|
|
38
|
+
"ts-node": "10.9.1",
|
|
39
|
+
"tsc-watch": "6.2.0",
|
|
40
|
+
"typescript": "5.1.3"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"glob": "11.0.3"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TemplateData } from './interfaces';
|
|
2
|
+
declare function checkForUnclosedPrefix(templateData: TemplateData | undefined, expression: string, originalOpen: string, openingResultIndex: number, fileContent: string): void;
|
|
3
|
+
/**
|
|
4
|
+
* Handle quotes and throw in case of an error.
|
|
5
|
+
*/
|
|
6
|
+
declare function handleQuotes(expression: string, original: string, closeResultIndex: number, fileContent: string): number;
|
|
7
|
+
export { handleQuotes, checkForUnclosedPrefix };
|
|
8
|
+
//# sourceMappingURL=parsing-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsing-helpers.d.ts","sourceRoot":"","sources":["../src/parsing-helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,iBAAS,sBAAsB,CAC7B,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,kBAAkB,EAAE,MAAM,EAC1B,WAAW,EAAE,MAAM,QAYpB;AAED;;GAEG;AACH,iBAAS,YAAY,CACnB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM,UAgBpB;AAuED,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,CAAC"}
|