Change client.* to web.* and accept client and web

This commit is contained in:
Matthew Arbesfeld
2014-08-28 13:34:49 -07:00
parent 91b193d5fb
commit 0af50c04ef
11 changed files with 89 additions and 87 deletions

View File

@@ -14,10 +14,10 @@ Package.on_use(function (api) {
api.use(['livedata', 'mongo-livedata', 'underscore'], ['client', 'server']);
api.use('deps', 'client');
api.use('reload', 'client', {weak: true});
api.use('http', 'client.cordova');
api.use('http', 'web.cordova');
api.export('Autoupdate');
api.add_files('autoupdate_server.js', 'server');
api.add_files('autoupdate_client.js', 'client.browser');
api.add_files('autoupdate_cordova.js', 'client.cordova');
api.add_files('autoupdate_client.js', 'web.browser');
api.add_files('autoupdate_cordova.js', 'web.cordova');
});

View File

@@ -4,7 +4,7 @@ Package.describe({
});
Package.on_use(function (api) {
api.export('FastClick', 'client.cordova');
api.export('FastClick', 'web.cordova');
api.addFiles(['pre.js', 'fastclick.js', 'post.js'], 'client.cordova');
api.addFiles(['pre.js', 'fastclick.js', 'post.js'], 'web.cordova');
});

View File

