2015-03-23 22:07:33 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
2015-02-06 23:45:28 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-01-30 01:10:49 +00:00
|
|
|
var Activity = require('./src/Activity');
|
2015-02-06 23:45:28 +00:00
|
|
|
var Server = require('./src/Server');
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2015-02-06 23:45:28 +00:00
|
|
|
exports.middleware = function(options) {
|
|
|
|
var server = new Server(options);
|
|
|
|
return server.processRequest.bind(server);
|
2015-01-30 01:10:49 +00:00
|
|
|
};
|
|
|
|
|
2015-02-06 23:45:28 +00:00
|
|
|
exports.buildPackageFromUrl = function(options, reqUrl) {
|
|
|
|
Activity.disable();
|
2015-02-19 01:51:14 +00:00
|
|
|
// Don't start the filewatcher or the cache.
|
|
|
|
if (options.nonPersistent == null) {
|
|
|
|
options.nonPersistent = true;
|
|
|
|
}
|
|
|
|
|
2015-02-06 23:45:28 +00:00
|
|
|
var server = new Server(options);
|
|
|
|
return server.buildPackageFromUrl(reqUrl)
|
|
|
|
.then(function(p) {
|
2015-02-19 01:51:14 +00:00
|
|
|
server.end();
|
2015-02-06 23:45:28 +00:00
|
|
|
return p;
|
|
|
|
});
|
2015-01-30 01:10:49 +00:00
|
|
|
};
|
2015-02-19 01:51:14 +00:00
|
|
|
|
|
|
|
exports.getDependencies = function(options, main) {
|
|
|
|
Activity.disable();
|
|
|
|
// Don't start the filewatcher or the cache.
|
|
|
|
if (options.nonPersistent == null) {
|
|
|
|
options.nonPersistent = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
var server = new Server(options);
|
|
|
|
return server.getDependencies(main)
|
|
|
|
.then(function(r) {
|
|
|
|
server.end();
|
|
|
|
return r.dependencies;
|
|
|
|
});
|
|
|
|
};
|