Skip to content

Commit ebc37ce

Browse files
committed
Update to 3.0.3
1 parent 9a511dc commit ebc37ce

File tree

12 files changed

+1080
-80
lines changed

12 files changed

+1080
-80
lines changed

dist/utils/html/HTMLCache.js

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
/**
2-
* Author: Zeta Ret
3-
* Date: 2019 - Today
4-
* HTML cache from parser
5-
**/
6-
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
73
var fs = require("fs"),
84
path = require("path"),
95
events = require("events");
10-
116
const EVENTS = {
127
SET_STRUCT: "setStruct",
138
ADD_PAGE: "addPage",
@@ -21,8 +16,17 @@ const EVENTS = {
2116
WATCH_FILE: "watchFile",
2217
RESET_WATCHERS: "resetWatchers",
2318
};
24-
2519
class HTMLCache {
20+
structs;
21+
autoStructPage;
22+
pages;
23+
despaceChars;
24+
despaceRules;
25+
watchFiles;
26+
watchOptions;
27+
watchListener;
28+
watchMap;
29+
events;
2630
constructor() {
2731
var o = this;
2832
o.structs = {};
@@ -36,14 +40,12 @@ class HTMLCache {
3640
o.watchMap = {};
3741
o.events = new events.EventEmitter();
3842
}
39-
4043
setStruct(id, pagesOrStructIds) {
4144
var o = this;
4245
o.structs[id] = pagesOrStructIds;
4346
o.events.emit(EVENTS.SET_STRUCT, id, o);
4447
return o;
4548
}
46-
4749
getStruct(id) {
4850
var o = this;
4951
var c,
@@ -52,7 +54,6 @@ class HTMLCache {
5254
else c = o.getPage(s);
5355
return c;
5456
}
55-
5657
addPage(page, parser, hfile, dir) {
5758
var o = this;
5859
var pdata = {
@@ -73,11 +74,9 @@ class HTMLCache {
7374
o.events.emit(EVENTS.ADD_PAGE, page, pdata, o);
7475
return pdata;
7576
}
76-
7777
getPage(page) {
7878
return this.pages[page].content || this.renderContent(page);
7979
}
80-
8180
exePage(page, cfg) {
8281
var o = this;
8382
var pdata = o.pages[page],
@@ -93,7 +92,6 @@ class HTMLCache {
9392
o.events.emit(EVENTS.EXE_PAGE, page, pdata, o);
9493
return pdata;
9594
}
96-
9795
renderContent(page) {
9896
var o = this;
9997
var c,
@@ -106,7 +104,6 @@ class HTMLCache {
106104
if (!cfg.nocontent) pdata.content = c;
107105
return c;
108106
}
109-
110107
resetBinders(page) {
111108
var o = this;
112109
var p, pdata;
@@ -118,7 +115,6 @@ class HTMLCache {
118115
}
119116
}
120117
}
121-
122118
recache(page) {
123119
var o = this;
124120
var pdata = o.pages[page],
@@ -127,7 +123,6 @@ class HTMLCache {
127123
hpinst.parseFromFile(hpinst.file, hpinst.dir);
128124
o.exePage(page, pdata.execfg);
129125
}
130-
131126
execDom(hpinst, id, pdata) {
132127
var o = this;
133128
var exes = hpinst.search(null, hpinst.exeOn, hpinst.exeAttr);
@@ -148,11 +143,9 @@ class HTMLCache {
148143
});
149144
}
150145
}
151-
152146
setPages(pages, HTMLParser, watchers, log, decorateParser) {
153147
var o = this;
154148
var hpinst, p, op;
155-
156149
for (p in pages) {
157150
op = pages[p];
158151
hpinst = new HTMLParser();
@@ -176,7 +169,6 @@ class HTMLCache {
176169
o.exePage(op.id, op.exe);
177170
}
178171
}
179-
180172
swapCSS(page, handler, despace) {
181173
var o = this;
182174
var pdata = o.pages[page],
@@ -190,7 +182,6 @@ class HTMLCache {
190182
fileid = f.split("/").pop(),
191183
prefix = e.attr.prefix,
192184
base = e.attr.base;
193-
194185
if (base) {
195186
browserpath = path.join(base, fileid).split("\\").join("/");
196187
delete e.attr.base;
@@ -216,7 +207,6 @@ class HTMLCache {
216207
if (handler) handler(page, pdata, e, swap);
217208
});
218209
}
219-
220210
swapJS(page, handler, despace) {
221211
var o = this;
222212
var pdata = o.pages[page],
@@ -230,7 +220,6 @@ class HTMLCache {
230220
fileid = f.split("/").pop(),
231221
prefix = e.attr.prefix,
232222
base = e.attr.base;
233-
234223
if (base) {
235224
browserpath = path.join(base, fileid).split("\\").join("/");
236225
delete e.attr.base;
@@ -252,7 +241,6 @@ class HTMLCache {
252241
if (handler) handler(page, pdata, e, swap);
253242
});
254243
}
255-
256244
defaultRenderTemplate(hcache, page, pdata, hpinst, cfg) {
257245
hpinst.search("#template").forEach((t) => {
258246
var sp = t.attr.section;
@@ -262,7 +250,6 @@ class HTMLCache {
262250
if (!t.attr.nodom) t.elements = !cfg.domtemplate ? [hcache.getPage(sp)] : hcache.pages[sp].parser.dom.elements;
263251
});
264252
}
265-
266253
watch(listener, options) {
267254
var o = this;
268255
var k, pdata, hpinst;
@@ -279,12 +266,10 @@ class HTMLCache {
279266
}
280267
o.events.emit(EVENTS.WATCH, o);
281268
}
282-
283269
getWatchers(listener, interval, debug, recacheOnChange) {
284270
var o = this;
285271
var watchers = {},
286272
watchinterval = interval || 0;
287-
288273
function watchmethod(e, f, longfile, page, type, stats) {
289274
if (watchers[longfile] !== undefined) return;
290275
watchers[longfile] = setTimeout(() => {
@@ -295,32 +280,28 @@ class HTMLCache {
295280
o.events.emit(EVENTS.ON_WATCH, e, f, longfile, page, type, stats, o);
296281
}, watchinterval);
297282
}
298-
299283
return {
300284
watchers,
301285
watchinterval,
302286
watchmethod,
303287
};
304288
}
305-
306289
watchFile(pr, page, type) {
307290
var o = this;
308291
if (o.watchMap[pr]) o.watchMap[pr].close();
309292
o.watchMap[pr] = fs.watch(pr, o.watchOptions, (e, f) => o.watchListener(e, f, pr, page, type, fs.statSync(pr)));
310293
o.events.emit(EVENTS.WATCH_FILE, pr, page, type, o);
311294
}
312-
313295
resetWatchers() {
314296
var o = this;
315297
var k;
316298
o.events.emit(EVENTS.RESET_WATCHERS, o);
317299
for (k in o.watchMap) o.watchMap[k].close();
318300
o.watchMap = {};
319301
}
320-
321302
despace(v, type) {
322303
var o = this;
323-
if (!o.despaceRules[" "]) v = v.replace(new RegExp("[\\s]+", "g"), " ", v);
304+
if (!o.despaceRules[" "]) v = v.replace(new RegExp("[\\s]+", "g"), " ");
324305
var i,
325306
chars = o.despaceChars[type] || ":(|{}=,?!&-+*/%<>";
326307
for (i = 0; i < chars.length; i++)
@@ -334,6 +315,5 @@ class HTMLCache {
334315
return v;
335316
}
336317
}
337-
338318
module.exports.EVENTS = EVENTS;
339319
module.exports.HTMLCache = HTMLCache;

dist/utils/html/HTMLDomElement.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
const htmlmod = require("./HTMLParser.js");
2-
1+
const htmlmod = require("./HTMLParser");
32
module.exports.HTMLDomElement = htmlmod.HTMLDomElement;

0 commit comments

Comments
 (0)