catto.js 1.0.7 → 1.0.9

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.
Files changed (2) hide show
  1. package/Server.js +9 -6
  2. package/package.json +1 -1
package/Server.js CHANGED
@@ -35,6 +35,7 @@ class Server extends EventEmitter {
35
35
  "storeOptions": {},
36
36
  "ejs": !1,
37
37
  "cjs": !1,
38
+ "cjsClient": !0,
38
39
  "proxies": 0,
39
40
  "bodyCompatible": !1,
40
41
  "secureCookie": !0,
@@ -63,11 +64,13 @@ class Server extends EventEmitter {
63
64
  this.app.set("view engine", "ejs");
64
65
  }
65
66
  if (this.options.cjs) {
66
- Server.injectCJS(this.app);
67
+ Server.injectCJS(this.app, !1, this.options.cjsClient);
67
68
  }
68
69
  if (this.options.secret) {
69
70
  this.app.use(session({
70
- "store": new FileStore(this.options.storeOptions),
71
+ "store": new FileStore(Object.assign(this.options.storeOptions, {
72
+ "logFn": () => {}
73
+ })),
71
74
  "secret": this.options.secret,
72
75
  "cookie": {
73
76
  "secure": this.options.secureCookie,
@@ -164,14 +167,14 @@ class Server extends EventEmitter {
164
167
  }
165
168
  return this;
166
169
  }
167
- static renderCJS(app, filepath, options, callback) {
170
+ static renderCJS(app, wclient, filepath, options, callback) {
168
171
  var code = fs.readFileSync(filepath).toString("utf-8");
169
172
  var doctype = code.startsWith("<!DOCTYPE html>");
170
173
  if (doctype) {
171
174
  code = code.replace(/^<!DOCTYPE html>(\r?\n)?/, "");
172
175
  }
173
176
  var parts = code.split(/<%s(?:erver)?(?!\*)(?!=) +(.+?) +%>/g);
174
- var compile = `var __output = "${doctype ? "<!DOCTYPE html>\\n" : ""}<script src=\\"/_cattojs/cjs_client.js\\"></script>\\n";\nfunction __escape(str) {\n if (str === void 0) {\n return "undefined";\n }\n if (typeof str !== "string") {\n str = str.toString();\n }\n return str.split("<").join("&lt;").split(">").join("&gt;");\n}\n`;
177
+ var compile = `var __output = "${doctype ? "<!DOCTYPE html>\\n" : ""}${wclient ? `<script src=\\"/_cattojs/cjs_client.js\\"></script>\\n` : ""}";\nfunction __escape(str) {\n if (str === void 0) {\n return "undefined";\n }\n if (typeof str !== "string") {\n str = str.toString();\n }\n return str.split("<").join("&lt;").split(">").join("&gt;");\n}\n`;
175
178
  parts.forEach((part, index) => {
176
179
  compile += ((index + 1) % 2 < 1 ? `${part}\n` : `__output += ${JSON.stringify(part)}.replace(/<%s(?:erver)?(?!\\*)= +(.+?) +%>/g, (_, g) => __escape(eval(g))).replace(/<%s(?:erver)?(?!\\*)- +(.+?) +%>/g, (_, g) => eval(g)).replace(/<%s(erver)\\*?# +(.+?) +%>/g, "");\n`);
177
180
  });
@@ -184,8 +187,8 @@ class Server extends EventEmitter {
184
187
  }
185
188
  return context.__output;
186
189
  }
187
- static injectCJS(app, nows) {
188
- app.engine("cjs", Server.renderCJS.bind(null, app)).set("view engine", "cjs").get("/_cattojs/cjs_client.js", (req, res) => {
190
+ static injectCJS(app, nows, wclient) {
191
+ app.engine("cjs", Server.renderCJS.bind(null, app, wclient)).set("view engine", "cjs").get("/_cattojs/cjs_client.js", (req, res) => {
189
192
  res.sendFile(path.join(__dirname, "cjs_client.js"));
190
193
  });
191
194
  if (!nows && !app.ws) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catto.js",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Universal module for everything.",
5
5
  "main": "index.js",
6
6
  "scripts": {