nsp-server-pages 0.2.3 → 0.2.4

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.
@@ -34,7 +34,7 @@ class JspLoader extends BaseLoader {
34
34
  timeout: 1000,
35
35
  })(async (path) => {
36
36
  const app = this.appRef.deref();
37
- app.log(`loading: ${path}`);
37
+ app.log(`loading JSP: ${path}`);
38
38
  const text = await fs_1.promises.readFile(path, "utf8");
39
39
  return app.parse(text).toFn();
40
40
  });
@@ -64,7 +64,7 @@ class JsLoader extends BaseLoader {
64
64
  timeout: 1000,
65
65
  })(async (file) => {
66
66
  const app = this.appRef.deref();
67
- app.log(`loading: ${file}`);
67
+ app.log(`loading JS: ${file}`);
68
68
  const module = await Promise.resolve(`${file}`).then(s => require(s));
69
69
  const name = getName(file);
70
70
  const fn = module[name];
@@ -80,8 +80,8 @@ class JsLoader extends BaseLoader {
80
80
  }
81
81
  async load(file) {
82
82
  file = file?.replace(/\.jsp$/, ".js");
83
- // valid only for .js files
84
- if (!/\.[cm]?js$/.test(file))
83
+ // valid only for .js-like files
84
+ if (!/\.(cjs|js|mjs|ts)$/.test(file))
85
85
  return;
86
86
  // skip when file does not exist
87
87
  if (!await this.isFile(file))
@@ -110,8 +110,8 @@ class FileLoader extends BaseLoader {
110
110
  });
111
111
  }
112
112
  async load(file) {
113
- // disabled for JSP, JS and image files
114
- if (/\.(jsp|[cm]?js|png|gif|jpe?g)$/i.test(file))
113
+ // disabled for JSP, JS, TS and image files
114
+ if (/\.(jsp|cjs|js|mjs|ts|png|gif|jpe?g|webp)$/i.test(file))
115
115
  return;
116
116
  // skip when file does not exist
117
117
  if (!await this.isFile(file))
package/cjs/src/mount.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.load = exports.mount = void 0;
3
+ exports.mount = mount;
4
+ exports.load = load;
4
5
  function mount(match, fn) {
5
6
  const test = ("string" !== typeof match) ? match : {
6
7
  test: ((path) => path.startsWith(match))
@@ -10,7 +11,6 @@ function mount(match, fn) {
10
11
  return fn(path);
11
12
  });
12
13
  }
13
- exports.mount = mount;
14
14
  async function load(path) {
15
15
  const { loaders } = this;
16
16
  const search = path.replace(/^[^?]*\??/, "");
@@ -31,4 +31,3 @@ async function load(path) {
31
31
  return fn(context);
32
32
  };
33
33
  }
34
- exports.load = load;
package/cjs/src/taglib.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareTag = exports.addTagLib = void 0;
3
+ exports.addTagLib = addTagLib;
4
+ exports.prepareTag = prepareTag;
4
5
  const to_xml_1 = require("to-xml");
5
6
  const isTagCon = (v) => ("function" === typeof v?.prototype?.render);
6
7
  const tagConToTagFn = (Tag) => {
@@ -44,7 +45,6 @@ function addTagLib(tagLibDef) {
44
45
  }
45
46
  }
46
47
  }
47
- exports.addTagLib = addTagLib;
48
48
  function prepareTag(name, attr, body) {
49
49
  const { tagMap } = this;
50
50
  const tagFn = tagMap.get(name) || defaultTagFn;
@@ -52,7 +52,6 @@ function prepareTag(name, attr, body) {
52
52
  const tagDef = { name, app: this, attr: attrFn, body };
53
53
  return tagFn(tagDef);
54
54
  }
55
- exports.prepareTag = prepareTag;
56
55
  const defaultTagFn = (tagDef) => {
57
56
  const { name } = tagDef;
58
57
  // tagDef.app.log(`Unknown tag: ${name}`);
@@ -31,7 +31,7 @@ export class JspLoader extends BaseLoader {
31
31
  timeout: 1000,
32
32
  })(async (path) => {
33
33
  const app = this.appRef.deref();
34
- app.log(`loading: ${path}`);
34
+ app.log(`loading JSP: ${path}`);
35
35
  const text = await fs.readFile(path, "utf8");
36
36
  return app.parse(text).toFn();
37
37
  });
@@ -60,7 +60,7 @@ export class JsLoader extends BaseLoader {
60
60
  timeout: 1000,
61
61
  })(async (file) => {
62
62
  const app = this.appRef.deref();
63
- app.log(`loading: ${file}`);
63
+ app.log(`loading JS: ${file}`);
64
64
  const module = await import(file);
65
65
  const name = getName(file);
66
66
  const fn = module[name];
@@ -76,8 +76,8 @@ export class JsLoader extends BaseLoader {
76
76
  }
77
77
  async load(file) {
78
78
  file = file?.replace(/\.jsp$/, ".js");
79
- // valid only for .js files
80
- if (!/\.[cm]?js$/.test(file))
79
+ // valid only for .js-like files
80
+ if (!/\.(cjs|js|mjs|ts)$/.test(file))
81
81
  return;
82
82
  // skip when file does not exist
83
83
  if (!await this.isFile(file))
@@ -105,8 +105,8 @@ export class FileLoader extends BaseLoader {
105
105
  });
106
106
  }
107
107
  async load(file) {
108
- // disabled for JSP, JS and image files
109
- if (/\.(jsp|[cm]?js|png|gif|jpe?g)$/i.test(file))
108
+ // disabled for JSP, JS, TS and image files
109
+ if (/\.(jsp|cjs|js|mjs|ts|png|gif|jpe?g|webp)$/i.test(file))
110
110
  return;
111
111
  // skip when file does not exist
112
112
  if (!await this.isFile(file))
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nsp-server-pages",
3
3
  "description": "NSP JavaScript Server Pages for Node.js",
4
- "version": "0.2.3",
4
+ "version": "0.2.4",
5
5
  "author": "@kawanet",
6
6
  "bugs": {
7
7
  "url": "https://github.com/kawanet/nsp-server-pages/issues"
@@ -11,12 +11,11 @@
11
11
  "to-xml": "^0.1.11"
12
12
  },
13
13
  "devDependencies": {
14
- "@rollup/plugin-node-resolve": "^15.2.1",
15
- "@types/mocha": "^10.0.1",
16
- "@types/node": "^20.5.8",
17
- "mocha": "^10.2.0",
18
- "nyc": "^15.1.0",
19
- "typescript": "^5.2.2"
14
+ "@types/mocha": "^10.0.10",
15
+ "@types/node": "^25.2.0",
16
+ "mocha": "^11.7.5",
17
+ "nyc": "^17.1.0",
18
+ "typescript": "^5.9.3"
20
19
  },
21
20
  "exports": {
22
21
  "import": {