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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "binhend",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "Nguyen Duc Binh",
@@ -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, tags);
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
  };
@@ -45,6 +45,7 @@ function joinCodes(component, rootPath) {
45
45
  var mainCode = CodeFormat.prequire(component, [
46
46
  `var _Binh = Binh;\r\n`,
47
47
  CodeFormat.htmltags(component),
48
+ CodeFormat.svgtags(component),
48
49
  CodeFormat.bundle(component, rootPath)
49
50
  ]);
50
51
 
@@ -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