binhend 1.4.3 → 1.4.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.
- package/package.json +1 -1
- package/src/binh.web.builder.js +12 -2
- package/src/code.js +18 -0
- package/src/component.build.js +1 -0
- package/src/component.format.js +1 -1
package/package.json
CHANGED
package/src/binh.web.builder.js
CHANGED
|
@@ -14,16 +14,25 @@ function WebBuilder(binh, Binh) {
|
|
|
14
14
|
return {
|
|
15
15
|
context,
|
|
16
16
|
tag: tag.bind(context),
|
|
17
|
+
svg: svg.bind(context),
|
|
17
18
|
script: script.bind(context),
|
|
18
19
|
require: customRequire.bind(context),
|
|
19
20
|
css: css.bind(context)
|
|
20
21
|
};
|
|
21
22
|
};
|
|
22
23
|
|
|
24
|
+
function tagnames(tagNames) {
|
|
25
|
+
return typeof tagNames === 'string' ? tagNames.split(/\s+/) : [];
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
function tag(tagNames) {
|
|
24
|
-
var tags = typeof tagNames === 'string' ? tagNames.split(/\s+/) : [];
|
|
25
29
|
var htmltags = this.component.htmltags;
|
|
26
|
-
htmltags.push.apply(htmltags,
|
|
30
|
+
htmltags.push.apply(htmltags, tagnames(tagNames));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function svg(tagNames) {
|
|
34
|
+
var svgtags = this.component.svgtags;
|
|
35
|
+
svgtags.push.apply(svgtags, tagnames(tagNames));
|
|
27
36
|
}
|
|
28
37
|
|
|
29
38
|
function script() {
|
|
@@ -60,6 +69,7 @@ function WebBuilder(binh, Binh) {
|
|
|
60
69
|
component.type = type;
|
|
61
70
|
|
|
62
71
|
component.htmltags = [];
|
|
72
|
+
component.svgtags = [];
|
|
63
73
|
component.links = [];
|
|
64
74
|
component.options = { csses: [] };
|
|
65
75
|
component.vars = {};
|
package/src/code.js
CHANGED
|
@@ -189,6 +189,23 @@ function htmltags(component) {
|
|
|
189
189
|
.join(`\r\n`);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
function svgtags(component) {
|
|
193
|
+
var tags = distinctValues(component, 'svgtags');
|
|
194
|
+
|
|
195
|
+
if (!tags.length) return '';
|
|
196
|
+
|
|
197
|
+
var variablesList = tags.join(',');
|
|
198
|
+
tags = tags.map((tag) => JSON.stringify(tag));
|
|
199
|
+
|
|
200
|
+
return [
|
|
201
|
+
`Binh.SVGs = Binh.svgs(${tags.join(',')});`,
|
|
202
|
+
'',
|
|
203
|
+
`var {${variablesList}} = Binh.SVGs;`,
|
|
204
|
+
''
|
|
205
|
+
]
|
|
206
|
+
.join(`\r\n`);
|
|
207
|
+
}
|
|
208
|
+
|
|
192
209
|
function prequire(component, codes) {
|
|
193
210
|
var code = '', links = distinctValues(component, 'links');
|
|
194
211
|
|
|
@@ -249,6 +266,7 @@ function uniquefy(arrays) {
|
|
|
249
266
|
module.exports = {
|
|
250
267
|
bundle,
|
|
251
268
|
htmltags,
|
|
269
|
+
svgtags,
|
|
252
270
|
prequire,
|
|
253
271
|
IIF
|
|
254
272
|
};
|
package/src/component.build.js
CHANGED
package/src/component.format.js
CHANGED
|
@@ -7,7 +7,7 @@ const { scanNestedFiles, cloneFile, printError, makeFullDirPath } = require('./c
|
|
|
7
7
|
// [-] Enhance code by removing sync logics (except for existsSync, mkdirSync): readdir, readFileSync, (statSync?)
|
|
8
8
|
|
|
9
9
|
const PREFIX_CODE =
|
|
10
|
-
`var { context, tag, script, require, css } = binh.context(module, require);
|
|
10
|
+
`var { context, tag, svg, script, require, css } = binh.context(module, require);
|
|
11
11
|
binh.component(context, ui, service, style);
|
|
12
12
|
var ui = null, service = null, style = null;\r\n\r\n`;
|
|
13
13
|
|