From 1f26045fe01496eb770255041151906cd80541ce Mon Sep 17 00:00:00 2001 From: David Glasser Date: Tue, 2 Jul 2013 16:03:30 -0700 Subject: [PATCH] __meteor_bootstrap__.bundle -> WebApp.clientProgram --- packages/appcache/appcache-server.js | 9 ++++----- packages/routepolicy/package.js | 3 +++ packages/routepolicy/routepolicy.js | 9 ++++++--- packages/webapp/webapp_server.js | 13 ++++++------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/appcache/appcache-server.js b/packages/appcache/appcache-server.js index aa7f8612d6..5868255323 100644 --- a/packages/appcache/appcache-server.js +++ b/packages/appcache/appcache-server.js @@ -1,4 +1,3 @@ -var bundle = __meteor_bootstrap__.bundle; var crypto = Npm.require('crypto'); var fs = Npm.require('fs'); var path = Npm.require('path'); @@ -97,7 +96,7 @@ WebApp.connectHandlers.use(function(req, res, next) { var hash = crypto.createHash('sha1'); hash.update(JSON.stringify(__meteor_runtime_config__), 'utf8'); - _.each(bundle.manifest, function (resource) { + _.each(WebApp.clientProgram.manifest, function (resource) { if (resource.where === 'client' || resource.where === 'internal') { hash.update(resource.hash); } @@ -109,7 +108,7 @@ WebApp.connectHandlers.use(function(req, res, next) { manifest += "CACHE:" + "\n"; manifest += "/" + "\n"; - _.each(bundle.manifest, function (resource) { + _.each(WebApp.clientProgram.manifest, function (resource) { if (resource.where === 'client' && ! RoutePolicy.classify(resource.url)) { manifest += resource.url; @@ -138,7 +137,7 @@ WebApp.connectHandlers.use(function(req, res, next) { // request to the server and have the asset served from cache by // specifying the full URL with hash in their code (manually, with // some sort of URL rewriting helper) - _.each(bundle.manifest, function (resource) { + _.each(WebApp.clientProgram.manifest, function (resource) { if (resource.where === 'client' && ! RoutePolicy.classify(resource.url) && !resource.cacheable) { @@ -174,7 +173,7 @@ WebApp.connectHandlers.use(function(req, res, next) { var sizeCheck = function() { var totalSize = 0; - _.each(bundle.manifest, function (resource) { + _.each(WebApp.clientProgram.manifest, function (resource) { if (resource.where === 'client') { totalSize += resource.size; } diff --git a/packages/routepolicy/package.js b/packages/routepolicy/package.js index 3060100b4a..b9d4514ce3 100644 --- a/packages/routepolicy/package.js +++ b/packages/routepolicy/package.js @@ -5,6 +5,9 @@ Package.describe({ Package.on_use(function (api) { api.use('underscore', 'server'); + // Resolve circular dependency with webapp. We can only use WebApp via + // Package.webapp and only after initial load. + api.use('webapp', 'server', {unordered: true}); api.add_files('routepolicy.js', 'server'); }); diff --git a/packages/routepolicy/routepolicy.js b/packages/routepolicy/routepolicy.js index 3fff5964c5..04edb5122a 100644 --- a/packages/routepolicy/routepolicy.js +++ b/packages/routepolicy/routepolicy.js @@ -63,14 +63,17 @@ _.extend(_RoutePolicyConstructor.prototype, { var self = this; if (type === 'static-online') return null; - if (typeof __meteor_bootstrap__ === "undefined" || - !__meteor_bootstrap__.bundle || !__meteor_bootstrap__.bundle.manifest) + if (!Package.webapp || !Package.webapp.WebApp + || !Package.webapp.WebApp.clientProgram + || !Package.webapp.WebApp.clientProgram.manifest) { // Hack: If we don't have a manifest, deal with it // gracefully. This lets us load livedata into a nodejs // environment that doesn't have a HTTP server (eg, a // command-line tool). return null; - var manifest = _testManifest || __meteor_bootstrap__.bundle.manifest; + } + var manifest = + _testManifest || Package.webapp.WebApp.clientProgram.manifest; var conflict = _.find(manifest, function (resource) { return (resource.type === 'static' && resource.where === 'client' && diff --git a/packages/webapp/webapp_server.js b/packages/webapp/webapp_server.js index c4317013b2..ee5435dbd5 100644 --- a/packages/webapp/webapp_server.js +++ b/packages/webapp/webapp_server.js @@ -284,6 +284,12 @@ var runWebAppServer = function () { _.extend(WebApp, { connectHandlers: packageAndAppHandlers, httpServer: httpServer, + // metadata about the client program that we serve + clientProgram: { + manifest: clientJson.manifest + // XXX do we need a "root: clientDir" field here? it used to be here but + // was unused. + }, // For testing. suppressConnectErrors: function () { suppressConnectErrors = true; @@ -294,13 +300,6 @@ var runWebAppServer = function () { __basicAuth__: connect.basicAuth }); _.extend(__meteor_bootstrap__, { - // metadata about this bundle - // XXX this could use some refactoring to better distinguish - // server and client - bundle: { - manifest: clientJson.manifest, - root: clientDir - }, // function that takes a connect `req` object and returns a summary // object with information about the request. See // #BrowserIdentifcation