@kosatyi/ejs 0.0.110 → 0.0.112

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.
@@ -3,8 +3,8 @@
3
3
  var fs = require('node:fs/promises');
4
4
  var globWatch = require('glob-watcher');
5
5
  var node_path = require('node:path');
6
- var index_js = require('./index.js');
7
6
  var glob = require('glob');
7
+ var index_js = require('./index.js');
8
8
 
9
9
  const symbolEntities = {
10
10
  "'": "'",
@@ -51,6 +51,7 @@ class EjsBundler {
51
51
  #ejsOptions
52
52
  #buildInProgress
53
53
  static exports = ['build', 'watch', 'concat', 'output']
54
+
54
55
  constructor(bundlerOptions = {}, ejsOptions = {}) {
55
56
  bindContext(this, this.constructor.exports);
56
57
  const { compile, configure } = index_js.create(ejsOptions);
@@ -60,14 +61,17 @@ class EjsBundler {
60
61
  this.#buildInProgress = false;
61
62
  this.#templates = {};
62
63
  }
64
+
63
65
  async #stageRead(path) {
64
66
  return fs
65
67
  .readFile(node_path.join(this.#ejsOptions.path, path))
66
68
  .then((response) => response.toString())
67
69
  }
70
+
68
71
  #stageCompile(content, name) {
69
72
  return this.#compile(content, name).source
70
73
  }
74
+
71
75
  #getBundle() {
72
76
  const umd = this.#bundlerOptions.umd;
73
77
  const strict = this.#ejsOptions.strict;
@@ -102,6 +106,7 @@ class EjsBundler {
102
106
  }
103
107
  return out.join('\n')
104
108
  }
109
+
105
110
  async build() {
106
111
  if (this.#buildInProgress === true) return false
107
112
  this.#buildInProgress = true;
@@ -110,6 +115,7 @@ class EjsBundler {
110
115
  console.log('✅', 'bundle complete:', this.#bundlerOptions.target);
111
116
  this.#buildInProgress = false;
112
117
  }
118
+
113
119
  async watch() {
114
120
  console.log('🔍', 'watch directory:', this.#ejsOptions.path);
115
121
  const pattern = '**/*.'.concat(this.#ejsOptions.extension);
@@ -130,6 +136,7 @@ class EjsBundler {
130
136
  });
131
137
  });
132
138
  }
139
+
133
140
  async concat() {
134
141
  const pattern = '**/*.'.concat(this.#ejsOptions.extension);
135
142
  const list = await glob.glob(
@@ -144,6 +151,7 @@ class EjsBundler {
144
151
  this.#templates[template] = content;
145
152
  }
146
153
  }
154
+
147
155
  async output() {
148
156
  const target = [].concat(this.#bundlerOptions.target);
149
157
  const content = this.#getBundle();
@@ -44,7 +44,7 @@ const eachAttribute = _ref => {
44
44
  const element = (tag, attrs, content) => {
45
45
  const result = [];
46
46
  const hasClosedTag = selfClosed.indexOf(tag) === -1;
47
- const attributes = Object.entries(attrs ?? {}).map(eachAttribute).filter(e => e).join(space);
47
+ const attributes = Object.entries(attrs !== null && attrs !== void 0 ? attrs : {}).map(eachAttribute).filter(e => e).join(space);
48
48
  result.push([lt, tag, space, attributes, gt].join(''));
49
49
  if (content && hasClosedTag) {
50
50
  result.push(Array.isArray(content) ? content.join('') : content);