binhend 1.1.5 → 1.1.6
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 +14 -14
- package/src/code.js +15 -1
package/package.json
CHANGED
package/src/binh.web.builder.js
CHANGED
|
@@ -4,42 +4,42 @@ const path = require('path');
|
|
|
4
4
|
const Component = require('./component');
|
|
5
5
|
|
|
6
6
|
function WebBuilder(binh, Binh) {
|
|
7
|
-
binh.ui = function(
|
|
7
|
+
binh.ui = function(module, component, htmltags, links) {
|
|
8
8
|
component.htmltags = htmltags;
|
|
9
9
|
component.links = links;
|
|
10
|
-
binh.bundle('ui',
|
|
10
|
+
binh.bundle('ui', module, component);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
binh.service = function(
|
|
13
|
+
binh.service = function(module, component, links) {
|
|
14
14
|
component.links = links;
|
|
15
|
-
binh.bundle('service',
|
|
15
|
+
binh.bundle('service', module, component);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
binh.style = function(
|
|
19
|
-
binh.bundle('style',
|
|
18
|
+
binh.style = function(module, component) {
|
|
19
|
+
binh.bundle('style', module, component);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
binh.css = function(
|
|
23
|
-
var cssFilePath = cssFilename && path.join(
|
|
22
|
+
binh.css = function(module, cssFilename) {
|
|
23
|
+
var cssFilePath = cssFilename && path.join(module.path, cssFilename) || module.filename.replace(/.js$/, '');
|
|
24
24
|
var content = require('fs').readFileSync(cssFilePath, { encoding: 'utf8', flag: 'r' });
|
|
25
25
|
content = content.replace(/\s+/g, ' ');
|
|
26
26
|
var component = new Function(`return ${JSON.stringify(content)};`);
|
|
27
|
-
binh.bundle('style',
|
|
27
|
+
binh.bundle('style', module, component);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
binh.bundle = function(type,
|
|
30
|
+
binh.bundle = function(type, module, component) {
|
|
31
31
|
if (!(component instanceof Function)) return;
|
|
32
32
|
|
|
33
33
|
component.type = type;
|
|
34
|
-
component.filename =
|
|
34
|
+
component.filename = module.filename;
|
|
35
35
|
component.constructor = Component;
|
|
36
|
-
component.module =
|
|
36
|
+
component.module = module;
|
|
37
37
|
component.as = alias;
|
|
38
38
|
component.vars = {};
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
module.exports = component;
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
module.children.forEach(function(child) {
|
|
43
43
|
child = child.exports;
|
|
44
44
|
if (child.constructor !== Component) return;
|
|
45
45
|
if (child.alias) component.vars[child.filename] = child.alias;
|
package/src/code.js
CHANGED
|
@@ -125,15 +125,29 @@ function IIF(codes) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
function distinctValues(component, key) {
|
|
128
|
-
var arrays = [component[key]];
|
|
128
|
+
var arrays = [component[key]], ref = {};
|
|
129
|
+
|
|
130
|
+
ref[component.filename] = true;
|
|
129
131
|
|
|
130
132
|
component.module.children.forEach(function(child) {
|
|
133
|
+
if (ref[child.filename]) return;
|
|
134
|
+
ref[child.filename] = true;
|
|
131
135
|
arrays.push(child.exports[key]);
|
|
136
|
+
getArraysFromDeeperChildren(ref, arrays, child, key);
|
|
132
137
|
});
|
|
133
138
|
|
|
134
139
|
return uniquefy(arrays);
|
|
135
140
|
}
|
|
136
141
|
|
|
142
|
+
function getArraysFromDeeperChildren(ref, arrays, module, key) {
|
|
143
|
+
module.children.forEach(function(child) {
|
|
144
|
+
if (ref[child.filename]) return;
|
|
145
|
+
ref[child.filename] = true;
|
|
146
|
+
arrays.push(child.exports[key]);
|
|
147
|
+
getArraysFromDeeperChildren(ref, arrays, child, key);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
137
151
|
function uniquefy(arrays) {
|
|
138
152
|
var map = {};
|
|
139
153
|
|