binhend 1.4.2 → 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 +23 -4
- 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
|
@@ -43,7 +43,7 @@ function getCodeOfDependencies(component, rootPath, metadata) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
function injectFunctionCodeContent(functionCodeString, injectionCode) {
|
|
46
|
-
return functionCodeString.replace(/(\(
|
|
46
|
+
return functionCodeString.replace(/(\(.*?\)\s*{|\(.*?\)\s*=>\s*{)/, `$1\r\n${injectionCode}`);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function getDependencyDelaration(component, rootPath) {
|
|
@@ -143,7 +143,6 @@ function getRelativeFilePath(filePath, rootPath) {
|
|
|
143
143
|
getRelativeFilePath.cache = {};
|
|
144
144
|
|
|
145
145
|
function bundle(component, rootPath) {
|
|
146
|
-
var codeOfDependencies = getCodeOfDependencies(component, rootPath);
|
|
147
146
|
var dependencyDelaration = getDependencyDelaration(component, rootPath);
|
|
148
147
|
var optionCode = generateOptionCode(component, '', rootPath);
|
|
149
148
|
var componentCode = component.toString();
|
|
@@ -154,11 +153,13 @@ function bundle(component, rootPath) {
|
|
|
154
153
|
|
|
155
154
|
var codes = [];
|
|
156
155
|
|
|
157
|
-
if (codeOfDependencies) codes.push(codeOfDependencies);
|
|
158
156
|
if (componentCode) {
|
|
159
157
|
codes.push(`Binh.${component.type}(${component.type})${optionCode};`);
|
|
160
|
-
codes.push(`${componentCode}`);
|
|
158
|
+
codes.push(`${componentCode}\r\n`);
|
|
161
159
|
}
|
|
160
|
+
|
|
161
|
+
var codeOfDependencies = getCodeOfDependencies(component, rootPath);
|
|
162
|
+
if (codeOfDependencies) codes.push(codeOfDependencies);
|
|
162
163
|
|
|
163
164
|
return codes.join('\r\n');
|
|
164
165
|
}
|
|
@@ -188,6 +189,23 @@ function htmltags(component) {
|
|
|
188
189
|
.join(`\r\n`);
|
|
189
190
|
}
|
|
190
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
|
+
|
|
191
209
|
function prequire(component, codes) {
|
|
192
210
|
var code = '', links = distinctValues(component, 'links');
|
|
193
211
|
|
|
@@ -248,6 +266,7 @@ function uniquefy(arrays) {
|
|
|
248
266
|
module.exports = {
|
|
249
267
|
bundle,
|
|
250
268
|
htmltags,
|
|
269
|
+
svgtags,
|
|
251
270
|
prequire,
|
|
252
271
|
IIF
|
|
253
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
|
|