@kosatyi/ejs 0.0.96 → 0.0.98
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.
- package/dist/cjs/browser.js +923 -649
- package/dist/cjs/bundler.js +28 -22
- package/dist/cjs/element.js +8 -1
- package/dist/cjs/index.js +932 -657
- package/dist/cjs/worker.js +919 -647
- package/dist/esm/browser.js +691 -609
- package/dist/esm/bundler.js +21 -15
- package/dist/esm/element.js +12 -2
- package/dist/esm/index.js +700 -618
- package/dist/esm/worker.js +707 -626
- package/dist/umd/browser.js +1136 -862
- package/dist/umd/browser.min.js +1 -1
- package/dist/umd/element.js +8 -1
- package/dist/umd/element.min.js +1 -1
- package/dist/umd/index.js +1170 -895
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +919 -647
- package/dist/umd/worker.min.js +1 -1
- package/package.json +1 -1
- package/types/global.d.ts +4 -0
package/dist/esm/bundler.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { promises } from 'fs';
|
|
1
|
+
import { promises } from 'node:fs';
|
|
2
|
+
import { join, dirname } from 'node:path';
|
|
2
3
|
import { glob } from 'glob';
|
|
3
4
|
import watch from 'glob-watcher';
|
|
4
|
-
import { join, dirname } from 'path';
|
|
5
5
|
import { create } from './index.js';
|
|
6
6
|
|
|
7
|
-
const isPlainObject = function(obj) {
|
|
7
|
+
const isPlainObject = function (obj) {
|
|
8
8
|
return Object.prototype.toString.call(obj) === '[object Object]'
|
|
9
9
|
};
|
|
10
10
|
|
|
@@ -19,7 +19,7 @@ class Bundler {
|
|
|
19
19
|
options = {
|
|
20
20
|
target: [],
|
|
21
21
|
umd: true,
|
|
22
|
-
minify: true
|
|
22
|
+
minify: true,
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* @type {EjsConfig}
|
|
@@ -55,10 +55,16 @@ class Bundler {
|
|
|
55
55
|
const out = [];
|
|
56
56
|
if (umd) {
|
|
57
57
|
out.push('(function(global,factory){');
|
|
58
|
-
out.push(
|
|
58
|
+
out.push(
|
|
59
|
+
'typeof exports === "object" && typeof module !== "undefined" ?'
|
|
60
|
+
);
|
|
59
61
|
out.push('module.exports = factory():');
|
|
60
|
-
out.push(
|
|
61
|
-
|
|
62
|
+
out.push(
|
|
63
|
+
'typeof define === "function" && define.amd ? define(factory):'
|
|
64
|
+
);
|
|
65
|
+
out.push(
|
|
66
|
+
'(global = typeof globalThis !== "undefined" ? globalThis:'
|
|
67
|
+
);
|
|
62
68
|
out.push(`global || self,global["${module}"] = factory())`);
|
|
63
69
|
out.push('})(this,(function(){');
|
|
64
70
|
}
|
|
@@ -82,16 +88,16 @@ class Bundler {
|
|
|
82
88
|
const watcher = watch(pattern, { cwd: this.config.path });
|
|
83
89
|
const state = { build: null };
|
|
84
90
|
watcher.on('change', (path) => {
|
|
85
|
-
if(state.build) return
|
|
86
|
-
console.log('⟳','file change:',path);
|
|
87
|
-
state.build = this.build().then(()=>{
|
|
91
|
+
if (state.build) return
|
|
92
|
+
console.log('⟳', 'file change:', path);
|
|
93
|
+
state.build = this.build().then(() => {
|
|
88
94
|
state.build = null;
|
|
89
95
|
});
|
|
90
96
|
});
|
|
91
97
|
watcher.on('add', (path) => {
|
|
92
|
-
if(state.build) return
|
|
93
|
-
console.log('+','file added:',path);
|
|
94
|
-
state.build = this.build().then(()=>{
|
|
98
|
+
if (state.build) return
|
|
99
|
+
console.log('+', 'file added:', path);
|
|
100
|
+
state.build = this.build().then(() => {
|
|
95
101
|
state.build = null;
|
|
96
102
|
});
|
|
97
103
|
});
|
|
@@ -102,7 +108,7 @@ class Bundler {
|
|
|
102
108
|
this.buildInProgress = true;
|
|
103
109
|
await this.concat().catch(console.error);
|
|
104
110
|
await this.output().catch(console.error);
|
|
105
|
-
console.log('✅','bundle complete:',this.options.target);
|
|
111
|
+
console.log('✅', 'bundle complete:', this.options.target);
|
|
106
112
|
this.buildInProgress = false;
|
|
107
113
|
}
|
|
108
114
|
|
|
@@ -142,7 +148,7 @@ const ejsBundler = (options, config) => {
|
|
|
142
148
|
},
|
|
143
149
|
async buildEnd() {
|
|
144
150
|
await bundler.output();
|
|
145
|
-
}
|
|
151
|
+
},
|
|
146
152
|
}
|
|
147
153
|
};
|
|
148
154
|
|
package/dist/esm/element.js
CHANGED
|
@@ -38,7 +38,11 @@ const entities = (string = '') => {
|
|
|
38
38
|
|
|
39
39
|
const safeValue = (value, escape) => {
|
|
40
40
|
const check = value;
|
|
41
|
-
return check == null
|
|
41
|
+
return check == null
|
|
42
|
+
? ''
|
|
43
|
+
: Boolean(escape) === true
|
|
44
|
+
? entities(check)
|
|
45
|
+
: check
|
|
42
46
|
};
|
|
43
47
|
|
|
44
48
|
const each = (object, callback) => {
|
|
@@ -63,6 +67,12 @@ const map = (object, callback, context) => {
|
|
|
63
67
|
return result
|
|
64
68
|
};
|
|
65
69
|
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @param object
|
|
73
|
+
* @param prop
|
|
74
|
+
* @return {boolean}
|
|
75
|
+
*/
|
|
66
76
|
const hasProp = (object, prop) => {
|
|
67
77
|
return object && object.hasOwnProperty(prop)
|
|
68
78
|
};
|
|
@@ -103,7 +113,7 @@ const element = (tag, attrs, content) => {
|
|
|
103
113
|
}
|
|
104
114
|
}).join(space);
|
|
105
115
|
result.push([lt, tag, space, attributes, gt].join(''));
|
|
106
|
-
if (content) {
|
|
116
|
+
if (content && hasClosedTag) {
|
|
107
117
|
result.push(content instanceof Array ? content.join('') : content);
|
|
108
118
|
}
|
|
109
119
|
if (hasClosedTag) {
|