isomorphic-region-loader 21.0.27 → 21.0.29
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/browser/package.json +1 -1
- package/browser-prod/fesm2022/isomorphic-region-loader-browser.mjs.map +1 -1
- package/browser-prod/package.json +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/package.json +1 -1
- package/lib-prod/build-info._auto-generated_.js +26 -14
- package/lib-prod/env/env.angular-node-app.js +66 -130
- package/lib-prod/env/env.docs-webapp.js +66 -130
- package/lib-prod/env/env.electron-app.js +66 -130
- package/lib-prod/env/env.mobile-app.js +66 -130
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +66 -130
- package/lib-prod/env/env.vscode-plugin.js +66 -130
- package/lib-prod/env/index.js +6 -6
- package/lib-prod/index._auto-generated_.js +5 -0
- package/lib-prod/index.js +15 -14
- package/lib-prod/migrations/index.js +2 -1
- package/lib-prod/migrations/migrations_index._auto-generated_.js +3 -0
- package/lib-prod/models.js +12 -21
- package/lib-prod/package.json +1 -1
- package/lib-prod/region-remover.js +111 -116
- package/lib-prod/region.js +176 -156
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/fesm2022/isomorphic-region-loader-websql.mjs.map +1 -1
- package/websql-prod/package.json +1 -1
|
@@ -1,126 +1,121 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
//#region imports
|
|
2
|
+
import { REGEX_REGION, TAGS } from 'tnp-core/lib-prod';
|
|
3
|
+
import { path, ___NS__first, ___NS__isUndefined, ___NS__last } from 'tnp-core/lib-prod';
|
|
4
|
+
import { UtilsTypescript__NS__removeTaggedImportExport } from 'tnp-helpers/lib-prod';
|
|
5
|
+
import { Region } from './region';
|
|
6
|
+
//#endregion
|
|
7
|
+
export class RegionRemover {
|
|
8
|
+
static from(realtiveOrAbsFilePAth, content, replacementss, // Models.dev.Replacement[],
|
|
9
|
+
project) {
|
|
10
|
+
let fileExtension = path.extname(realtiveOrAbsFilePAth);
|
|
11
|
+
if (!replacementss) {
|
|
12
|
+
replacementss = [
|
|
13
|
+
[TAGS.BACKEND_FUNC, `return (void 0);`],
|
|
14
|
+
TAGS.BACKEND,
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
return new RegionRemover(realtiveOrAbsFilePAth, fileExtension, content, replacementss, project);
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
matchStartRegion(l) {
|
|
20
|
+
const res = !___NS__isUndefined(this.START_REGION.find(r => l.match(r)));
|
|
21
|
+
return res;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// debug,
|
|
26
|
-
) || "";
|
|
27
|
-
const lines = this.content.split("\n");
|
|
28
|
-
this.root = new Region(
|
|
29
|
-
this,
|
|
30
|
-
replacementss,
|
|
31
|
-
void 0,
|
|
32
|
-
0,
|
|
33
|
-
lines.length - 1,
|
|
34
|
-
___NS__first(lines),
|
|
35
|
-
___NS__last(lines),
|
|
36
|
-
lines
|
|
37
|
-
);
|
|
38
|
-
this.tree(this.root);
|
|
39
|
-
}
|
|
40
|
-
root;
|
|
41
|
-
START_REGION = [];
|
|
42
|
-
END_REGION = [];
|
|
43
|
-
static from(realtiveOrAbsFilePAth, content, replacementss, project) {
|
|
44
|
-
let fileExtension = path.extname(realtiveOrAbsFilePAth);
|
|
45
|
-
if (!replacementss) {
|
|
46
|
-
replacementss = [
|
|
47
|
-
[TAGS.BACKEND_FUNC, `return (void 0);`],
|
|
48
|
-
TAGS.BACKEND
|
|
49
|
-
];
|
|
23
|
+
matchEndRegion(l) {
|
|
24
|
+
const res = !___NS__isUndefined(this.END_REGION.find(r => l.match(r)));
|
|
25
|
+
return res;
|
|
50
26
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const res = !___NS__isUndefined(this.START_REGION.find((r) => l.match(r)));
|
|
62
|
-
return res;
|
|
63
|
-
}
|
|
64
|
-
matchEndRegion(l) {
|
|
65
|
-
const res = !___NS__isUndefined(this.END_REGION.find((r) => l.match(r)));
|
|
66
|
-
return res;
|
|
67
|
-
}
|
|
68
|
-
tree(node) {
|
|
69
|
-
const contentLines = node.contentLines;
|
|
70
|
-
let stack = 0;
|
|
71
|
-
for (let i = 0; i < contentLines.length; i++) {
|
|
72
|
-
const l = contentLines[i];
|
|
73
|
-
if (!node.isRoot) {
|
|
74
|
-
if (i === 0) {
|
|
75
|
-
node.addNormalLine(l, 0);
|
|
76
|
-
continue;
|
|
27
|
+
constructor(realtiveOrAbsFilePAth, fileExtension, content, replacementss, // Models.dev.Replacement[],
|
|
28
|
+
project) {
|
|
29
|
+
this.realtiveOrAbsFilePAth = realtiveOrAbsFilePAth;
|
|
30
|
+
this.content = content;
|
|
31
|
+
this.project = project;
|
|
32
|
+
this.START_REGION = [];
|
|
33
|
+
this.END_REGION = [];
|
|
34
|
+
if (REGEX_REGION.TS_JS_SCSS_SASS.EXT.includes(fileExtension)) {
|
|
35
|
+
this.START_REGION.push(REGEX_REGION.TS_JS_SCSS_SASS.START);
|
|
36
|
+
this.END_REGION.push(REGEX_REGION.TS_JS_SCSS_SASS.END);
|
|
77
37
|
}
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
38
|
+
if (REGEX_REGION.HTML.EXT.includes(fileExtension)) {
|
|
39
|
+
this.START_REGION.push(REGEX_REGION.HTML.START);
|
|
40
|
+
this.END_REGION.push(REGEX_REGION.HTML.END);
|
|
81
41
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
42
|
+
if (REGEX_REGION.CSS.EXT.includes(fileExtension)) {
|
|
43
|
+
this.START_REGION.push(REGEX_REGION.CSS.START);
|
|
44
|
+
this.END_REGION.push(REGEX_REGION.CSS.END);
|
|
45
|
+
}
|
|
46
|
+
this.content =
|
|
47
|
+
UtilsTypescript__NS__removeTaggedImportExport(this.content, replacementss) || '';
|
|
48
|
+
const lines = this.content.split('\n');
|
|
49
|
+
this.root = new Region(this, replacementss, void 0, 0, lines.length - 1, ___NS__first(lines), ___NS__last(lines), lines);
|
|
50
|
+
this.tree(this.root);
|
|
51
|
+
}
|
|
52
|
+
tree(node) {
|
|
53
|
+
const contentLines = node.contentLines;
|
|
54
|
+
// if (contentLines.length <= 3) {
|
|
55
|
+
// for (let i = 0; i < contentLines.length; i++) {
|
|
56
|
+
// const l = contentLines[i];
|
|
57
|
+
// node.addNormalLine(l, i);
|
|
58
|
+
// }
|
|
59
|
+
// } else {
|
|
60
|
+
let stack = 0;
|
|
61
|
+
for (let i = 0; i < contentLines.length; i++) {
|
|
62
|
+
const l = contentLines[i];
|
|
63
|
+
if (!node.isRoot) {
|
|
64
|
+
if (i === 0) {
|
|
65
|
+
node.addNormalLine(l, 0);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (i === node.contentLines.length - 1) {
|
|
69
|
+
node.addNormalLine(l, i);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (node.lastRegionWithoutEnd) {
|
|
74
|
+
if (this.matchStartRegion(l)) {
|
|
75
|
+
node.addNormalLineToLastRegion(l, i);
|
|
76
|
+
stack++;
|
|
77
|
+
}
|
|
78
|
+
else if (this.matchEndRegion(l)) {
|
|
79
|
+
if (stack === 0) {
|
|
80
|
+
node.endLastRegion(i, l);
|
|
81
|
+
}
|
|
82
|
+
else if (stack > 0) {
|
|
83
|
+
node.addNormalLineToLastRegion(l, i);
|
|
84
|
+
stack--;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
if (i === node.contentLines.length - (node.isRoot ? 1 : 2)) {
|
|
89
|
+
stack = 0;
|
|
90
|
+
node.endLastRegion(i, l);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
node.addNormalLineToLastRegion(l, i);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
if (this.matchStartRegion(l)) {
|
|
99
|
+
node.addRegion(this, node, i, l);
|
|
100
|
+
}
|
|
101
|
+
else if (this.matchEndRegion(l)) {
|
|
102
|
+
node.addNormalLine(l, i);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
node.addNormalLine(l, i);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
101
108
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
// }
|
|
110
|
+
const children = node.regions;
|
|
111
|
+
if (children.length > 0) {
|
|
112
|
+
for (let index = 0; index < children.length; index++) {
|
|
113
|
+
const child = children[index];
|
|
114
|
+
this.tree(child);
|
|
115
|
+
}
|
|
109
116
|
}
|
|
110
|
-
}
|
|
111
117
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
for (let index = 0; index < children.length; index++) {
|
|
115
|
-
const child = children[index];
|
|
116
|
-
this.tree(child);
|
|
117
|
-
}
|
|
118
|
+
get output() {
|
|
119
|
+
return this.root.toString();
|
|
118
120
|
}
|
|
119
|
-
}
|
|
120
|
-
get output() {
|
|
121
|
-
return this.root.toString();
|
|
122
|
-
}
|
|
123
121
|
}
|
|
124
|
-
export {
|
|
125
|
-
RegionRemover
|
|
126
|
-
};
|
package/lib-prod/region.js
CHANGED
|
@@ -1,160 +1,180 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return this.endIndex !== void 0;
|
|
18
|
-
}
|
|
19
|
-
get lastRegionWithoutEnd() {
|
|
20
|
-
const last = ___NS__last(this.regionsOrStrings);
|
|
21
|
-
if (last instanceof Region && !last.hasEnd) {
|
|
22
|
-
return last;
|
|
1
|
+
//#region imports
|
|
2
|
+
import { ___NS__first, ___NS__isArray, ___NS__last, ___NS__times } from 'tnp-core/lib-prod';
|
|
3
|
+
import { TAGS } from 'tnp-core/lib-prod';
|
|
4
|
+
import { labelReplacementCode } from './models';
|
|
5
|
+
//#endregion
|
|
6
|
+
export class Region {
|
|
7
|
+
constructor(context, replacementss, parent, startIndex, endIndex, lineStart, lineEnd, contentLines = []) {
|
|
8
|
+
this.context = context;
|
|
9
|
+
this.replacementss = replacementss;
|
|
10
|
+
this.parent = parent;
|
|
11
|
+
this.startIndex = startIndex;
|
|
12
|
+
this.endIndex = endIndex;
|
|
13
|
+
this.lineStart = lineStart;
|
|
14
|
+
this.lineEnd = lineEnd;
|
|
15
|
+
this.contentLines = contentLines;
|
|
16
|
+
this.regionsOrStrings = [];
|
|
23
17
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
regionsOrStrings = [];
|
|
27
|
-
get regions() {
|
|
28
|
-
return this.regionsOrStrings.filter((f) => f instanceof Region);
|
|
29
|
-
}
|
|
30
|
-
setEnd(endIndex, lineEnd) {
|
|
31
|
-
this.endIndex = endIndex;
|
|
32
|
-
this.lineEnd = lineEnd;
|
|
33
|
-
}
|
|
34
|
-
get isRoot() {
|
|
35
|
-
return !this.parent;
|
|
36
|
-
}
|
|
37
|
-
addNormalLine(l, lineIndex) {
|
|
38
|
-
this.contentLines[lineIndex] = void 0;
|
|
39
|
-
this.regionsOrStrings.push(l);
|
|
40
|
-
}
|
|
41
|
-
addNormalLineToLastRegion(l, lineIndex) {
|
|
42
|
-
this.contentLines[lineIndex] = void 0;
|
|
43
|
-
this.lastRegionWithoutEnd.contentLines.push(l);
|
|
44
|
-
}
|
|
45
|
-
addRegion(context, parent, startIndex, lineStart) {
|
|
46
|
-
this.contentLines[startIndex] = void 0;
|
|
47
|
-
const newReg = new Region(
|
|
48
|
-
context,
|
|
49
|
-
this.replacementss,
|
|
50
|
-
parent,
|
|
51
|
-
startIndex,
|
|
52
|
-
void 0,
|
|
53
|
-
lineStart,
|
|
54
|
-
void 0,
|
|
55
|
-
[lineStart]
|
|
56
|
-
);
|
|
57
|
-
this.regionsOrStrings.push(newReg);
|
|
58
|
-
}
|
|
59
|
-
endLastRegion(endIndex, lineEnd) {
|
|
60
|
-
this.contentLines[endIndex] = void 0;
|
|
61
|
-
const regionWithoutEnd = this.regionsOrStrings.find(
|
|
62
|
-
(r) => r instanceof Region && !r.hasEnd
|
|
63
|
-
);
|
|
64
|
-
regionWithoutEnd.contentLines.push(lineEnd);
|
|
65
|
-
regionWithoutEnd.setEnd(endIndex, lineEnd);
|
|
66
|
-
}
|
|
67
|
-
containsTitle(s) {
|
|
68
|
-
const res = this.titleString.search(s) !== -1;
|
|
69
|
-
return res;
|
|
70
|
-
}
|
|
71
|
-
get titleString() {
|
|
72
|
-
let line = this.lineStart;
|
|
73
|
-
const regionWord = "#region";
|
|
74
|
-
const indexOfRegion = line.search(regionWord);
|
|
75
|
-
line = line.replace(line.slice(0, indexOfRegion + regionWord.length), "");
|
|
76
|
-
return line.replace("-->", "").replace("<!--", "");
|
|
77
|
-
}
|
|
78
|
-
toString() {
|
|
79
|
-
if (this.tmpOutput !== void 0) {
|
|
80
|
-
return this.tmpOutput;
|
|
18
|
+
get hasEnd() {
|
|
19
|
+
return this.endIndex !== void 0;
|
|
81
20
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
for (let index = 0; index < replacements.length; index++) {
|
|
87
|
-
const rep = replacements[index];
|
|
88
|
-
const isArr = ___NS__isArray(replacements[index]);
|
|
89
|
-
const regionTag = isArr ? ___NS__first(rep) : rep;
|
|
90
|
-
let out = isArr ? rep[1] : "";
|
|
91
|
-
const verticalLength = regionOrString.toString().split("\n").length - 1;
|
|
92
|
-
if (regionOrString.containsTitle(regionTag)) {
|
|
93
|
-
if (regionTag.toLowerCase() === TAGS.WEBSQL.toLowerCase()) {
|
|
94
|
-
out = `${___NS__times(verticalLength).map(() => labelReplacementCode.backendCode + "\n").join("")} ${out}`;
|
|
95
|
-
}
|
|
96
|
-
if (regionTag.toLowerCase() === TAGS.BACKEND.toLowerCase()) {
|
|
97
|
-
out = `${___NS__times(verticalLength).map(() => labelReplacementCode.backendCode + "\n").join("")} ${out}`;
|
|
98
|
-
}
|
|
99
|
-
if (regionTag.toLowerCase() === TAGS.NOT_FOR_NPM.toLowerCase()) {
|
|
100
|
-
out = `${___NS__times(verticalLength).map(() => labelReplacementCode.notForNpmCode + "\n").join("")} ${out}`;
|
|
101
|
-
}
|
|
102
|
-
if (regionTag.toLowerCase() === TAGS.BROWSER.toLowerCase()) {
|
|
103
|
-
out = `${___NS__times(verticalLength).map(() => labelReplacementCode.browserCode + "\n").join("")} ${out}`;
|
|
104
|
-
}
|
|
105
|
-
if (regionTag.toLowerCase() === TAGS.WEBSQL_ONLY.toLowerCase()) {
|
|
106
|
-
out = `${___NS__times(verticalLength).map(() => labelReplacementCode.backendCode + "\n").join("")} ${out}`;
|
|
107
|
-
}
|
|
108
|
-
if (regionTag.toLowerCase() === TAGS.BACKEND_FUNC.toLowerCase()) {
|
|
109
|
-
let spacesPrevious = previous.search(/\S/);
|
|
110
|
-
spacesPrevious = spacesPrevious < 0 ? 0 : spacesPrevious;
|
|
111
|
-
out = `${___NS__times(verticalLength).map(() => labelReplacementCode.backendCode + "\n").join("")}${___NS__times(spacesPrevious).map((n) => " ").join("")} ${out}`;
|
|
112
|
-
}
|
|
113
|
-
if (regionTag.toLowerCase() === TAGS.WEBSQL_FUNC.toLowerCase()) {
|
|
114
|
-
let spacesPrevious = previous.search(/\S/);
|
|
115
|
-
spacesPrevious = spacesPrevious < 0 ? 0 : spacesPrevious;
|
|
116
|
-
out = `${___NS__times(verticalLength).map(() => labelReplacementCode.backendCode + "\n").join("")}${___NS__times(spacesPrevious).map((n) => " ").join("")} ${out}`;
|
|
117
|
-
}
|
|
118
|
-
if (regionTag.toLowerCase() === TAGS.CUT_CODE_IF_TRUE.toLowerCase() || regionTag.toLowerCase() === TAGS.CUT_CODE_IF_FALSE.toLowerCase()) {
|
|
119
|
-
const fn = out;
|
|
120
|
-
let expressionToExecute = regionOrString.titleString;
|
|
121
|
-
expressionToExecute = expressionToExecute.replace(
|
|
122
|
-
regionTag,
|
|
123
|
-
""
|
|
124
|
-
);
|
|
125
|
-
const configForProject = this.project && this.project.env.config;
|
|
126
|
-
const cutCode = fn(
|
|
127
|
-
expressionToExecute,
|
|
128
|
-
configForProject,
|
|
129
|
-
this.realtiveOrAbsFilePAth
|
|
130
|
-
);
|
|
131
|
-
if (cutCode === null) {
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
if (cutCode && regionTag.toLowerCase() === TAGS.CUT_CODE_IF_TRUE.toLowerCase() || !cutCode && regionTag.toLowerCase() === TAGS.CUT_CODE_IF_FALSE.toLowerCase()) {
|
|
135
|
-
out = "";
|
|
136
|
-
} else {
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
regionOrString.tmpOutput = out;
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
21
|
+
get lastRegionWithoutEnd() {
|
|
22
|
+
const last = ___NS__last(this.regionsOrStrings);
|
|
23
|
+
if (last instanceof Region && !last.hasEnd) {
|
|
24
|
+
return last;
|
|
143
25
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
get regions() {
|
|
29
|
+
return this.regionsOrStrings.filter(f => f instanceof Region);
|
|
30
|
+
}
|
|
31
|
+
setEnd(endIndex, lineEnd) {
|
|
32
|
+
this.endIndex = endIndex;
|
|
33
|
+
this.lineEnd = lineEnd;
|
|
34
|
+
}
|
|
35
|
+
get isRoot() {
|
|
36
|
+
return !this.parent;
|
|
37
|
+
}
|
|
38
|
+
addNormalLine(l, lineIndex) {
|
|
39
|
+
this.contentLines[lineIndex] = void 0;
|
|
40
|
+
this.regionsOrStrings.push(l);
|
|
41
|
+
}
|
|
42
|
+
addNormalLineToLastRegion(l, lineIndex) {
|
|
43
|
+
this.contentLines[lineIndex] = void 0;
|
|
44
|
+
this.lastRegionWithoutEnd.contentLines.push(l);
|
|
45
|
+
}
|
|
46
|
+
addRegion(context, parent, startIndex, lineStart) {
|
|
47
|
+
this.contentLines[startIndex] = void 0;
|
|
48
|
+
const newReg = new Region(context, this.replacementss, parent, startIndex, void 0, lineStart, void 0, [lineStart]);
|
|
49
|
+
this.regionsOrStrings.push(newReg);
|
|
50
|
+
}
|
|
51
|
+
endLastRegion(endIndex, lineEnd) {
|
|
52
|
+
this.contentLines[endIndex] = void 0;
|
|
53
|
+
const regionWithoutEnd = this.regionsOrStrings.find(r => r instanceof Region && !r.hasEnd);
|
|
54
|
+
regionWithoutEnd.contentLines.push(lineEnd);
|
|
55
|
+
regionWithoutEnd.setEnd(endIndex, lineEnd);
|
|
56
|
+
}
|
|
57
|
+
containsTitle(s) {
|
|
58
|
+
const res = this.titleString.search(s) !== -1;
|
|
59
|
+
// Helpers__NS__log(`checking tag (${res}): "${s}" in line: "${this.titleString}"`)
|
|
60
|
+
return res;
|
|
61
|
+
}
|
|
62
|
+
get titleString() {
|
|
63
|
+
let line = this.lineStart;
|
|
64
|
+
const regionWord = '#region';
|
|
65
|
+
const indexOfRegion = line.search(regionWord);
|
|
66
|
+
line = line.replace(line.slice(0, indexOfRegion + regionWord.length), '');
|
|
67
|
+
return line.replace('-->', '').replace('<!--', ''); // TODO not necessery ?
|
|
68
|
+
}
|
|
69
|
+
toString() {
|
|
70
|
+
if (this.tmpOutput !== void 0) {
|
|
71
|
+
return this.tmpOutput;
|
|
72
|
+
}
|
|
73
|
+
let previous = '';
|
|
74
|
+
this.tmpOutput = this.regionsOrStrings
|
|
75
|
+
.map(regionOrString => {
|
|
76
|
+
if (regionOrString instanceof Region) {
|
|
77
|
+
//#region handle region
|
|
78
|
+
const replacements = this.replacementss;
|
|
79
|
+
for (let index = 0; index < replacements.length; index++) {
|
|
80
|
+
const rep = replacements[index];
|
|
81
|
+
const isArr = ___NS__isArray(replacements[index]);
|
|
82
|
+
const regionTag = (isArr ? ___NS__first(rep) : rep);
|
|
83
|
+
let out = (isArr ? rep[1] : '');
|
|
84
|
+
const verticalLength = regionOrString.toString().split('\n').length - 1;
|
|
85
|
+
if (regionOrString.containsTitle(regionTag)) {
|
|
86
|
+
if (regionTag.toLowerCase() === TAGS.WEBSQL.toLowerCase()) {
|
|
87
|
+
out = `${___NS__times(verticalLength)
|
|
88
|
+
.map(() => labelReplacementCode.backendCode + '\n')
|
|
89
|
+
.join('')} ${out}`;
|
|
90
|
+
}
|
|
91
|
+
if (regionTag.toLowerCase() === TAGS.BACKEND.toLowerCase()) {
|
|
92
|
+
out = `${___NS__times(verticalLength)
|
|
93
|
+
.map(() => labelReplacementCode.backendCode + '\n')
|
|
94
|
+
.join('')} ${out}`;
|
|
95
|
+
}
|
|
96
|
+
if (regionTag.toLowerCase() === TAGS.NOT_FOR_NPM.toLowerCase()) {
|
|
97
|
+
out = `${___NS__times(verticalLength)
|
|
98
|
+
.map(() => labelReplacementCode.notForNpmCode + '\n')
|
|
99
|
+
.join('')} ${out}`;
|
|
100
|
+
}
|
|
101
|
+
if (regionTag.toLowerCase() === TAGS.BROWSER.toLowerCase()) {
|
|
102
|
+
out = `${___NS__times(verticalLength)
|
|
103
|
+
.map(() => labelReplacementCode.browserCode + '\n')
|
|
104
|
+
.join('')} ${out}`;
|
|
105
|
+
}
|
|
106
|
+
if (regionTag.toLowerCase() === TAGS.WEBSQL_ONLY.toLowerCase()) {
|
|
107
|
+
out = `${___NS__times(verticalLength)
|
|
108
|
+
.map(() => labelReplacementCode.backendCode + '\n')
|
|
109
|
+
.join('')} ${out}`;
|
|
110
|
+
}
|
|
111
|
+
if (regionTag.toLowerCase() === TAGS.BACKEND_FUNC.toLowerCase()) {
|
|
112
|
+
let spacesPrevious = previous.search(/\S/);
|
|
113
|
+
spacesPrevious = spacesPrevious < 0 ? 0 : spacesPrevious;
|
|
114
|
+
out =
|
|
115
|
+
`${___NS__times(verticalLength)
|
|
116
|
+
.map(() => labelReplacementCode.backendCode + '\n')
|
|
117
|
+
.join('')}` +
|
|
118
|
+
`${___NS__times(spacesPrevious)
|
|
119
|
+
.map(n => ' ')
|
|
120
|
+
.join('')} ${out}`;
|
|
121
|
+
}
|
|
122
|
+
if (regionTag.toLowerCase() === TAGS.WEBSQL_FUNC.toLowerCase()) {
|
|
123
|
+
let spacesPrevious = previous.search(/\S/);
|
|
124
|
+
spacesPrevious = spacesPrevious < 0 ? 0 : spacesPrevious;
|
|
125
|
+
out =
|
|
126
|
+
`${___NS__times(verticalLength)
|
|
127
|
+
.map(() => labelReplacementCode.backendCode + '\n')
|
|
128
|
+
.join('')}` +
|
|
129
|
+
`${___NS__times(spacesPrevious)
|
|
130
|
+
.map(n => ' ')
|
|
131
|
+
.join('')} ${out}`;
|
|
132
|
+
}
|
|
133
|
+
if (regionTag.toLowerCase() ===
|
|
134
|
+
TAGS.CUT_CODE_IF_TRUE.toLowerCase() ||
|
|
135
|
+
regionTag.toLowerCase() === TAGS.CUT_CODE_IF_FALSE.toLowerCase()) {
|
|
136
|
+
const fn = out; // as ReturnType<typeof codeCuttFn>;
|
|
137
|
+
let expressionToExecute = regionOrString.titleString;
|
|
138
|
+
// Helpers__NS__log(`LINE: "${regionOrString.lineStart}"`);
|
|
139
|
+
expressionToExecute = expressionToExecute.replace(regionTag, '');
|
|
140
|
+
// Helpers__NS__log(`Expresion to evaluate "${expressionToExecute}"`);
|
|
141
|
+
// Helpers__NS__log(`this.project "${this.project.name}"`);
|
|
142
|
+
const configForProject = this.project && this.project.env.config;
|
|
143
|
+
// Helpers__NS__log(`configForProject "${configForProject}"`);
|
|
144
|
+
const cutCode = fn(expressionToExecute, configForProject, this.realtiveOrAbsFilePAth);
|
|
145
|
+
// Helpers__NS__info(`Cut code: "${cutCode}"`);
|
|
146
|
+
if (cutCode === null) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if ((cutCode &&
|
|
150
|
+
regionTag.toLowerCase() ===
|
|
151
|
+
TAGS.CUT_CODE_IF_TRUE.toLowerCase()) ||
|
|
152
|
+
(!cutCode &&
|
|
153
|
+
regionTag.toLowerCase() ===
|
|
154
|
+
TAGS.CUT_CODE_IF_FALSE.toLowerCase())) {
|
|
155
|
+
out = '';
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
regionOrString.tmpOutput = out;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
}
|
|
167
|
+
const res = regionOrString.toString();
|
|
168
|
+
previous = res;
|
|
169
|
+
return res;
|
|
170
|
+
})
|
|
171
|
+
.join('\n');
|
|
172
|
+
return this.tmpOutput;
|
|
173
|
+
}
|
|
174
|
+
get project() {
|
|
175
|
+
return this.context.project;
|
|
176
|
+
}
|
|
177
|
+
get realtiveOrAbsFilePAth() {
|
|
178
|
+
return this.context.realtiveOrAbsFilePAth;
|
|
179
|
+
}
|
|
157
180
|
}
|
|
158
|
-
export {
|
|
159
|
-
Region
|
|
160
|
-
};
|
package/package.json
CHANGED