@@ -15,7 +15,7 @@ Package.on_use(function (api) {
api.export('Log');
api.use(['underscore', 'ejson']);
api.add_files('logging.js');
api.add_files('logging_cordova.js', 'client.cordova');
api.add_files('logging_cordova.js', 'web.cordova');
});
Package.on_test(function (api) {

View File

@@ -16,7 +16,7 @@ Package.on_use(function (api) {
api.export('Meteor');
api.add_files('client_environment.js', 'client');
api.add_files('cordova_environment.js', 'client.cordova');
api.add_files('cordova_environment.js', 'web.cordova');
api.add_files('server_environment.js', 'server');
api.add_files('helpers.js', ['client', 'server']);
api.add_files('setimmediate.js', ['client', 'server']);
@@ -42,9 +42,9 @@ Package.on_use(function (api) {
Package.on_test(function (api) {
api.use(['underscore', 'tinytest', 'test-helpers']);
api.add_files('browser_environment_test.js', 'client.browser');
api.add_files('browser_environment_test.js', 'web.browser');
api.add_files('client_environment_test.js', 'client');
api.add_files('cordova_environment_test.js', 'client.cordova');
api.add_files('cordova_environment_test.js', 'web.cordova');
api.add_files('server_environment_test.js', 'server');
api.add_files('helpers_test.js', ['client', 'server']);

View File

@@ -4,7 +4,7 @@ Package.describe({
});
Package.onUse(function(api) {
api.addFiles('mobile-status-bar.js', 'client.cordova');
api.addFiles('mobile-status-bar.js', 'web.cordova');
});
Cordova.depends({

View File

@@ -4,6 +4,6 @@ Package.describe({
});
Package.on_use(function (api) {
api.use(['reload', 'deps'], 'client.cordova');
api.add_files("reload-on-resume.js", 'client.cordova');
api.use(['reload', 'deps'], 'web.cordova');
api.add_files("reload-on-resume.js", 'web.cordova');
});

View File

@@ -60,5 +60,5 @@ Package.on_use(function(api) {
'fastclick',
// Good defaults for the mobile status bar
'mobile-status-bar'
], 'client.cordova');
], 'web.cordova');
});

View File

@@ -82,7 +82,7 @@ Tinytest.add("webapp - additional static javascript", function (test) {
var boilerplate = WebAppInternals.getBoilerplate({
browser: "doesn't-matter",
url: "also-doesnt-matter"
}, "client.browser");
}, "web.browser");
// When inline scripts are allowed, the script should be inlined.
test.isTrue(boilerplate.indexOf(additionalScript) !== -1);

View File

@@ -1399,7 +1399,7 @@ _.extend(ServerTarget.prototype, {
builder.reserve('dependencies');
// Mapping from arch to relative path to the client program, if we have any
// (hack). Ex.: { 'client.browser': '../client.browser/program.json', ... }
// (hack). Ex.: { 'web.browser': '../web.browser/program.json', ... }
var clientTargetPaths = {};
if (self.clientTargets) {
_.each(self.clientTargets, function (target) {

View File

@@ -93,14 +93,17 @@ var loadOrderSort = function (templateExtensions) {
};
};
// XXX We currently have a 1 to 1 mapping between 'where' and 'arch'.
// In the future, we may let people specify different 'where' and 'arch'.
// We currently have a 1 to 1 mapping between 'where' and 'arch'.
// 'client' -> 'web'
// 'server' -> 'os'
// '*' -> '*'
var mapWhereToArch = function (where) {
if (where === 'server') {
return 'os';
} else if (where === 'client') {
return 'web';
} else {
// Transform client.* into web.*
return 'web.' + where.split('.').slice(1).join('.');
return where;
}
};
@@ -315,9 +318,9 @@ var PackageSource = function (catalog) {
// this option transparent to the user in package.js.
self.noVersionFile = false;
// The list of where that we can target. Doesn't include 'client' because
// it is expanded into 'client.*'.
self.allWheres = ['server', 'client.browser', 'client.cordova'];
// The list of archs that we can target. Doesn't include 'web' because
// it is expanded into 'web.*'.
self.allArchs = ['os', 'web.browser', 'web.cordova'];
};
@@ -813,20 +816,20 @@ _.extend(PackageSource.prototype, {
var uses = {};
var implies = {};
_.each(self.allWheres, function (where) {
sources[where] = [];
exports[where] = [];
uses[where] = [];
implies[where] = [];
_.each(self.allArchs, function (arch) {
sources[arch] = [];
exports[arch] = [];
uses[arch] = [];
implies[arch] = [];
});
// Iterates over the list of target archs and calls f(arch) for all archs
// that match an element of 'wheres'.
var forAllMatchingWheres = function (wheres, f) {
_.each(wheres, function (where) {
_.each(self.allWheres, function (matchWhere) {
if (archinfo.matches(matchWhere, where)) {
f(matchWhere);
// that match an element of self.allarchs.
var forAllMatchingArchs = function (archs, f) {
_.each(archs, function (arch) {
_.each(self.allArchs, function (matchArch) {
if (archinfo.matches(matchArch, arch)) {
f(matchArch);
}
});
});
@@ -852,23 +855,24 @@ _.extend(PackageSource.prototype, {
return x ? [x] : [];
};
var toWhereArray = function (where) {
if (!(where instanceof Array)) {
where = where ? [where] : self.allWheres;
var toArchArray = function (arch) {
if (!(arch instanceof Array)) {
arch = arch ? [arch] : self.allArchs;
}
where = _.uniq(where);
_.each(where, function (inputWhere) {
var isMatch = _.any(_.map(self.allWheres, function (actualWhere) {
return archinfo.matches(actualWhere, inputWhere);
arch = _.uniq(arch);
arch = _.map(arch, mapWhereToArch);
_.each(arch, function (inputArch) {
var isMatch = _.any(_.map(self.allArchs, function (actualArch) {
return archinfo.matches(actualArch, inputArch);
}));
if (! isMatch) {
buildmessage.error(
"Invalid 'where' argument: '" + inputWhere + "'",
// skip toWhereArray in addition to the actual API function
"Invalid 'where' argument: '" + inputArch + "'",
// skip toArchArray in addition to the actual API function
{useMyCaller: 2});
}
});
return where;
return arch;
};
var api = {
@@ -876,7 +880,7 @@ _.extend(PackageSource.prototype, {
// used. Can also take literal package objects, if you have
// anonymous packages you want to use (eg, app packages)
//
// @param where 'web', 'web.browser', 'web.cordova', 'server',
// @param arch 'web', 'web.browser', 'web.cordova', 'server',
// or an array of those.
// The default is ['web', 'server'].
//
@@ -902,16 +906,16 @@ _.extend(PackageSource.prototype, {
// its plugins. (Has the same limitation as "unordered" that this
// flag is not tracked per-environment or per-role; this may
// change.)
use: function (names, where, options) {
// Support `api.use(package, {weak: true})` without where.
if (_.isObject(where) && !_.isArray(where) && !options) {
options = where;
where = null;
use: function (names, arch, options) {
// Support `api.use(package, {weak: true})` without arch.
if (_.isObject(arch) && !_.isArray(arch) && !options) {
options = arch;
arch = null;
}
options = options || {};
names = toArray(names);
where = toWhereArray(where);
arch = toArchArray(arch);
// A normal dependency creates an ordering constraint and a "if I'm
// used, use that" constraint. Unordered dependencies lack the
@@ -938,8 +942,8 @@ _.extend(PackageSource.prototype, {
continue;
}
forAllMatchingWheres(where, function (w) {
uses[w].push({
forAllMatchingArchs(arch, function (a) {
uses[a].push({
package: parsed.name,
constraint: parsed.constraintString,
unordered: options.unordered || false,
@@ -952,9 +956,9 @@ _.extend(PackageSource.prototype, {
// Called when this package wants packages using it to also use
// another package. eg, for umbrella packages which want packages
// using them to also get symbols or plugins from their components.
imply: function (names, where) {
imply: function (names, arch) {
names = toArray(names);
where = toWhereArray(where);
arch = toArchArray(arch);
// using for loop rather than underscore to help with useMyCaller
for (var i = 0; i < names.length; ++i) {
@@ -969,10 +973,10 @@ _.extend(PackageSource.prototype, {
continue;
}
forAllMatchingWheres(where, function (w) {
forAllMatchingArchs(arch, function (a) {
// We don't allow weak or unordered implies, since the main
// purpose of imply is to provide imports and plugins.
implies[w].push({
implies[a].push({
package: parsed.name,
constraint: parsed.constraintString
});
@@ -983,16 +987,16 @@ _.extend(PackageSource.prototype, {
// Top-level call to add a source file to a package. It will
// be processed according to its extension (eg, *.coffee
// files will be compiled to JavaScript).
addFiles: function (paths, where, fileOptions) {
addFiles: function (paths, arch, fileOptions) {
paths = toArray(paths);
where = toWhereArray(where);
arch = toArchArray(arch);
_.each(paths, function (path) {
forAllMatchingWheres(where, function (w) {
forAllMatchingArchs(arch, function (a) {
var source = {relPath: path};
if (fileOptions)
source.fileOptions = fileOptions;
sources[w].push(source);
sources[a].push(source);
});
});
},
@@ -1041,21 +1045,21 @@ _.extend(PackageSource.prototype, {
// Export symbols from this package.
//
// @param symbols String (eg "Foo") or array of String
// @param where 'web', 'server', 'web.browser', 'web.cordova'
// @param arch 'web', 'server', 'web.browser', 'web.cordova'
// or an array of those.
// The default is ['web', 'server'].
// @param options 'testOnly', boolean.
export: function (symbols, where, options) {
export: function (symbols, arch, options) {
// Support `api.export("FooTest", {testOnly: true})` without
// where.
if (_.isObject(where) && !_.isArray(where) && !options) {
options = where;
where = null;
// arch.
if (_.isObject(arch) && !_.isArray(arch) && !options) {
options = arch;
arch = null;
}
options = options || {};
symbols = toArray(symbols);
where = toWhereArray(where);
arch = toArchArray(arch);
_.each(symbols, function (symbol) {
// XXX be unicode-friendlier
@@ -1065,7 +1069,7 @@ _.extend(PackageSource.prototype, {
// recover by ignoring
return;
}
forAllMatchingWheres(where, function (w) {
forAllMatchingArchs(arch, function (w) {
exports[w].push({name: symbol, testOnly: !!options.testOnly});
});
});
@@ -1086,8 +1090,8 @@ _.extend(PackageSource.prototype, {
// principle of least surprise to half-run a handler
// and then continue.
sources = {};
_.each(self.allWheres, function (where) {
sources[where] = [];
_.each(self.allArchs, function (arch) {
sources[arch] = [];
});
fileAndDepLoader = null;
@@ -1116,7 +1120,7 @@ _.extend(PackageSource.prototype, {
// For all implies and uses, fill in the unspecified dependencies from the
// release.
_.each(self.allWheres, function (label) {
_.each(self.allArchs, function (label) {
uses[label] = _.map(uses[label], setFromRel);
implies[label] = _.map(implies[label], setFromRel);
});
@@ -1159,9 +1163,7 @@ _.extend(PackageSource.prototype, {
// Create source architectures, one for the server and one for each web
// arch.
_.each(self.allWheres, function (where) {
var arch = mapWhereToArch(where);
_.each(self.allArchs, function (arch) {
// Everything depends on the package 'meteor', which sets up
// the basic environment) (except 'meteor' itself, and js-analyze
// which needs to be loaded by the linker).
@@ -1175,11 +1177,11 @@ _.extend(PackageSource.prototype, {
// dependency on meteor dating from when the .js extension handler was
// in the "meteor" package).
var alreadyDependsOnMeteor =
!! _.find(uses[where], function (u) {
!! _.find(uses[arch], function (u) {
return u.package === "meteor";
});
if (! alreadyDependsOnMeteor)
uses[where].unshift({ package: "meteor" });
uses[arch].unshift({ package: "meteor" });
}
// Each unibuild has its own separate WatchSet. This is so that, eg, a test
@@ -1192,10 +1194,10 @@ _.extend(PackageSource.prototype, {
self.architectures.push(new SourceArch(self, {
name: "main",
arch: arch,
uses: uses[where],
implies: implies[where],
getSourcesFunc: function () { return sources[where]; },
declaredExports: exports[where],
uses: uses[arch],
implies: implies[arch],
getSourcesFunc: function () { return sources[arch]; },
declaredExports: exports[arch],
watchSet: watchSet
}));
});
@@ -1247,17 +1249,17 @@ _.extend(PackageSource.prototype, {
self.sourceRoot = appDir;
self.serveRoot = path.sep;
_.each(self.allWheres, function (where) {
_.each(self.allArchs, function (arch) {
// Determine used packages
var project = require('./project.js').project;
var names = project.getConstraints();
var arch = mapWhereToArch(where);
// XXX what about /client.browser/* etc, these directories could also
// XXX what about /web.browser/* etc, these directories could also
// be for specific client targets.
// Create unibuild
var sourceArch = new SourceArch(self, {
name: where,
name: arch,
arch: arch,
uses: _.map(names, utils.dealConstraint)
});
@@ -1302,7 +1304,7 @@ _.extend(PackageSource.prototype, {
});
var otherUnibuildRegExp =
(where === "server" ? /^client\/$/ : /^server\/$/);
(arch === "os" ? /^client\/$/ : /^server\/$/);
// The paths that we've called checkForInfiniteRecursion on.
var seenPaths = {};

View File

@@ -5,7 +5,7 @@ Package.describe({
Package.on_use(function (api) {
api.add_files('all-clients.js', ['client']);
api.add_files('browser-client.js', ['client.browser']);
api.add_files('cordova-client.js', ['client.cordova']);
api.add_files('browser-client.js', ['web.browser']);
api.add_files('cordova-client.js', ['web.cordova']);
api.add_files('server.js', ['server']);
});