@kosatyi/ejs 0.0.106 → 0.0.107

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.
@@ -525,7 +525,6 @@ var createContextScope = function createContextScope(config, methods) {
525
525
  SCOPE = _config$vars.SCOPE,
526
526
  COMPONENT = _config$vars.COMPONENT,
527
527
  ELEMENT = _config$vars.ELEMENT;
528
-
529
528
  /**
530
529
  *
531
530
  * @type {symbol}
@@ -823,18 +822,20 @@ var createContextScope = function createContextScope(config, methods) {
823
822
  return ContextScope;
824
823
  };
825
824
  var Context = function Context(options, methods) {
825
+ var config = {
826
+ Scope: null
827
+ };
826
828
  /**
827
- * @type {InstanceType<ContextScope>}
829
+ * @return {ContextScope}
828
830
  */
829
- var Scope;
830
831
  var create = function create(data) {
831
- return new Scope(data);
832
+ return new config.Scope(data);
832
833
  };
833
834
  var helpers = function helpers(methods) {
834
- extend(Scope.prototype, methods || {});
835
+ extend(config.Scope.prototype, methods || {});
835
836
  };
836
837
  var configure = function configure(options, methods) {
837
- Scope = createContextScope(options, methods);
838
+ config.Scope = createContextScope(options, methods);
838
839
  };
839
840
  configure(options, methods);
840
841
  return {
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ var globWatch = require('glob-watcher');
3
4
  var node_fs = require('node:fs');
4
5
  var node_path = require('node:path');
5
6
  var glob = require('glob');
6
- var globWatch = require('glob-watcher');
7
7
  var index_js = require('./index.js');
8
8
 
9
- const isPlainObject = function(obj) {
9
+ const isPlainObject = function (obj) {
10
10
  return Object.prototype.toString.call(obj) === '[object Object]'
11
11
  };
12
12
 
@@ -18,10 +18,10 @@ const Bundler = (params = {}, ejsParams = {}) => {
18
18
  const config = {
19
19
  target: [],
20
20
  umd: true,
21
- minify: true
21
+ minify: true,
22
22
  };
23
- const ejs = index_js.create();
24
- const ejsConfig = ejs.configure(ejsParams);
23
+ const { compile, configure } = index_js.create();
24
+ const ejsConfig = configure(ejsParams);
25
25
  const templates = {};
26
26
  extend(config, params || {});
27
27
  const stageRead = (path) => {
@@ -30,7 +30,7 @@ const Bundler = (params = {}, ejsParams = {}) => {
30
30
  .then((response) => response.toString())
31
31
  };
32
32
  const stageCompile = (content, name) => {
33
- return ejs.compile(content, name).source
33
+ return compile(content, name).source
34
34
  };
35
35
  const getBundle = () => {
36
36
  const umd = config.umd;
@@ -40,14 +40,14 @@ const Bundler = (params = {}, ejsParams = {}) => {
40
40
  if (umd) {
41
41
  out.push('(function(global,factory){');
42
42
  out.push(
43
- 'typeof exports === "object" && typeof module !== "undefined" ?'
43
+ 'typeof exports === "object" && typeof module !== "undefined" ?',
44
44
  );
45
45
  out.push('module.exports = factory():');
46
46
  out.push(
47
- 'typeof define === "function" && define.amd ? define(factory):'
47
+ 'typeof define === "function" && define.amd ? define(factory):',
48
48
  );
49
49
  out.push(
50
- '(global = typeof globalThis !== "undefined" ? globalThis:'
50
+ '(global = typeof globalThis !== "undefined" ? globalThis:',
51
51
  );
52
52
  out.push(`global || self,global["${module}"] = factory())`);
53
53
  out.push('})(this,(function(){');
@@ -66,7 +66,6 @@ const Bundler = (params = {}, ejsParams = {}) => {
66
66
  }
67
67
  return out.join('\n')
68
68
  };
69
-
70
69
  const watch = async () => {
71
70
  console.log('🔍', 'watch directory:', ejsConfig.path);
72
71
  const pattern = '**/*.'.concat(ejsConfig.extension);
@@ -87,7 +86,6 @@ const Bundler = (params = {}, ejsParams = {}) => {
87
86
  });
88
87
  });
89
88
  };
90
-
91
89
  const concat = async () => {
92
90
  const pattern = '**/*.'.concat(ejsConfig.extension);
93
91
  const list = await glob.glob(pattern, { cwd: ejsConfig.path });
@@ -98,7 +96,6 @@ const Bundler = (params = {}, ejsParams = {}) => {
98
96
  templates[template] = content;
99
97
  }
100
98
  };
101
-
102
99
  const build = async () => {
103
100
  if (config.buildInProgress === true) return false
104
101
  config.buildInProgress = true;
@@ -107,7 +104,6 @@ const Bundler = (params = {}, ejsParams = {}) => {
107
104
  console.log('✅', 'bundle complete:', config.target);
108
105
  config.buildInProgress = false;
109
106
  };
110
-
111
107
  const output = async () => {
112
108
  const target = [].concat(config.target);
113
109
  const content = getBundle();
@@ -123,17 +119,14 @@ const Bundler = (params = {}, ejsParams = {}) => {
123
119
  await node_fs.promises.writeFile(file, content);
124
120
  }
125
121
  };
126
-
127
122
  return {
128
123
  build,
129
124
  watch,
130
125
  concat,
131
- output
126
+ output,
132
127
  }
133
-
134
128
  };
135
129
 
136
-
137
130
  const ejsBundler = (options, config) => {
138
131
  const bundler = new Bundler(options, config);
139
132
  return {
@@ -143,7 +136,7 @@ const ejsBundler = (options, config) => {
143
136
  },
144
137
  async buildEnd() {
145
138
  await bundler.output();
146
- }
139
+ },
147
140
  }
148
141
  };
149
142
 
package/dist/cjs/index.js CHANGED
@@ -528,7 +528,6 @@ var createContextScope = function createContextScope(config, methods) {
528
528
  SCOPE = _config$vars.SCOPE,
529
529
  COMPONENT = _config$vars.COMPONENT,
530
530
  ELEMENT = _config$vars.ELEMENT;
531
-
532
531
  /**
533
532
  *
534
533
  * @type {symbol}
@@ -826,18 +825,20 @@ var createContextScope = function createContextScope(config, methods) {
826
825
  return ContextScope;
827
826
  };
828
827
  var Context = function Context(options, methods) {
828
+ var config = {
829
+ Scope: null
830
+ };
829
831
  /**
830
- * @type {InstanceType<ContextScope>}
832
+ * @return {ContextScope}
831
833
  */
832
- var Scope;
833
834
  var create = function create(data) {
834
- return new Scope(data);
835
+ return new config.Scope(data);
835
836
  };
836
837
  var helpers = function helpers(methods) {
837
- extend(Scope.prototype, methods || {});
838
+ extend(config.Scope.prototype, methods || {});
838
839
  };
839
840
  var configure = function configure(options, methods) {
840
- Scope = createContextScope(options, methods);
841
+ config.Scope = createContextScope(options, methods);
841
842
  };
842
843
  configure(options, methods);
843
844
  return {
@@ -790,7 +790,6 @@ var createContextScope = function createContextScope(config, methods) {
790
790
  SCOPE = _config$vars.SCOPE,
791
791
  COMPONENT = _config$vars.COMPONENT,
792
792
  ELEMENT = _config$vars.ELEMENT;
793
-
794
793
  /**
795
794
  *
796
795
  * @type {symbol}
@@ -1088,18 +1087,20 @@ var createContextScope = function createContextScope(config, methods) {
1088
1087
  return ContextScope;
1089
1088
  };
1090
1089
  var Context = function Context(options, methods) {
1090
+ var config = {
1091
+ Scope: null
1092
+ };
1091
1093
  /**
1092
- * @type {InstanceType<ContextScope>}
1094
+ * @return {ContextScope}
1093
1095
  */
1094
- var Scope;
1095
1096
  var create = function create(data) {
1096
- return new Scope(data);
1097
+ return new config.Scope(data);
1097
1098
  };
1098
1099
  var helpers = function helpers(methods) {
1099
- extend(Scope.prototype, methods || {});
1100
+ extend(config.Scope.prototype, methods || {});
1100
1101
  };
1101
1102
  var configure = function configure(options, methods) {
1102
- Scope = createContextScope(options, methods);
1103
+ config.Scope = createContextScope(options, methods);
1103
1104
  };
1104
1105
  configure(options, methods);
1105
1106
  return {
@@ -1238,7 +1239,6 @@ var setTemplates = useTemplates;
1238
1239
  * @property {function(name:string,data:{}):Promise<string>} ejs
1239
1240
  * @property {ContextScope} data
1240
1241
  */
1241
-
1242
1242
  /**
1243
1243
  * @param {Object<string,any>} options
1244
1244
  * @return {(function(c:HonoContext, next): Promise<any>)|*}