binhend 2.1.8 → 2.1.10
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.js +2 -3
- package/src/configuration.js +1 -1
- package/src/web/code.js +23 -8
- package/src/web/component.build.js +1 -0
- package/src/web/component.format.js +1 -1
- package/src/web/component.method.js +5 -1
package/package.json
CHANGED
package/src/binh.js
CHANGED
|
@@ -5,7 +5,7 @@ const createCSD = require('./csd');
|
|
|
5
5
|
const cors = require('./cors');
|
|
6
6
|
const { server } = require('./server');
|
|
7
7
|
const { loadRouter, loadRoutes, mapRoutes, trycatch, Router, HttpError } = require('./api');
|
|
8
|
-
const { ConfigLoader } = require('./configuration');
|
|
8
|
+
const { ConfigLoader, config } = require('./configuration');
|
|
9
9
|
const { WebBuilder } = require('./web');
|
|
10
10
|
const { binh } = require('./web/component.method');
|
|
11
11
|
const { HttpCodes } = require('./utils/httpCodes');
|
|
@@ -15,14 +15,13 @@ const { HTTPS } = require('./https');
|
|
|
15
15
|
require('./alias');
|
|
16
16
|
|
|
17
17
|
module.exports = {
|
|
18
|
-
config: {},
|
|
19
18
|
typeOf,
|
|
20
19
|
security,
|
|
21
20
|
createCSD,
|
|
22
21
|
cors,
|
|
23
22
|
server,
|
|
24
23
|
loadRouter, loadRoutes, mapRoutes, trycatch, Router, HttpError,
|
|
25
|
-
ConfigLoader,
|
|
24
|
+
ConfigLoader, config,
|
|
26
25
|
WebBuilder,
|
|
27
26
|
binh,
|
|
28
27
|
HttpCodes,
|
package/src/configuration.js
CHANGED
package/src/web/code.js
CHANGED
|
@@ -54,7 +54,10 @@ function getDependencyDelaration(component) {
|
|
|
54
54
|
|
|
55
55
|
for (var filePath in dependencies) {
|
|
56
56
|
var { name, url, type } = dependencies[filePath];
|
|
57
|
-
if (name) {
|
|
57
|
+
if (name && type === 'service') {
|
|
58
|
+
codes.push(` ${name} = this.${type}('${url}')`);
|
|
59
|
+
}
|
|
60
|
+
else if (name) {
|
|
58
61
|
codes.push(` ${name} = Binh.${type}('${url}')`);
|
|
59
62
|
}
|
|
60
63
|
}
|
|
@@ -92,20 +95,32 @@ function getMetadataOfDependencies(component) {
|
|
|
92
95
|
return component.dependencies;
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
function generateOptionCode(component,
|
|
96
|
-
var options = component.options
|
|
98
|
+
function generateOptionCode(component, baseCode) {
|
|
99
|
+
var options = component.options;
|
|
100
|
+
|
|
101
|
+
if (!options) return ''; // TODO remove this line, seem like always have this object 'options'
|
|
97
102
|
|
|
98
|
-
|
|
103
|
+
var cssUrls = [], serviceUrls = [];
|
|
99
104
|
|
|
105
|
+
// CSS
|
|
100
106
|
component.type === 'ui' && options.csses.forEach(function(cssModule) {
|
|
101
|
-
|
|
107
|
+
cssUrls.push(JSON.stringify(cssModule.url));
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
if (cssUrls.length) {
|
|
111
|
+
baseCode += `.style([${cssUrls.join(',')}])`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Services
|
|
115
|
+
options.services.forEach(function(serviceModule) {
|
|
116
|
+
serviceUrls.push(serviceModule.url);
|
|
102
117
|
});
|
|
103
118
|
|
|
104
|
-
if (
|
|
105
|
-
|
|
119
|
+
if (serviceUrls.length) {
|
|
120
|
+
baseCode += `.service(['${serviceUrls.join("', '")}'])`;
|
|
106
121
|
}
|
|
107
122
|
|
|
108
|
-
return
|
|
123
|
+
return baseCode;
|
|
109
124
|
}
|
|
110
125
|
|
|
111
126
|
function getRelativeFilePath(filePath, rootPath) {
|
|
@@ -70,6 +70,7 @@ function lazyload(paths) {
|
|
|
70
70
|
processEachFile(paths, buildLazyCode, copyExternalComponentFiles);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/** case of components or modules are required from node_modules installed by NPM */
|
|
73
74
|
function copyExternalComponentFiles({ outputRootPath }) {
|
|
74
75
|
var cache = copyExternalComponentFiles.cache,
|
|
75
76
|
csses = copyExternalComponentFiles.csses;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { config } = require('
|
|
1
|
+
const { config } = require('../configuration');
|
|
2
2
|
const { readFileSync } = require('fs');
|
|
3
3
|
const { parse } = require('path');
|
|
4
4
|
const { scanNestedFiles, cloneFileIfNew, printError, makeFullDirPath, writeToFileIfNew } = require('./component.file');
|
|
@@ -81,7 +81,7 @@ binh.component = function(context, ui, service, style) {
|
|
|
81
81
|
component.htmltags = [];
|
|
82
82
|
component.svgtags = [];
|
|
83
83
|
component.links = [];
|
|
84
|
-
component.options = { csses: [] };
|
|
84
|
+
component.options = { csses: [], services: [] };
|
|
85
85
|
component.vars = {};
|
|
86
86
|
component.varname = getVariableName(component.filename);
|
|
87
87
|
component.as = alias;
|
|
@@ -98,6 +98,10 @@ binh.final = function(module) {
|
|
|
98
98
|
component.vars[childComponent.filename] = childComponent.alias;
|
|
99
99
|
delete childComponent.alias;
|
|
100
100
|
}
|
|
101
|
+
|
|
102
|
+
if (childComponent.type === 'service') {
|
|
103
|
+
component.options.services.push(childComponent);
|
|
104
|
+
}
|
|
101
105
|
});
|
|
102
106
|
};
|
|
103
107
|
|