binhend 2.1.12 → 2.1.13
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/web/component.method.js +19 -13
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ const binh = {};
|
|
|
9
9
|
|
|
10
10
|
global.binh = binh;
|
|
11
11
|
|
|
12
|
-
binh.context = function(module, defaultRequire) {
|
|
12
|
+
binh.context = function (module, defaultRequire) {
|
|
13
13
|
var context = { module, require: defaultRequire };
|
|
14
14
|
|
|
15
15
|
return {
|
|
@@ -43,8 +43,10 @@ function script() {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
function customRequire(filePath) {
|
|
46
|
-
filePath = filePath.endsWith('.css') ? (filePath+'.js') : filePath;
|
|
47
|
-
|
|
46
|
+
filePath = filePath.endsWith('.css') ? (filePath + '.js') : filePath;
|
|
47
|
+
var childComponent = this.require(filePath);
|
|
48
|
+
childComponent.parent = this.component;
|
|
49
|
+
return childComponent;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
function applyDefaultFileCSS() {
|
|
@@ -53,7 +55,7 @@ function applyDefaultFileCSS() {
|
|
|
53
55
|
var cssModule = this.require('./' + cssModuleFile);
|
|
54
56
|
css.bind(this)(cssModule);
|
|
55
57
|
}
|
|
56
|
-
catch (error) {}
|
|
58
|
+
catch (error) { }
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
function css() {
|
|
@@ -62,7 +64,7 @@ function css() {
|
|
|
62
64
|
appliedStyles.push.apply(appliedStyles, csses);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
binh.component = function(context, ui, service, style) {
|
|
67
|
+
binh.component = function (context, ui, service, style) {
|
|
66
68
|
var component = ui || service || style;
|
|
67
69
|
var type = ui && 'ui' || service && 'service' || style && 'style';
|
|
68
70
|
|
|
@@ -86,17 +88,17 @@ binh.component = function(context, ui, service, style) {
|
|
|
86
88
|
component.varname = getVariableName(component.filename);
|
|
87
89
|
component.as = alias;
|
|
88
90
|
component.eachChild = loopComponentChildren;
|
|
89
|
-
|
|
91
|
+
|
|
90
92
|
if (type === 'ui') applyDefaultFileCSS.bind(context)();
|
|
91
93
|
};
|
|
92
94
|
|
|
93
|
-
binh.final = function(module) {
|
|
95
|
+
binh.final = function (module) {
|
|
94
96
|
var component = module.exports;
|
|
95
97
|
|
|
96
98
|
component.eachChild && component.eachChild(childComponent => {
|
|
97
|
-
if (childComponent.alias) {
|
|
98
|
-
component.vars[childComponent.filename] = childComponent.alias;
|
|
99
|
-
delete childComponent.alias;
|
|
99
|
+
if (childComponent.alias?.[component.filename]) {
|
|
100
|
+
component.vars[childComponent.filename] = childComponent.alias?.[component.filename];
|
|
101
|
+
delete childComponent.alias?.[component.filename];
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
if (childComponent.type === 'service') {
|
|
@@ -113,7 +115,7 @@ function loopComponentChildren(callback) {
|
|
|
113
115
|
});
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
binh.css = function(module, cssFilename) {
|
|
118
|
+
binh.css = function (module, cssFilename) {
|
|
117
119
|
var cssFilePath = cssFilename && path.join(module.path, cssFilename) || module.filename.replace(/.js$/, '');
|
|
118
120
|
var content = fs.readFileSync(cssFilePath, { encoding: 'utf8', flag: 'r' });
|
|
119
121
|
content = UglifyCSS.processString(content);
|
|
@@ -123,12 +125,16 @@ binh.css = function(module, cssFilename) {
|
|
|
123
125
|
binh.final(module);
|
|
124
126
|
};
|
|
125
127
|
|
|
126
|
-
binh.Binh = function() {}; // dummy Binh object for binhjs => build web not logging error of undefined
|
|
128
|
+
binh.Binh = function () { }; // dummy Binh object for binhjs => build web not logging error of undefined
|
|
127
129
|
|
|
128
130
|
function alias(name) {
|
|
129
131
|
if (!isString(name)) return this;
|
|
130
132
|
name = name.trim();
|
|
131
|
-
|
|
133
|
+
|
|
134
|
+
var alias = this.alias || (this.alias = {});
|
|
135
|
+
if (this.parent) alias[this.parent.filename] = name;
|
|
136
|
+
delete this.parent;
|
|
137
|
+
|
|
132
138
|
return this;
|
|
133
139
|
}
|
|
134
140
|
|