@yr-lang/yr 0.1.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/BUGS.md +35 -0
- package/CNAME +1 -0
- package/LICENSE +42 -0
- package/README.md +21 -0
- package/lib/%build.yr +3 -0
- package/lib/%deploy.yr +7 -0
- package/lib/%gh-pages.yr +60 -0
- package/lib/%nvm.yr +18 -0
- package/lib/%serve.yr +7 -0
- package/lib/.yrrc +2 -0
- package/lib/Ciyr/A1.yr +25 -0
- package/lib/Ciyr/B1.yr +11 -0
- package/lib/Ciyr/B2.yr +0 -0
- package/lib/Ciyr/C1.yr +14 -0
- package/lib/Ciyr/C2.yr +5 -0
- package/lib/Ciyr/C2_2.yr +5 -0
- package/lib/Ciyr/a1.yr +23 -0
- package/lib/Ciyr/b1.yr +21 -0
- package/lib/Ciyr/c1.yr +18 -0
- package/lib/Yrci/&app.yr +1 -0
- package/lib/Yrci/&app2.yr +1 -0
- package/lib/Yrci/@m1.yr +7 -0
- package/lib/Yrci/@m2.yr +11 -0
- package/lib/Yrci/A1.yr +8 -0
- package/lib/Yrci/A2.yr +26 -0
- package/lib/Yrci/A3.yr +51 -0
- package/lib/Yrci/B1.yr +8 -0
- package/lib/Yrci/C1.yr +58 -0
- package/lib/Yrci/C1.yrr +14 -0
- package/lib/Yrci/C2.yr +17 -0
- package/lib/Yrci/C3.yr +28 -0
- package/lib/Yrci/C4.yr +4 -0
- package/lib/Yrci/C5.yr +3 -0
- package/lib/Yrci/C6.yr +7 -0
- package/lib/Yrci/C7.yr +3 -0
- package/lib/Yrci/C8.yr +3 -0
- package/lib/Yrci/C9.yr +11 -0
- package/lib/Yrci/Index_.yr +4 -0
- package/lib/Yrci/Login.yr +3 -0
- package/lib/Yrci/M1.yr +7 -0
- package/lib/Yrci/Sp.yr +5 -0
- package/lib/Yrci/T1.yr +4 -0
- package/lib/Yrci/T2.yr +4 -0
- package/lib/Yrci/Ta1.yr +4 -0
- package/lib/Yrci/Ta2.yr +4 -0
- package/lib/Yrci/Tg.yr +5 -0
- package/lib/Yrci/Wr.yr +7 -0
- package/lib/Yrci/Wrapper.yr +14 -0
- package/lib/Yrci/Wrapper1.yr +5 -0
- package/lib/Yrci/Wrapper2.yr +24 -0
- package/lib/Yrci/Wrapper3.yr +5 -0
- package/lib/Yrci/Wrapperext.yr +4 -0
- package/lib/Yrci/Wrt.yr +3 -0
- package/lib/Yrci/Yrwm.yr +32 -0
- package/lib/Yrci/a1.yr +18 -0
- package/lib/Yrci/a2.yr +10 -0
- package/lib/Yrci/app.yr +3 -0
- package/lib/Yrci/b2.yr +10 -0
- package/lib/Yrci/j1.yr +5 -0
- package/lib/Yrci/j2.yr +5 -0
- package/lib/Yrci/j3.yr +3 -0
- package/lib/Yrci/modal.yr +5 -0
- package/lib/bodyblock.yr +13 -0
- package/lib/ci.yr +21 -0
- package/lib/crypto.yr +13 -0
- package/lib/element.yr +358 -0
- package/lib/hidden.yr +9 -0
- package/lib/utils.yr +13 -0
- package/node.js +807 -0
- package/package.json +14 -0
- package/src/common.js +7 -0
- package/yr.js +1308 -0
package/yr.js
ADDED
|
@@ -0,0 +1,1308 @@
|
|
|
1
|
+
const crypto = {
|
|
2
|
+
generateToken(size=15, startWithNumber=false, complex=false) {
|
|
3
|
+
const chars =
|
|
4
|
+
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
5
|
+
let token = '';
|
|
6
|
+
for (let i = 0; i < size; i++)
|
|
7
|
+
token += chars[Math.floor(Math.random() * chars.length)];
|
|
8
|
+
return (!isNaN(parseInt(token[0])) && !startWithNumber)
|
|
9
|
+
? this.generateToken(size, startWithNumber, complex) : token;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const utils = {
|
|
14
|
+
capitalize(string) {
|
|
15
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const common = {
|
|
20
|
+
getWhiteSpace(indentation) {
|
|
21
|
+
try {
|
|
22
|
+
return new Array((indentation * 2) - 1).join(' ');
|
|
23
|
+
} catch(error) { return ''; }
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const namespaces = {
|
|
28
|
+
'@&': { name: 'jsapp', parser: 'array', default: [], merge: true },
|
|
29
|
+
'++': { name: 'wrappers', parser: 'auxstring', default: {}, merge: true },
|
|
30
|
+
'>+': { name: 'wrapperbody', parser: 'html', default: '', merge: true },
|
|
31
|
+
'><': { name: 'body', parser: 'html', default: '', merge: true },
|
|
32
|
+
'@>': { name: 'jsheader', parser: 'string', default: '', merge: true },
|
|
33
|
+
'@@': { name: 'js', parser: 'string', default: '', merge: true },
|
|
34
|
+
'@<': { name: 'jsfooter', parser: 'string', default: '', merge: true },
|
|
35
|
+
'>@': { name: 'wrapperjs', parser: 'string', default: '', merge: true },
|
|
36
|
+
'<@': { name: 'wrapperjscustom', parser: 'string', default: '', merge: true },
|
|
37
|
+
'""': { name: 'documentation', parser: 'string', default: '' },
|
|
38
|
+
'--': { name: 'modules', parser: 'object', default: [], merge: true },
|
|
39
|
+
'==': { name: 'pixel', parser: 'string', default: '', merge: true },
|
|
40
|
+
'>>': { name: 'header', parser: 'html', default: '', merge: true },
|
|
41
|
+
'<<': { name: 'footer', parser: 'html', default: '', merge: true },
|
|
42
|
+
'<>': { name: 'scripts', parser: 'html', default: '', merge: true },
|
|
43
|
+
'#>': { name: 'cssheader', parser: 'string', default: '', merge: true },
|
|
44
|
+
'##': { name: 'css', parser: 'string', default: '', merge: true },
|
|
45
|
+
'#<': { name: 'cssfooter', parser: 'string', default: '', merge: true },
|
|
46
|
+
'>#': { name: 'wrappercss', parser: 'string', default: '', merge: true },
|
|
47
|
+
'<#': { name: 'wrappercsscustom', parser: 'string', default: '', merge: true },
|
|
48
|
+
'|@': { name: 'jstests', parser: 'string', default: '', merge: true },
|
|
49
|
+
'||': { name: 'assert', parser: 'string', default: '', merge: true },
|
|
50
|
+
'&>': { name: 'appheader', parser: 'array', default: [], merge: true },
|
|
51
|
+
'&&': { name: 'app', parser: 'array', default: [], merge: true },
|
|
52
|
+
'&<': { name: 'appfooter', parser: 'array', default: [], merge: true },
|
|
53
|
+
'|&': { name: 'apptests', parser: 'array', default: [], merge: true },
|
|
54
|
+
'%%': { name: 'macros', parser: 'auxstring', default: {}, merge: true },
|
|
55
|
+
'**': { name: 'devops', parser: 'auxstring', default: [], merge: true }
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const _parsers = {}, defaults = {}, mergers = {}, names = {};
|
|
59
|
+
for (let item of Object.keys(namespaces)) {
|
|
60
|
+
names[namespaces[item].name] = item;
|
|
61
|
+
if (namespaces[item].parser)
|
|
62
|
+
_parsers[namespaces[item].name] = namespaces[item].parser;
|
|
63
|
+
if (namespaces[item].default || namespaces[item].default === '') {
|
|
64
|
+
defaults[namespaces[item].name] = namespaces[item].default;
|
|
65
|
+
if (namespaces[item].merge)
|
|
66
|
+
mergers[namespaces[item].name] = namespaces[item].default;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function parseLine(line) {
|
|
71
|
+
const indentation = line.search(/\S/);
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
indentation, line: line.trim(),
|
|
75
|
+
level: (indentation / 2) + 1,
|
|
76
|
+
whiteSpace: ' '.repeat(indentation)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function getElementAttributes(line) {
|
|
81
|
+
const attributes = {};
|
|
82
|
+
if (!line.includes(' att={{')) return attributes;
|
|
83
|
+
const parsedString = line.split(' att={{')[1].split('}}')[0];
|
|
84
|
+
const parse = {};
|
|
85
|
+
let parseKey = '', parseValue = '', parseType = 0, changedParseType = false;
|
|
86
|
+
let isString = false, shouldSplit = false, string = '';
|
|
87
|
+
let lastChar, stringKey;
|
|
88
|
+
for (let value of parsedString) {
|
|
89
|
+
if (value === ':' && parseType === 0 && !isString) {
|
|
90
|
+
parseType = 1;
|
|
91
|
+
isString = false;
|
|
92
|
+
changedParseType = true;
|
|
93
|
+
continue;
|
|
94
|
+
} else if (value === ',' && parseType === 1 && !isString) {
|
|
95
|
+
parseType = 0;
|
|
96
|
+
isString = false;
|
|
97
|
+
changedParseType = true;
|
|
98
|
+
parse[parseKey.trim()] = parseValue.trim();
|
|
99
|
+
parseKey = '';
|
|
100
|
+
parseValue = '';
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
changedParseType = false;
|
|
105
|
+
if (lastChar !== '\\' && value === '\\' && isString) {
|
|
106
|
+
lastChar = value;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if ((value === '"' || value === "'")
|
|
111
|
+
&& (stringKey === value || !stringKey)) {
|
|
112
|
+
if (lastChar === '\\' && isString) {
|
|
113
|
+
if (parseType === 0) {
|
|
114
|
+
parseKey += value;
|
|
115
|
+
} else if (parseType === 1) {
|
|
116
|
+
parseValue += value;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
lastChar = value;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (value === stringKey) {
|
|
124
|
+
isString = false;
|
|
125
|
+
stringKey = false;
|
|
126
|
+
continue;
|
|
127
|
+
} else if (!stringKey) {
|
|
128
|
+
isString = true;
|
|
129
|
+
stringKey = value;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (parseType === 0) {
|
|
135
|
+
parseKey += value;
|
|
136
|
+
} else if (parseType === 1) {
|
|
137
|
+
parseValue += value;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
lastChar = value;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
parse[parseKey.trim()] = parseValue.trim();
|
|
144
|
+
parseKey = '', parseValue = '';
|
|
145
|
+
return { ...attributes, ...parse };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function addIdToElement(line, config, elementId=false) {
|
|
149
|
+
if (config.preview && !line.includes('.__') && !line.includes('.{{__')) {
|
|
150
|
+
if (!elementId) elementId = '__' + crypto.generateToken(8);
|
|
151
|
+
if (!line.trim().startsWith('_')) elementId = '{{' + elementId;
|
|
152
|
+
|
|
153
|
+
let openCase, newLine = '', addedClass;
|
|
154
|
+
for (let item of line.split(' ')) {
|
|
155
|
+
if (item.endsWith('{{')) {
|
|
156
|
+
openCase = true;
|
|
157
|
+
newLine += item + ' ';
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (item.endsWith('}}') && openCase) {
|
|
162
|
+
openCase = false;
|
|
163
|
+
newLine += item + ' ';
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (!openCase && item.startsWith('.') && !addedClass) {
|
|
168
|
+
addedClass = true;
|
|
169
|
+
item = item.replace(/\./, `.${elementId}.`);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
newLine += item + ' ';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
newLine = newLine.trimEnd();
|
|
176
|
+
if (!addedClass) newLine += ` .${elementId}`;
|
|
177
|
+
line = newLine;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return line;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const parserFns = {
|
|
184
|
+
array(line, sections, section, state, lineNumber, config={}) {
|
|
185
|
+
if (state.sectionChanged) sections[section].push('')
|
|
186
|
+
sections[section][sections[section].length - 1] += line + '\n';
|
|
187
|
+
},
|
|
188
|
+
auxstring(line, sections, section, state, lineNumber, config={}) {
|
|
189
|
+
if (!sections[section + 'Aux']) sections[section + 'Aux'] = '';
|
|
190
|
+
sections[section + 'Aux'] += line + '\n';
|
|
191
|
+
},
|
|
192
|
+
nosection(line, sections, section, state, lineNumber, config={}) {
|
|
193
|
+
if (line.startsWith('--')) sections.modules =
|
|
194
|
+
[...sections.modules, ...line.slice(2).trim().split(',')];
|
|
195
|
+
},
|
|
196
|
+
string(line, sections, section, state, lineNumber, config={}) {
|
|
197
|
+
sections[section] += line + '\n';
|
|
198
|
+
},
|
|
199
|
+
html(line, sections, section, state, lineNumber, config={}) {
|
|
200
|
+
if (config.ignoreHtml) return;
|
|
201
|
+
if (!sections.yr[section]) sections.yr[section] = '';
|
|
202
|
+
const parsedLine = parseLine(line);
|
|
203
|
+
if (parsedLine.line.startsWith('//')) {
|
|
204
|
+
sections.yr[section] += line + '\n';
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (parsedLine.line.endsWith('\\\\')) {
|
|
208
|
+
if (state.lineBreak) {
|
|
209
|
+
state.lineBreak.line = state.lineBreak.line + parsedLine.line.slice(0, -2);
|
|
210
|
+
} else {
|
|
211
|
+
state.lineBreak =
|
|
212
|
+
{ ...parsedLine, line: parsedLine.line.slice(0, -2) };
|
|
213
|
+
}
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (state.lineBreak) {
|
|
217
|
+
parsedLine.line = state.lineBreak.line + parsedLine.line;
|
|
218
|
+
line = state.lineBreak.line + line;
|
|
219
|
+
state.lineBreak = false;
|
|
220
|
+
}
|
|
221
|
+
if (!state.level) state.level = 0;
|
|
222
|
+
let yrParsedLine = (parsedLine.line.split(' ')[0].includes('/')
|
|
223
|
+
&& !parsedLine.line.split(' ')[0].includes('_!') && parsedLine.line[0] === '_')
|
|
224
|
+
? parsedLine.line.replace(/_/, '_!') : parsedLine.line;
|
|
225
|
+
let elementId = '__' + crypto.generateToken(8);
|
|
226
|
+
if (parsedLine.line.includes('.__')) {
|
|
227
|
+
elementId = '__' + parsedLine.line
|
|
228
|
+
.split('.__')[1].split(' ')[0].split('.')[0];
|
|
229
|
+
} else if (!parsedLine.line.trim().startsWith('_')
|
|
230
|
+
&& parsedLine.line.includes('.{{__')) {
|
|
231
|
+
const split = parsedLine.line.split('.{{__');
|
|
232
|
+
elementId = '__' + split[1];
|
|
233
|
+
parsedLine.line = split[0].trimEnd();
|
|
234
|
+
}
|
|
235
|
+
yrParsedLine = addIdToElement(yrParsedLine, config, elementId);
|
|
236
|
+
let yrIndentation = 0, ignoreYr, wildCard = '', replaceYr;
|
|
237
|
+
if (state.wrapper.length > 0) {
|
|
238
|
+
let wrapper = state.wrapper[state.wrapper.length - 1];
|
|
239
|
+
if (parsedLine.indentation >= wrapper.reference) {
|
|
240
|
+
yrIndentation = wrapper.new - wrapper.reference + 2;
|
|
241
|
+
replaceYr = sections.yr[section].includes('#@#\n');
|
|
242
|
+
} else {
|
|
243
|
+
wrapper = state.wrapper[state.wrapper.length - 1];
|
|
244
|
+
sections.yr[section] = sections.yr[section].replace(/#@#\n/, '');
|
|
245
|
+
if (wrapper.wildCard) sections[section] += wrapper.wildCard + '\n';
|
|
246
|
+
state.wrapper.pop();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (yrIndentation < 0) yrIndentation = 0;
|
|
250
|
+
const parsedYr = parsedLine.whiteSpace
|
|
251
|
+
+ ' '.repeat(yrIndentation) + yrParsedLine.trim() + '\n';
|
|
252
|
+
if (replaceYr) {
|
|
253
|
+
sections.yr[section] = sections.yr[section]
|
|
254
|
+
.replace(/#@#\n/, parsedYr + '#@#\n');
|
|
255
|
+
} else {
|
|
256
|
+
sections.yr[section] += parsedYr;
|
|
257
|
+
}
|
|
258
|
+
if (parsedLine.indentation !== -1) {
|
|
259
|
+
if (parsedLine.indentation % 2 !== 0)
|
|
260
|
+
throw `-1: indentation error at line ${lineNumber}` + '';
|
|
261
|
+
` (${config.name}.yr, ${config.project}):\n\n"""\n${line}\n"""`;
|
|
262
|
+
if (parsedLine.level > state.level + 1)
|
|
263
|
+
throw `-2: indentation error at line ${lineNumber}` + '' +
|
|
264
|
+
` (${config.name}.yr, ${config.project}):\n\n"""\n${line}\n"""`;
|
|
265
|
+
if (parsedLine.level < state.level) {
|
|
266
|
+
for (let j = state.layers.length; j > parsedLine.level - 1; j--) {
|
|
267
|
+
if (!state.layers[j - 1]) continue;
|
|
268
|
+
sections[state.layers[j - 1].section] +=
|
|
269
|
+
state.layers[j - 1].whiteSpace + `</${state.layers[j - 1].tag}>\n`;
|
|
270
|
+
state.layers.pop();
|
|
271
|
+
}
|
|
272
|
+
} else if (parsedLine.level === state.level
|
|
273
|
+
&& state.element && state.layers.length > 0) {
|
|
274
|
+
sections[state.layers[state.layers.length - 1].section] +=
|
|
275
|
+
`</${state.layers[state.layers.length - 1].tag}>\n`;
|
|
276
|
+
state.layers.pop();
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (state.layers.length > 0 && (state.sectionChanged
|
|
280
|
+
|| state.layers[state.layers.length - 1].indentation === parsedLine.indentation)) {
|
|
281
|
+
for (let j = state.layers.length - 1; j >= 0; j--) {
|
|
282
|
+
if (j === -1) continue;
|
|
283
|
+
sections[state.layers[j].section] +=
|
|
284
|
+
state.layers[j].whiteSpace + `</${state.layers[j].tag}>\n`;
|
|
285
|
+
state.layers.pop();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (parsedLine.line[0] === '_') {
|
|
289
|
+
const elementAttributes = getElementAttributes(parsedLine.line);
|
|
290
|
+
const attSplit = parsedLine.line.split(' att={{');
|
|
291
|
+
if (attSplit.length > 1)
|
|
292
|
+
parsedLine.line = attSplit[0] + attSplit[1].split('}}')[1];
|
|
293
|
+
const lineSplit = parsedLine.line.split(' ');
|
|
294
|
+
let tag = lineSplit.shift().substring(1);
|
|
295
|
+
if (tag === '') tag = 'div';
|
|
296
|
+
if (tag[0] === '_') {
|
|
297
|
+
tag = tag.replace(/__/, '');
|
|
298
|
+
if (!tag) tag = 'div';
|
|
299
|
+
wildCard += '<!--#@#-->';
|
|
300
|
+
}
|
|
301
|
+
let attributes = '', id = '', classes = '';
|
|
302
|
+
for (let item of lineSplit) {
|
|
303
|
+
if (item.startsWith('#')) {
|
|
304
|
+
id = ` id="${item.substring(1)}"`;
|
|
305
|
+
} else if (item.startsWith('.')) {
|
|
306
|
+
let ignoreCrypto;
|
|
307
|
+
if (item.includes('.__')) {
|
|
308
|
+
for (let value of item.split('\.')) {
|
|
309
|
+
if (value.startsWith('__')) {
|
|
310
|
+
ignoreCrypto = true;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
classes = ` class="${item.substring(1).split('.').join(' ')}"`;
|
|
316
|
+
} else {
|
|
317
|
+
attributes += ` ${item}`;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (tag.includes('/')) {
|
|
321
|
+
const wrapper = tag.replace(/!/, '').split('/');
|
|
322
|
+
wrapper[0] = utils.capitalize(wrapper[0]);
|
|
323
|
+
wrapper[1] = utils.capitalize(wrapper[1]);
|
|
324
|
+
const wrapperName = wrapper.join('/');
|
|
325
|
+
core.extend(wrapper, wrapperName, sections, state, { redoWrapper: true });
|
|
326
|
+
let newWrapper, wrapperIndentation;
|
|
327
|
+
if (!tag.includes('!')) {
|
|
328
|
+
newWrapper = {
|
|
329
|
+
section, reference: parsedLine.indentation + 2,
|
|
330
|
+
new: parsedLine.indentation, content: '', wildCard: '',
|
|
331
|
+
layers: JSON.parse(JSON.stringify(state.layers))
|
|
332
|
+
};
|
|
333
|
+
state.wrapper.push(newWrapper);
|
|
334
|
+
wrapperIndentation = parsedLine.indentation;
|
|
335
|
+
}
|
|
336
|
+
if (sections.wrappers[wrapperName]) {
|
|
337
|
+
elementAttributes.id = elementId;
|
|
338
|
+
elementAttributes.category = wrapper[0];
|
|
339
|
+
elementAttributes.option = wrapper[1];
|
|
340
|
+
let attributes = [];
|
|
341
|
+
try {
|
|
342
|
+
attributes = sections.wrappers[wrapperName].vars.attributes;
|
|
343
|
+
} catch(error) {
|
|
344
|
+
console.log(wrapperName);
|
|
345
|
+
console.log(sections.wrappers[wrapperName]);
|
|
346
|
+
console.log(parsedLine);
|
|
347
|
+
console.log(error);
|
|
348
|
+
throw error;
|
|
349
|
+
}
|
|
350
|
+
if (!attributes) attributes = sections.vars.attributes;
|
|
351
|
+
elementAttributes.attributes = attributes;
|
|
352
|
+
let redone;
|
|
353
|
+
try {
|
|
354
|
+
redone = !sections.wrappers[wrapperName].redone;
|
|
355
|
+
} catch(error) {/* pass */}
|
|
356
|
+
if (sections.jsheader
|
|
357
|
+
.includes(`function __${wrapperName.replace(/\//, '_')}(`)
|
|
358
|
+
&& !sections.wrapperjs.includes(`"id":"${elementId}"`)) {
|
|
359
|
+
const wrapperjs =
|
|
360
|
+
`__${wrapperName.replace(/\//, '_')}(${JSON.stringify(elementAttributes)});\n`;
|
|
361
|
+
sections.wrapperjs += wrapperjs;
|
|
362
|
+
}
|
|
363
|
+
if (!tag.includes('!')) {
|
|
364
|
+
if (sections.wrappers[wrapperName].yrwrapperbody) {
|
|
365
|
+
for (let value of sections.wrappers[wrapperName]
|
|
366
|
+
.yrwrapperbody.split('\n')) {
|
|
367
|
+
if (value.trim() === '') continue;
|
|
368
|
+
value = addIdToElement(value, config);
|
|
369
|
+
if (yrIndentation % 2 !== 0) yrIndentation -= 1;
|
|
370
|
+
if (newWrapper.reference % 2 !== 0) newWrapper.reference -= 1;
|
|
371
|
+
if (newWrapper.new % 2 !== 0) newWrapper.new -= 1;
|
|
372
|
+
value = ' '.repeat(newWrapper.reference + yrIndentation)
|
|
373
|
+
+ value + '\n';
|
|
374
|
+
if (value.includes('___')) {
|
|
375
|
+
value = value.replace(/___/, '_');
|
|
376
|
+
value += '#@#\n';
|
|
377
|
+
newWrapper.new = value.search(/\S/);
|
|
378
|
+
}
|
|
379
|
+
sections.yr[section] += value;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (sections.wrappers[wrapperName].wrapperbody) {
|
|
383
|
+
const split = sections.wrappers[wrapperName].wrapperbody.split('<!--#@#-->\n');
|
|
384
|
+
if (split[1]) newWrapper.wildCard = split[1];
|
|
385
|
+
for (let _line of split[0].split('\n'))
|
|
386
|
+
wildCard += ' '.repeat(yrIndentation) + _line + '\n';
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
tag = 'div';
|
|
391
|
+
if (!classes) {
|
|
392
|
+
classes = ` class="${elementId}"`;
|
|
393
|
+
} else if (!classes.includes(elementId)) {
|
|
394
|
+
classes = classes.split('class="').join(`class="${elementId} `);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
if (config.preview) {
|
|
398
|
+
if (!classes) {
|
|
399
|
+
classes = ` class="${elementId}"`;
|
|
400
|
+
} else if (!classes.includes(elementId)) {
|
|
401
|
+
classes = classes.split('class="').join(`class="${elementId} `);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
attributes = `${id}${classes}${attributes}`.trim();
|
|
405
|
+
sections[section] += ' '.repeat(yrIndentation) + parsedLine.whiteSpace +
|
|
406
|
+
`<${tag} ${attributes}>\n${wildCard}\n`;
|
|
407
|
+
state.layers.push({ tag, section, ...parsedLine });
|
|
408
|
+
state.element = true;
|
|
409
|
+
} else {
|
|
410
|
+
if (section) {
|
|
411
|
+
if (section === 'header') {
|
|
412
|
+
sections[section] += parsedLine.whiteSpace + parsedLine.line + '\n';
|
|
413
|
+
} else {
|
|
414
|
+
let attributes = '';
|
|
415
|
+
if (config.preview) elementId += ' _yrtext';
|
|
416
|
+
sections[section] +=
|
|
417
|
+
`${parsedLine.whiteSpace}<span class="${elementId}"${attributes}>${parsedLine.line}</span>\n`;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
state.element = false;
|
|
421
|
+
}
|
|
422
|
+
state.level = parsedLine.level;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
const parsers = {
|
|
427
|
+
namespaces, tokens: Object.keys(namespaces),
|
|
428
|
+
parsers: _parsers, mergers, names,
|
|
429
|
+
defaults() { return JSON.parse(JSON.stringify(defaults)); },
|
|
430
|
+
parse(parser, line, sections, section, state, lineNumber, config) {
|
|
431
|
+
if (line === '') return;
|
|
432
|
+
const parserFn = parserFns[parser];
|
|
433
|
+
if (!parserFn) return;
|
|
434
|
+
parserFn(line, sections, section, state, lineNumber, config);
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
const core = {
|
|
439
|
+
set(libFn) { this.lib = libFn },
|
|
440
|
+
lib(category=false, option=false, parseConfig=false) {
|
|
441
|
+
return { yr: '++\n\n_' };
|
|
442
|
+
},
|
|
443
|
+
macros(sections, key, obfuscate=false) {
|
|
444
|
+
if (key === 'yr' || !sections[key]) return sections[key];
|
|
445
|
+
const currentMacros = [];
|
|
446
|
+
let parsedCode = '';
|
|
447
|
+
|
|
448
|
+
for (let line of sections[key].split('\n')) {
|
|
449
|
+
if (line === '') continue;
|
|
450
|
+
|
|
451
|
+
if (line.trim() === '@}') {
|
|
452
|
+
const currentMacro = currentMacros[currentMacros.length - 1];
|
|
453
|
+
|
|
454
|
+
if (!currentMacro) {
|
|
455
|
+
console.log(-1, 'error', key, sections[key]);
|
|
456
|
+
console.log(-2, 'error', sections.macros);
|
|
457
|
+
console.log(-3, currentMacros);
|
|
458
|
+
console.log(-4, sections.extensions);
|
|
459
|
+
throw 'macro called but not required, verify your files';
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
const macro = sections.macros[currentMacro.name];
|
|
463
|
+
let newMacro = macro.content + '\n';
|
|
464
|
+
|
|
465
|
+
for (let index in macro.variables) {
|
|
466
|
+
let variable = currentMacro.variables[index];
|
|
467
|
+
|
|
468
|
+
if (!variable) {
|
|
469
|
+
variable = (macro.variables[index].includes('='))
|
|
470
|
+
? macro.variables[index].split('=')[1] : 'false';
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
newMacro = newMacro
|
|
474
|
+
.split(macro.variables[index].split('=')[0]).join(variable);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
newMacro = (newMacro.includes('___'))
|
|
478
|
+
? newMacro.split('___').join(currentMacro.content)
|
|
479
|
+
: newMacro + '\n' + currentMacro.content + '\n';
|
|
480
|
+
|
|
481
|
+
if (currentMacros.length > 1) {
|
|
482
|
+
currentMacros[currentMacros.length - 2].content += '\n' + newMacro;
|
|
483
|
+
} else {
|
|
484
|
+
parsedCode += '\n' + newMacro;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
currentMacros.pop();
|
|
488
|
+
} else if (line.trim().startsWith('_@')) {
|
|
489
|
+
line = line.replace(/ /g, '');
|
|
490
|
+
|
|
491
|
+
const name = line.split('(')[0];
|
|
492
|
+
if (!Object.keys(sections.macros).includes(name)) continue;
|
|
493
|
+
|
|
494
|
+
let variables = line.split(`${name}(`)[1].slice(0, -2).split(',');
|
|
495
|
+
if (variables.length === 1 && variables[0] === '') variables = [];
|
|
496
|
+
|
|
497
|
+
currentMacros.push({ content: '', variables, name });
|
|
498
|
+
|
|
499
|
+
if (line.trim().endsWith(')') || line.trim().endsWith(');')) {
|
|
500
|
+
const currentMacro = currentMacros[currentMacros.length - 1];
|
|
501
|
+
|
|
502
|
+
if (!currentMacro) {
|
|
503
|
+
console.log(-3, 'error', sections[key]);
|
|
504
|
+
console.log(-4, 'error', sections.macros);
|
|
505
|
+
throw 'macro called but not required, verify your files';
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
const macro = sections.macros[currentMacro.name];
|
|
509
|
+
let newMacro = macro.content + '\n';
|
|
510
|
+
|
|
511
|
+
for (let index in macro.variables) {
|
|
512
|
+
let variable = currentMacro.variables[index];
|
|
513
|
+
|
|
514
|
+
if (!variable) {
|
|
515
|
+
variable = (macro.variables[index].includes('='))
|
|
516
|
+
? macro.variables[index].split('=')[1] : 'false';
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
newMacro = newMacro
|
|
520
|
+
.split(macro.variables[index].split('=')[0]).join(variable);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
newMacro = (newMacro.includes('___'))
|
|
524
|
+
? newMacro.split('___').join(currentMacro.content)
|
|
525
|
+
: newMacro + '\n' + currentMacro.content + '\n';
|
|
526
|
+
|
|
527
|
+
if (currentMacros.length > 1) {
|
|
528
|
+
currentMacros[currentMacros.length - 2].content += '\n' + newMacro;
|
|
529
|
+
} else {
|
|
530
|
+
parsedCode += '\n' + newMacro;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
currentMacros.pop();
|
|
534
|
+
}
|
|
535
|
+
} else if (currentMacros.length > 0) {
|
|
536
|
+
currentMacros[currentMacros.length - 1].content += line + '\n';
|
|
537
|
+
} else {
|
|
538
|
+
parsedCode += line + '\n';
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
sections[key] = parsedCode;
|
|
543
|
+
if (obfuscate) sections[key] = sections[key];//obfuscator.obfuscate(sections[key]);
|
|
544
|
+
return sections[key];
|
|
545
|
+
},
|
|
546
|
+
aux(sections, extension) {
|
|
547
|
+
if (extension.devopsAux) {
|
|
548
|
+
let counter = 0, devopsSection;
|
|
549
|
+
for (let line of extension.devopsAux.split('\n')) {
|
|
550
|
+
if (counter === 0) {
|
|
551
|
+
counter = 1;
|
|
552
|
+
sections.devops.push({});
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (line.startsWith('___')) {
|
|
556
|
+
devopsSection = line.substring(3);
|
|
557
|
+
counter = 0;
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
if (!devopsSection) devopsSection = 'build';
|
|
562
|
+
|
|
563
|
+
if (!sections.devops[sections.devops.length - 1][devopsSection])
|
|
564
|
+
sections.devops[sections.devops.length - 1][devopsSection] = '';
|
|
565
|
+
|
|
566
|
+
sections.devops[sections.devops.length - 1][devopsSection] +=
|
|
567
|
+
line + '\n';
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
if (extension.macrosAux) {
|
|
572
|
+
let counter = 0, macro = false;
|
|
573
|
+
for (let line of extension.macrosAux.split('\n')) {
|
|
574
|
+
if (line === '@}') {
|
|
575
|
+
if (counter === 1) {
|
|
576
|
+
counter = 0;
|
|
577
|
+
macro = false;
|
|
578
|
+
continue;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
counter--;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
if (line.startsWith('_@') && line.endsWith('{')) {
|
|
585
|
+
counter++;
|
|
586
|
+
|
|
587
|
+
if (counter === 1) {
|
|
588
|
+
line = line.replace(/ /g, '');
|
|
589
|
+
const name = line.split('(')[0];
|
|
590
|
+
let variables = line.split(`${name}(`)[1].slice(0, -2).split(',');
|
|
591
|
+
if (variables.length === 1 && variables[0] === '') variables = [];
|
|
592
|
+
sections.macros[name] = { content: '', variables };
|
|
593
|
+
macro = name;
|
|
594
|
+
continue;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
if (macro) sections.macros[macro].content += line + '\n';
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
extend(wrapper, wrapperName, sections, state, config={}) {
|
|
603
|
+
if (!sections.parsedyr)
|
|
604
|
+
sections.parsedyr = { header: '', body: '', footer: '', scripts: '' };
|
|
605
|
+
|
|
606
|
+
try {
|
|
607
|
+
if (wrapperName.startsWith('!')) {
|
|
608
|
+
wrapper[0] = wrapper[0].replace(/!/, '');
|
|
609
|
+
wrapper[1] = wrapper[1].replace(/!/, '');
|
|
610
|
+
wrapperName = wrapperName.replace(/!/, '');
|
|
611
|
+
config.ignoreHtml = true;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
if (!sections.wrapperjs) sections.wrapperjs = '';
|
|
615
|
+
|
|
616
|
+
if (sections.extensions.includes('!! ' + wrapperName + '\n')) {
|
|
617
|
+
if (config.redoWrapper) {
|
|
618
|
+
const newWrapper = this.parse(`>+\n\n_${wrapperName.toLowerCase()}`, {
|
|
619
|
+
ignoreHtml: config.ignoreHtml
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
sections.wrappers[wrapperName] = newWrapper.wrappers[wrapperName];
|
|
623
|
+
sections.wrappers[wrapperName].redone = true;
|
|
624
|
+
sections.wrapperjs += newWrapper.wrapperjs;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
const _yr = sections.yr;
|
|
631
|
+
sections.yr = {};
|
|
632
|
+
|
|
633
|
+
const aux = {};
|
|
634
|
+
for (let item of ['header', 'body', 'footer', 'scripts']) {
|
|
635
|
+
aux[item] = sections[item];
|
|
636
|
+
sections[item] = '';
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const result = this.parse(this.lib(wrapper[0], wrapper[1]).yr, {
|
|
640
|
+
sections, wrapper: `${wrapper.join('/')}`, ...config
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
sections.extensions += '!! ' + wrapperName + '\n';
|
|
644
|
+
|
|
645
|
+
if (!sections.wrappers[wrapperName])
|
|
646
|
+
sections.wrappers[wrapperName] = {};
|
|
647
|
+
|
|
648
|
+
if (!sections.wrappers[wrapperName].parsed)
|
|
649
|
+
sections.wrappers[wrapperName].parsed = {};
|
|
650
|
+
|
|
651
|
+
if (!sections.wrappers[wrapperName].vars)
|
|
652
|
+
sections.wrappers[wrapperName].vars = {};
|
|
653
|
+
|
|
654
|
+
for (let item of ['header', 'body', 'footer', 'scripts']) {
|
|
655
|
+
sections.wrappers[wrapperName].parsed[item] = result[item];
|
|
656
|
+
sections[item] = aux[item];
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
try {
|
|
660
|
+
sections.wrappers[wrapperName].yr = result.yr;
|
|
661
|
+
} catch(error) {/* pass */}
|
|
662
|
+
|
|
663
|
+
sections.yr = _yr;
|
|
664
|
+
} catch(error) {
|
|
665
|
+
console.log(-323, error);
|
|
666
|
+
throw `error -323. Invalid extension: ${wrapper.join('/')}`;
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
parse(code, config={}) {
|
|
670
|
+
const sections = (config.sections) ? config.sections : parsers.defaults();
|
|
671
|
+
|
|
672
|
+
const state = {
|
|
673
|
+
section: undefined, layers: [],
|
|
674
|
+
lastSection: undefined, sectionChanged: false,
|
|
675
|
+
wrapper: [], code
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
if (config.debug) {
|
|
679
|
+
console.log('+++++');
|
|
680
|
+
console.log(code);
|
|
681
|
+
console.log('+++++');
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
try {
|
|
685
|
+
state.id = crypto.generateToken(8);
|
|
686
|
+
} catch(error) {/* pass */}
|
|
687
|
+
|
|
688
|
+
let section = 'nosection', lineNumber = 1;
|
|
689
|
+
|
|
690
|
+
if (!sections.vars) sections.vars = {};
|
|
691
|
+
if (!sections.extensions) sections.extensions = '';
|
|
692
|
+
|
|
693
|
+
if (config.extensions) {
|
|
694
|
+
sections.extensions = [...new Set([
|
|
695
|
+
...sections.extensions.split('\n'),
|
|
696
|
+
...config.extensions.split('\n')
|
|
697
|
+
])].join('\n');
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
if (!sections.jsfooter) sections.jsfooter = '';
|
|
701
|
+
if (!sections.wrappers) sections.wrappers = {};
|
|
702
|
+
|
|
703
|
+
if (!sections.yr)
|
|
704
|
+
sections.yr = { header: '', body: '', footer: '', scripts: '' };
|
|
705
|
+
|
|
706
|
+
sections.wrappersAux = '';
|
|
707
|
+
|
|
708
|
+
for (let line of code.split('\n')) {
|
|
709
|
+
if (line.trim() === '') continue;
|
|
710
|
+
|
|
711
|
+
if (parsers.tokens.includes(line)) {
|
|
712
|
+
if (section === 'macros')
|
|
713
|
+
this.aux(sections, { macrosAux: sections.macrosAux });
|
|
714
|
+
|
|
715
|
+
section = parsers.namespaces[line].name;
|
|
716
|
+
state.sectionChanged = true;
|
|
717
|
+
|
|
718
|
+
if (state.wrapper.length > 0) {
|
|
719
|
+
const wrapper = state.wrapper[0];
|
|
720
|
+
|
|
721
|
+
sections.yr[wrapper.section] =
|
|
722
|
+
sections.yr[wrapper.section].replace(/#@#\n/, '');
|
|
723
|
+
|
|
724
|
+
if (wrapper.wildCard)
|
|
725
|
+
sections[wrapper.section] += wrapper.wildCard + '\n';
|
|
726
|
+
|
|
727
|
+
state.wrapper.shift();
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
continue;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
if (!line.startsWith('[[') && lineNumber === 1 && config.onlyVars)
|
|
734
|
+
return {};
|
|
735
|
+
|
|
736
|
+
if (line.startsWith('[[') && lineNumber === 1) {
|
|
737
|
+
for (let value of line.slice(2).split(';').map(key => key.trim())) {
|
|
738
|
+
const values = value.split('=');
|
|
739
|
+
if (values[0] === 'attributes' && sections.vars.attributes) continue;
|
|
740
|
+
sections.vars[values[0]] = JSON.parse(values[1]);
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
sections.varsAux = line;
|
|
744
|
+
if (config.onlyVars) return sections.vars;
|
|
745
|
+
continue;
|
|
746
|
+
} else if (section === 'nosection') {
|
|
747
|
+
if (line.startsWith('!!')) {
|
|
748
|
+
const wrapperName = line.replace(/!!/g, '').trim();
|
|
749
|
+
|
|
750
|
+
const wrapper = wrapperName.split('/');
|
|
751
|
+
if (wrapper.length === 1) wrapper.unshift('__');
|
|
752
|
+
|
|
753
|
+
this.extend(wrapper, wrapperName, sections, state);
|
|
754
|
+
//} else if (line.startsWith('\\\\')) {
|
|
755
|
+
// const wrapperName = line.replace(/\\\\/g, '').trim() + '\n';
|
|
756
|
+
|
|
757
|
+
// if (!sections.extensions.includes(wrapperName))
|
|
758
|
+
// sections.extensions += wrapperName;
|
|
759
|
+
} else if (line.startsWith('??')) {
|
|
760
|
+
//let split = line.split('??');
|
|
761
|
+
|
|
762
|
+
//for (let value of split) {
|
|
763
|
+
// value = value.trim();
|
|
764
|
+
// let split2 = value.split('::');
|
|
765
|
+
|
|
766
|
+
// if (split2[0].startsWith('_')) {
|
|
767
|
+
// let envVar = split2[0].substring(1).trim();
|
|
768
|
+
// let firstConditional = split2[1].trim(), secondConditional;
|
|
769
|
+
|
|
770
|
+
// if (split2[1].includes('?_')) {
|
|
771
|
+
// let split3 = split2[1].split('?_');
|
|
772
|
+
// firstConditional = split3[0].trim();
|
|
773
|
+
// secondConditional = split3[1].trim();
|
|
774
|
+
// }
|
|
775
|
+
|
|
776
|
+
// if (options.vars[envVar]) {
|
|
777
|
+
// line = firstConditional;
|
|
778
|
+
// } else if (secondConditional) {
|
|
779
|
+
// line = secondConditional;
|
|
780
|
+
// }
|
|
781
|
+
// }
|
|
782
|
+
//}
|
|
783
|
+
|
|
784
|
+
//requires = line.split(' ');
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
let parser = (section === 'wrappers' || section === 'macros')
|
|
789
|
+
? 'auxstring' : 'nosection';
|
|
790
|
+
|
|
791
|
+
try {
|
|
792
|
+
parser = parsers.namespaces[parsers.names[section]].parser;
|
|
793
|
+
} catch(error) {/* pass */}
|
|
794
|
+
|
|
795
|
+
parsers.parse(parser, line, sections, section, state, lineNumber, config);
|
|
796
|
+
state.sectionChanged = false;
|
|
797
|
+
lineNumber++;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
section = false;
|
|
801
|
+
|
|
802
|
+
if (config.wrapper && sections.wrappersAux
|
|
803
|
+
&& !sections.wrappers[config.wrapper]) {
|
|
804
|
+
const yrAux = JSON.parse(JSON.stringify(sections.yr));
|
|
805
|
+
|
|
806
|
+
const wrapperbody = (sections.wrapperbody)
|
|
807
|
+
? sections.wrapperbody : '';
|
|
808
|
+
|
|
809
|
+
sections.wrapperbody = '';
|
|
810
|
+
sections.yr = false;
|
|
811
|
+
|
|
812
|
+
sections.wrappers[config.wrapper] = {
|
|
813
|
+
wrapper: sections.wrappersAux, vars: {}
|
|
814
|
+
};
|
|
815
|
+
|
|
816
|
+
const aux = {};
|
|
817
|
+
for (let item of ['header', 'body', 'footer', 'scripts']) {
|
|
818
|
+
aux[item] = sections[item];
|
|
819
|
+
sections[item] = '';
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
const extension = this.parse(`${
|
|
823
|
+
(sections.varsAux) ? `${sections.varsAux}\n\n` : ''
|
|
824
|
+
}>+\n\n${sections.wrappersAux}`, { sections });
|
|
825
|
+
|
|
826
|
+
if (!sections.wrappers[config.wrapper])
|
|
827
|
+
sections.wrappers[config.wrapper] = {};
|
|
828
|
+
|
|
829
|
+
if (!sections.wrappers[config.wrapper].parsed)
|
|
830
|
+
sections.wrappers[config.wrapper].parsed = {};
|
|
831
|
+
|
|
832
|
+
if (!sections.wrappers[config.wrapper].vars)
|
|
833
|
+
sections.wrappers[config.wrapper].vars = {};
|
|
834
|
+
|
|
835
|
+
for (let item of ['header', 'body', 'footer', 'scripts']) {
|
|
836
|
+
sections.wrappers[config.wrapper].parsed[item] = extension[item];
|
|
837
|
+
sections[item] = aux[item]
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
sections.wrappers[config.wrapper].yrwrapperbody =
|
|
841
|
+
extension.yr.wrapperbody;
|
|
842
|
+
|
|
843
|
+
delete extension.yr.wrapperbody;
|
|
844
|
+
|
|
845
|
+
sections.wrappers[config.wrapper].wrapperbody = extension.wrapperbody;
|
|
846
|
+
sections.wrappers[config.wrapper].vars = extension.vars;
|
|
847
|
+
sections.wrappers[config.wrapper].yr = extension.yr;
|
|
848
|
+
sections.wrapperbody = wrapperbody;
|
|
849
|
+
sections.yr = yrAux;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
sections.wrappersAux = '';
|
|
853
|
+
|
|
854
|
+
while (state.wrapper.length > 0) {
|
|
855
|
+
const wrapper = state.wrapper[state.wrapper.length - 1];
|
|
856
|
+
|
|
857
|
+
sections.yr[wrapper.section] =
|
|
858
|
+
sections.yr[wrapper.section].replace(/#@#\n/, '');
|
|
859
|
+
|
|
860
|
+
if (wrapper.wildCard)
|
|
861
|
+
sections[wrapper.section] += wrapper.wildCard + '\n';
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
for (let j = wrapper.layers.length - 1; j >= 0; j--) {
|
|
865
|
+
const layer = wrapper.layers[j];
|
|
866
|
+
if (!layer) continue;
|
|
867
|
+
|
|
868
|
+
sections[layer.section] +=
|
|
869
|
+
common.getWhiteSpace(layer.indentation) + `</${layer.tag}>\n`;
|
|
870
|
+
|
|
871
|
+
wrapper.layers.pop();
|
|
872
|
+
state.layers = state.layers.filter(e => e !== layer);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
state.wrapper.pop();
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
for (let j = state.layers.length - 1; j >= 0; j--) {
|
|
879
|
+
if (j === -1) continue;
|
|
880
|
+
|
|
881
|
+
sections[state.layers[j].section] +=
|
|
882
|
+
common.getWhiteSpace(state.layers[j].indentation) + `</${state.layers[j].tag}>\n`;
|
|
883
|
+
|
|
884
|
+
state.layers.pop();
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
this.aux(sections, {
|
|
888
|
+
macrosAux: sections.macrosAux,
|
|
889
|
+
devopsAux: sections.devopsAux
|
|
890
|
+
});
|
|
891
|
+
|
|
892
|
+
for (let item in parsers.mergers) {
|
|
893
|
+
if (JSON.stringify(parsers.mergers[item]) === '""')
|
|
894
|
+
sections[item] = this.macros(sections, item);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
sections.modules = sections.modules
|
|
898
|
+
.filter((item, pos, self) => self.indexOf(item) == pos);
|
|
899
|
+
|
|
900
|
+
sections.parsedjs = (!config.preview) ? '' : 'window.__preview = true;\n';
|
|
901
|
+
sections.parsedcss = '';
|
|
902
|
+
|
|
903
|
+
for (let item of ['css', 'js']) {
|
|
904
|
+
for (let value of ['header', '', 'footer']) {
|
|
905
|
+
if (item === 'css' && (value === 'jsapp' || value === 'footer'))
|
|
906
|
+
continue;
|
|
907
|
+
|
|
908
|
+
let target = (value === 'jsapp') ? 'jsapp' : `${item}${value}`;
|
|
909
|
+
|
|
910
|
+
if (sections[target] && !sections[`parsed${item}`].includes(sections[target])) {
|
|
911
|
+
sections[`parsed${item}`] += sections[target]
|
|
912
|
+
+ ((!sections[target].endsWith('\n')) ? '\n' : '');
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
if (!sections.parsedjs.includes(sections.jsapp.join('')))
|
|
918
|
+
sections.parsedjs = sections.jsapp.join('') + sections.parsedjs;
|
|
919
|
+
|
|
920
|
+
sections.parsedapp = '';
|
|
921
|
+
for (let item of ['jsapp', 'appheader', 'app', 'appfooter']) {
|
|
922
|
+
if (!sections.parsedapp.includes(sections[item].join('')))
|
|
923
|
+
sections.parsedapp += sections[item].join('');
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
sections.parsedcss += '\n' + sections.wrappercsscustom + '\n'
|
|
927
|
+
+ sections.wrappercss.replace(/\s*!important;/g, ';')
|
|
928
|
+
.replace(/;/g, ' !important;');
|
|
929
|
+
|
|
930
|
+
if (sections.cssfooter && !sections.parsedcss.includes(sections.cssfooter))
|
|
931
|
+
sections.parsedcss += '\n' + sections.cssfooter;
|
|
932
|
+
|
|
933
|
+
sections.parsedyr = { extensions: '' };
|
|
934
|
+
|
|
935
|
+
for (let item of sections.extensions.split('\n')) {
|
|
936
|
+
if (!item.startsWith('!! !')) item = item.replace(/!! /, '!! !');
|
|
937
|
+
|
|
938
|
+
if (!sections.parsedyr.extensions.includes(item + '\n'))
|
|
939
|
+
sections.parsedyr.extensions += item + '\n';
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
for (let value of ['header', 'body', 'footer', 'scripts']) {
|
|
943
|
+
if (!sections[value]) sections[value] = '';
|
|
944
|
+
if (!sections.yr[value]) sections.yr[value] = '';
|
|
945
|
+
|
|
946
|
+
sections[`parsed${value}`] = sections[value];
|
|
947
|
+
sections.parsedyr[value] = sections.yr[value];
|
|
948
|
+
|
|
949
|
+
for (let item in sections.wrappers) {
|
|
950
|
+
// fix!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
951
|
+
if (sections.wrappers[item].redone) continue; // this will cause files to be parsed wrongly
|
|
952
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
953
|
+
|
|
954
|
+
if (!sections.wrappers[item].yr)
|
|
955
|
+
sections.wrappers[item].yr = {};
|
|
956
|
+
|
|
957
|
+
if (!sections.wrappers[item].parsed)
|
|
958
|
+
sections.wrappers[item].parsed = {};
|
|
959
|
+
|
|
960
|
+
if (!sections.wrappers[item].vars)
|
|
961
|
+
sections.wrappers[item].vars = {};
|
|
962
|
+
|
|
963
|
+
if (!sections.wrappers[item].yr[value])
|
|
964
|
+
sections.wrappers[item].yr[value] = '';
|
|
965
|
+
|
|
966
|
+
if (!sections.wrappers[item].parsed[value])
|
|
967
|
+
sections.wrappers[item].parsed[value] = '';
|
|
968
|
+
|
|
969
|
+
sections[`parsed${value}`] = sections.wrappers[item].parsed[value]
|
|
970
|
+
+ sections[`parsed${value}`];
|
|
971
|
+
|
|
972
|
+
sections.parsedyr[value] = sections.wrappers[item].yr[value]
|
|
973
|
+
+ sections.parsedyr[value];
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
if (!sections[`parsed${value}`]) sections[`parsed${value}`] = '';
|
|
977
|
+
if (!sections.parsedyr[value]) sections.parsedyr[value] = '';
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
sections.parsedyr = {
|
|
981
|
+
...sections.parsedyr,
|
|
982
|
+
wrappercss: sections.wrappercss,
|
|
983
|
+
wrappercsscustom: sections.wrappercsscustom,
|
|
984
|
+
wrapperjs: sections.wrapperjs,
|
|
985
|
+
wrapperjscustom: sections.wrapperjscustom
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
if (sections.parsedcss !== '')
|
|
989
|
+
sections.parsedcss = this.macros(sections, 'parsedcss');
|
|
990
|
+
|
|
991
|
+
if (config.preview) sections.parsedjs += '\n' + sections.jstests;
|
|
992
|
+
|
|
993
|
+
if (sections.parsedjs !== '')
|
|
994
|
+
sections.parsedjs = this.macros(sections, 'parsedjs');
|
|
995
|
+
|
|
996
|
+
let newWrapperJs = '';//const __runenv = async () => {\n';
|
|
997
|
+
//sections.parsedjs += 'const __runenv = async () => {\n';
|
|
998
|
+
const arr = sections.parsedyr.wrapperjs.split('\n');
|
|
999
|
+
if (code.includes('!! !')) arr.reverse();
|
|
1000
|
+
for (let item of arr) {
|
|
1001
|
+
if (!item) continue;
|
|
1002
|
+
|
|
1003
|
+
let parsedItem = item.split('({');
|
|
1004
|
+
parsedItem.shift();
|
|
1005
|
+
parsedItem = parsedItem.join('({');
|
|
1006
|
+
|
|
1007
|
+
parsedItem = parsedItem.split('})');
|
|
1008
|
+
parsedItem.pop();
|
|
1009
|
+
parsedItem = parsedItem.join('})');
|
|
1010
|
+
|
|
1011
|
+
parsedItem = JSON.parse(`{${parsedItem}}`);
|
|
1012
|
+
|
|
1013
|
+
for (let value of ['header', 'body', 'footer', 'scripts']) {
|
|
1014
|
+
if (sections[`parsed${value}`].includes(`${parsedItem.id}`)) {
|
|
1015
|
+
parsedItem.attributes = sections
|
|
1016
|
+
.wrappers[`${parsedItem.category}/${parsedItem.option}`].vars.attributes;
|
|
1017
|
+
|
|
1018
|
+
const newItem = `__${parsedItem.category}_${parsedItem.option}(${
|
|
1019
|
+
JSON.stringify(parsedItem)
|
|
1020
|
+
});`;
|
|
1021
|
+
|
|
1022
|
+
sections.parsedjs += newItem + '\n';
|
|
1023
|
+
newWrapperJs += newItem + '\n';
|
|
1024
|
+
break;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
//newWrapperJs += '};\n__runenv();\n';
|
|
1029
|
+
//sections.parsedjs += '};\n__runenv();\n';
|
|
1030
|
+
|
|
1031
|
+
if (config.preview) {
|
|
1032
|
+
function countCharacterOccurrences(str, char) {
|
|
1033
|
+
const regex = new RegExp(char, 'gi');
|
|
1034
|
+
const matches = str.match(regex);
|
|
1035
|
+
return matches ? matches.length : 0;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
function parseCssToJson(css) {
|
|
1039
|
+
const styles = {};
|
|
1040
|
+
|
|
1041
|
+
let openLevel = 0, _viewport = 'desktop', _pseudo = 'default', _referenceId;
|
|
1042
|
+
for (let item of css.split('\n')) {
|
|
1043
|
+
if (!item) continue;
|
|
1044
|
+
item = item.trim();
|
|
1045
|
+
|
|
1046
|
+
if (item.includes('{')) {
|
|
1047
|
+
if (openLevel === 0 && !item.includes('@media')) {
|
|
1048
|
+
_viewport = 'desktop';
|
|
1049
|
+
const newItem = item.replace(/:+/g, ':');
|
|
1050
|
+
const names = newItem.split(' ')[0].split(':');
|
|
1051
|
+
_referenceId = names[0].replace(/\./, '');
|
|
1052
|
+
|
|
1053
|
+
_pseudo = (!names[1]) ? 'default'
|
|
1054
|
+
: ':'.repeat(countCharacterOccurrences(item, ':')) + names[1];
|
|
1055
|
+
} else if (openLevel === 0) {
|
|
1056
|
+
if (item.includes('802px')) _viewport = 'tablet';
|
|
1057
|
+
if (item.includes('482px')) _viewport = 'phone';
|
|
1058
|
+
} else {
|
|
1059
|
+
const newItem = item.replace(/:+/g, ':');
|
|
1060
|
+
const names = newItem.split(' ')[0].split(':');
|
|
1061
|
+
_referenceId = names[0].replace(/\./, '');
|
|
1062
|
+
|
|
1063
|
+
_pseudo = (!names[1]) ? 'default'
|
|
1064
|
+
: ':'.repeat(countCharacterOccurrences(item, ':')) + names[1];
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
openLevel++;
|
|
1068
|
+
} else if (item.trim() === '}') {
|
|
1069
|
+
openLevel--;
|
|
1070
|
+
|
|
1071
|
+
if (openLevel === 0) {
|
|
1072
|
+
_viewport = 'desktop';
|
|
1073
|
+
_pseudo = 'default';
|
|
1074
|
+
}
|
|
1075
|
+
} else {
|
|
1076
|
+
let value = item.split(':');
|
|
1077
|
+
let key = value[0].trim();
|
|
1078
|
+
value.shift();
|
|
1079
|
+
|
|
1080
|
+
value = value.join(':').replace(/\;$/, '').trim()
|
|
1081
|
+
.replace(/ !important/, '');
|
|
1082
|
+
|
|
1083
|
+
if (!styles[_viewport]) styles[_viewport] = {};
|
|
1084
|
+
|
|
1085
|
+
if (!styles[_viewport][_referenceId])
|
|
1086
|
+
styles[_viewport][_referenceId] = {};
|
|
1087
|
+
|
|
1088
|
+
if (!styles[_viewport][_referenceId][_pseudo])
|
|
1089
|
+
styles[_viewport][_referenceId][_pseudo] = {};
|
|
1090
|
+
|
|
1091
|
+
styles[_viewport][_referenceId][_pseudo][key] = value;
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
return styles;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
function parseJsonToCss(json) {
|
|
1099
|
+
let css = '';
|
|
1100
|
+
|
|
1101
|
+
for (let item in json) { // viewport
|
|
1102
|
+
let indentation = (item === 'desktop') ? 0 : 2;
|
|
1103
|
+
|
|
1104
|
+
if (item === 'tablet')
|
|
1105
|
+
css += '@media only screen and (max-width: 802px) {\n'
|
|
1106
|
+
|
|
1107
|
+
if (item === 'phone')
|
|
1108
|
+
css += '@media only screen and (max-width: 482px) {\n'
|
|
1109
|
+
|
|
1110
|
+
for (let value in json[item]) { // element
|
|
1111
|
+
for (let key in json[item][value]) { // pseudo
|
|
1112
|
+
css += `${' '.repeat(indentation)}${(value === 'body') ? value : '.' + value }`
|
|
1113
|
+
+ `${(key === 'default') ? '' : key} {\n`;
|
|
1114
|
+
|
|
1115
|
+
for (let option in json[item][value][key]) // selector
|
|
1116
|
+
css += `${' '.repeat(indentation + 2)}${option}`
|
|
1117
|
+
+ `: ${json[item][value][key][option]};\n`
|
|
1118
|
+
|
|
1119
|
+
css += `${' '.repeat(indentation)}}\n`;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
if (item === 'tablet' || item === 'phone') css += '}\n';
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
return css;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
sections.parsedyr.wrapperjs = newWrapperJs;
|
|
1130
|
+
//let newFullWrapperJs = '';
|
|
1131
|
+
//for (let value of sections.wrapperjs.split('\n').reverse())
|
|
1132
|
+
// newFullWrapperJs += value + '\n';
|
|
1133
|
+
//sections.wrapperjs = newFullWrapperJs;
|
|
1134
|
+
|
|
1135
|
+
let newExtensions = '';
|
|
1136
|
+
for (let item of sections.parsedyr.extensions.split('\n')) {
|
|
1137
|
+
if (!item.includes('/')) {
|
|
1138
|
+
newExtensions += item + '\n';
|
|
1139
|
+
continue;
|
|
1140
|
+
} else {
|
|
1141
|
+
const _item = item.split('/');
|
|
1142
|
+
if (_item[1][0].toLowerCase() === _item[1][0].toUpperCase()) {
|
|
1143
|
+
newExtensions += item + '\n';
|
|
1144
|
+
continue;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
for (let value of ['header', 'body', 'footer', 'scripts']) {
|
|
1149
|
+
if (sections.parsedyr[value].includes(item.replace(/!/g, '')
|
|
1150
|
+
.trim().toLowerCase())) {
|
|
1151
|
+
newExtensions += item + '\n';
|
|
1152
|
+
break;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
sections.parsedyr.extensions = newExtensions;
|
|
1158
|
+
const parsedCss = parseCssToJson(sections.parsedyr.wrappercss);
|
|
1159
|
+
|
|
1160
|
+
const newCss = {};
|
|
1161
|
+
for (let item in parsedCss) {
|
|
1162
|
+
for (let value in parsedCss[item]) {
|
|
1163
|
+
if (value === 'html' || value === 'body') {
|
|
1164
|
+
if (!newCss[item]) newCss[item] = {};
|
|
1165
|
+
newCss[item][value] = parsedCss[item][value];
|
|
1166
|
+
continue;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
for (let key of ['header', 'body', 'footer', 'scripts']) {
|
|
1170
|
+
//if (sections.parsedyr[key].includes(`.${value}`)) {
|
|
1171
|
+
if (!newCss[item]) newCss[item] = {};
|
|
1172
|
+
newCss[item][value] = parsedCss[item][value];
|
|
1173
|
+
//break;
|
|
1174
|
+
//}
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
sections.parsedyr.wrappercss = parseJsonToCss(newCss);
|
|
1180
|
+
|
|
1181
|
+
//const templateRegex = id =>
|
|
1182
|
+
// new RegExp(`\\{\\{[^}]*?\\.?${id}\\b[^}]*?\\}\\}`);
|
|
1183
|
+
|
|
1184
|
+
//for (let item of ['header', 'body', 'footer', 'scripts']) {
|
|
1185
|
+
// for (let value of sections.parsedyr[item].split('\n')) {
|
|
1186
|
+
// const match = value.match(/(?:\.|\.\{\{)\s*(__[A-Za-z0-9_-]+)/);
|
|
1187
|
+
// if (!match) continue;
|
|
1188
|
+
|
|
1189
|
+
// const elementId = match[1];
|
|
1190
|
+
// let exists;
|
|
1191
|
+
|
|
1192
|
+
// for (let key of Object.keys(sections.parsedyr)) {
|
|
1193
|
+
// const content = sections.parsedyr[key];
|
|
1194
|
+
|
|
1195
|
+
// if (!key.includes('wrapper')) {
|
|
1196
|
+
// exists = templateRegex(elementId).test(content);
|
|
1197
|
+
// } else {
|
|
1198
|
+
// exists = content.includes(elementId);
|
|
1199
|
+
// }
|
|
1200
|
+
|
|
1201
|
+
// if (exists) break;
|
|
1202
|
+
// }
|
|
1203
|
+
|
|
1204
|
+
// if (!exists) {
|
|
1205
|
+
// const newLine = value.split(match[0]).join('').trimEnd();
|
|
1206
|
+
|
|
1207
|
+
// sections.parsedyr[item] =
|
|
1208
|
+
// sections.parsedyr[item].split(value).join(newLine);
|
|
1209
|
+
// }
|
|
1210
|
+
// }
|
|
1211
|
+
//}
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
if (sections.parsedapp !== '')
|
|
1215
|
+
sections.parsedapp = this.macros(sections, 'parsedapp');
|
|
1216
|
+
|
|
1217
|
+
if (config.window) {
|
|
1218
|
+
let newjs = '';
|
|
1219
|
+
|
|
1220
|
+
for (let item in config.window) newjs +=
|
|
1221
|
+
`window['${item}'] = ${JSON.stringify(config.window[item])};\n`;
|
|
1222
|
+
|
|
1223
|
+
sections.parsedjs = newjs + sections.parsedjs;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
if (config.localStorage) {
|
|
1227
|
+
let newjs = 'try {\n';
|
|
1228
|
+
|
|
1229
|
+
for (let item in config.localStorage) {
|
|
1230
|
+
newjs += ` window.localStorage.setItem('${item}', ${
|
|
1231
|
+
JSON.stringify(config.localStorage[item])
|
|
1232
|
+
});\n`
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
newjs += '} catch(error) {/* pass */}\n';
|
|
1236
|
+
sections.parsedjs = newjs + sections.parsedjs;
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
if (sections.wrapperjscustom)
|
|
1240
|
+
sections.parsedjs += '\n' + sections.wrapperjscustom;
|
|
1241
|
+
|
|
1242
|
+
if (!config.lang) config.lang = 'en-US';
|
|
1243
|
+
|
|
1244
|
+
if (config.name) {
|
|
1245
|
+
const assetHash = crypto.generateToken(6).toLowerCase();
|
|
1246
|
+
for (let value of ['css', 'js'])
|
|
1247
|
+
config[`${value}name`] = `${config.name}.${assetHash}`;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
if (sections.apptests.length > 0 && !sections.parsedbody.includes('class="__')) {
|
|
1251
|
+
sections.parsedbody += '\n<div class="__cclass"></div>';
|
|
1252
|
+
|
|
1253
|
+
sections.parsedscripts = `<script>
|
|
1254
|
+
try {
|
|
1255
|
+
function require(name) {
|
|
1256
|
+
//return window[name];
|
|
1257
|
+
}
|
|
1258
|
+
function setGlobal(name, item) {
|
|
1259
|
+
//window[name] = item;
|
|
1260
|
+
}
|
|
1261
|
+
${sections.parsedjs}
|
|
1262
|
+
${sections.appheader.join('')}
|
|
1263
|
+
${sections.apptests.join('')}
|
|
1264
|
+
} catch(error) { console.log(error); }
|
|
1265
|
+
</script>`;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
sections.parsedhtml = `<!DOCTYPE html>
|
|
1269
|
+
<html lang="${config.lang}">
|
|
1270
|
+
${sections.pixel}
|
|
1271
|
+
<head>
|
|
1272
|
+
${sections.parsedheader}
|
|
1273
|
+
${(config.name) ? ` <link rel="stylesheet" href="./${config.cssname}.css">` : ` <style>\n${sections.parsedcss}\n</style>`}
|
|
1274
|
+
</head>
|
|
1275
|
+
<body style="display: none">
|
|
1276
|
+
${sections.parsedbody}
|
|
1277
|
+
${sections.parsedfooter}
|
|
1278
|
+
</body>
|
|
1279
|
+
${sections.parsedscripts}
|
|
1280
|
+
<script id="psj"${(config.name) ? ` src="./${config.jsname}.js">`
|
|
1281
|
+
: `>\n${sections.parsedjs}\n`
|
|
1282
|
+
}</script>
|
|
1283
|
+
<script>
|
|
1284
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
1285
|
+
document.body.style.display = 'block';
|
|
1286
|
+
});
|
|
1287
|
+
</script>
|
|
1288
|
+
</html>`;
|
|
1289
|
+
|
|
1290
|
+
if (config.name) sections.ui = [
|
|
1291
|
+
{ name: `${config.name}.html`, content: sections.parsedhtml },
|
|
1292
|
+
{ name: `${config.cssname}.css`, content: sections.parsedcss },
|
|
1293
|
+
{ name: `${config.jsname}.js`, content: sections.parsedjs },
|
|
1294
|
+
{ name: `${utils.capitalize(config.name)}_.yr`, content: code }
|
|
1295
|
+
];
|
|
1296
|
+
|
|
1297
|
+
return sections;
|
|
1298
|
+
},
|
|
1299
|
+
parsers
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
if (typeof module !== 'undefined' && module.exports)
|
|
1303
|
+
module.exports = core;
|
|
1304
|
+
|
|
1305
|
+
if (typeof window !== 'undefined' && !window.yr) {
|
|
1306
|
+
const parse = core.parse.bind(core);
|
|
1307
|
+
window.yr = parse;
|
|
1308
|
+
}
|