Skip to content

Commit fe3d321

Browse files
committed
snapshot
1 parent 1114d81 commit fe3d321

File tree

1 file changed

+152
-72
lines changed

1 file changed

+152
-72
lines changed

dist/r.js

Lines changed: 152 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license r.js 2.1.22+ Tue, 15 Mar 2016 21:57:59 GMT Copyright jQuery Foundation and other contributors.
2+
* @license r.js 2.1.22+ Tue, 15 Mar 2016 23:27:47 GMT Copyright jQuery Foundation and other contributors.
33
* Released under MIT license, http://github.com/requirejs/r.js/LICENSE
44
*/
55

@@ -19,7 +19,7 @@ var requirejs, require, define, xpcUtil;
1919
(function (console, args, readFileFunc) {
2020
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
2121
nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode, Cc, Ci,
22-
version = '2.1.22+ Tue, 15 Mar 2016 21:57:59 GMT',
22+
version = '2.1.22+ Tue, 15 Mar 2016 23:27:47 GMT',
2323
jsSuffixRegExp = /\.js$/,
2424
commandOption = '',
2525
useLibLoaded = {},
@@ -24918,6 +24918,8 @@ define('build', function (require) {
2491824918
findNestedDependencies: false,
2491924919
preserveLicenseComments: true,
2492024920
writeBuildTxt: true,
24921+
//Some builds can take a while, up the default limit.
24922+
waitSeconds: 30,
2492124923
//By default, all files/directories are copied, unless
2492224924
//they match this regexp, by default just excludes .folders
2492324925
dirExclusionRegExp: file.dirExclusionRegExp,
@@ -24945,6 +24947,13 @@ define('build', function (require) {
2494524947
return dirName;
2494624948
}
2494724949

24950+
function endsWithNewLine(text) {
24951+
if (text.charAt(text.length - 1) !== "\n") {
24952+
text += "\n";
24953+
}
24954+
return text;
24955+
}
24956+
2494824957
//Method used by plugin writeFile calls, defined up here to avoid
2494924958
//jslint warning about "making a function in a loop".
2495024959
function makeWriteFile(namespace, layer) {
@@ -24961,6 +24970,75 @@ define('build', function (require) {
2496124970
return writeFile;
2496224971
}
2496324972

24973+
/**
24974+
* Appends singleContents to fileContents and returns the result. If a sourceMapGenerator
24975+
* is provided, adds singleContents to the source map.
24976+
*
24977+
* @param {string} fileContents - The file contents to which to append singleContents
24978+
* @param {string} singleContents - The additional contents to append to fileContents
24979+
* @param {string} path - An absolute path of a file whose name to use in the source map.
24980+
* The file need not actually exist if the code in singleContents is generated.
24981+
* @param {{out: ?string, baseUrl: ?string}} config - The build configuration object.
24982+
* @param {?{_buildPath: ?string}} module - An object with module information.
24983+
* @param {?SourceMapGenerator} sourceMapGenerator - An instance of Mozilla's SourceMapGenerator,
24984+
* or null if no source map is being generated.
24985+
* @returns {string} fileContents with singleContents appended
24986+
*/
24987+
function appendToFileContents(fileContents, singleContents, path, config, module, sourceMapGenerator) {
24988+
var refPath, sourceMapPath, resourcePath, pluginId, sourceMapLineNumber, lineCount, parts, i;
24989+
if (sourceMapGenerator) {
24990+
if (config.out) {
24991+
refPath = config.baseUrl;
24992+
} else if (module && module._buildPath) {
24993+
refPath = module._buildPath;
24994+
} else {
24995+
refPath = "";
24996+
}
24997+
parts = path.split('!');
24998+
if (parts.length === 1) {
24999+
//Not a plugin resource, fix the path
25000+
sourceMapPath = build.makeRelativeFilePath(refPath, path);
25001+
} else {
25002+
//Plugin resource. If it looks like just a plugin
25003+
//followed by a module ID, pull off the plugin
25004+
//and put it at the end of the name, otherwise
25005+
//just leave it alone.
25006+
pluginId = parts.shift();
25007+
resourcePath = parts.join('!');
25008+
if (resourceIsModuleIdRegExp.test(resourcePath)) {
25009+
sourceMapPath = build.makeRelativeFilePath(refPath, require.toUrl(resourcePath)) +
25010+
'!' + pluginId;
25011+
} else {
25012+
sourceMapPath = path;
25013+
}
25014+
}
25015+
25016+
sourceMapLineNumber = fileContents.split('\n').length - 1;
25017+
lineCount = singleContents.split('\n').length;
25018+
for (i = 1; i <= lineCount; i += 1) {
25019+
sourceMapGenerator.addMapping({
25020+
generated: {
25021+
line: sourceMapLineNumber + i,
25022+
column: 0
25023+
},
25024+
original: {
25025+
line: i,
25026+
column: 0
25027+
},
25028+
source: sourceMapPath
25029+
});
25030+
}
25031+
25032+
//Store the content of the original in the source
25033+
//map since other transforms later like minification
25034+
//can mess up translating back to the original
25035+
//source.
25036+
sourceMapGenerator.setSourceContent(sourceMapPath, singleContents);
25037+
}
25038+
fileContents += singleContents;
25039+
return fileContents;
25040+
}
25041+
2496425042
/**
2496525043
* Main API entry point into the build. The args argument can either be
2496625044
* an array of arguments (like the onese passed on a command-line),
@@ -25621,7 +25699,9 @@ define('build', function (require) {
2562125699
"insertRequire": true,
2562225700
"stubModules": true,
2562325701
"deps": true,
25624-
"mainConfigFile": true
25702+
"mainConfigFile": true,
25703+
"wrap.startFile": true,
25704+
"wrap.endFile": true
2562525705
};
2562625706

2562725707
for (i = 0; i < ary.length; i++) {
@@ -25831,22 +25911,37 @@ define('build', function (require) {
2583125911
* Converts a wrap.startFile or endFile to be start/end as a string.
2583225912
* the startFile/endFile values can be arrays.
2583325913
*/
25834-
function flattenWrapFile(wrap, keyName, absFilePath) {
25835-
var keyFileName = keyName + 'File';
25914+
function flattenWrapFile(config, keyName, absFilePath) {
25915+
var wrap = config.wrap,
25916+
keyFileName = keyName + 'File',
25917+
keyMapName = '__' + keyName + 'Map';
2583625918

2583725919
if (typeof wrap[keyName] !== 'string' && wrap[keyFileName]) {
2583825920
wrap[keyName] = '';
2583925921
if (typeof wrap[keyFileName] === 'string') {
2584025922
wrap[keyFileName] = [wrap[keyFileName]];
2584125923
}
25924+
wrap[keyMapName] = [];
2584225925
wrap[keyFileName].forEach(function (fileName) {
25843-
wrap[keyName] += (wrap[keyName] ? '\n' : '') +
25844-
file.readFile(build.makeAbsPath(fileName, absFilePath));
25926+
var absPath = build.makeAbsPath(fileName, absFilePath),
25927+
fileText = endsWithNewLine(file.readFile(absPath));
25928+
wrap[keyMapName].push(function (fileContents, cfg, sourceMapGenerator) {
25929+
return appendToFileContents(fileContents, fileText, absPath, cfg, null, sourceMapGenerator);
25930+
});
25931+
wrap[keyName] += fileText;
2584525932
});
2584625933
} else if (wrap[keyName] === null || wrap[keyName] === undefined) {
2584725934
//Allow missing one, just set to empty string.
2584825935
wrap[keyName] = '';
25849-
} else if (typeof wrap[keyName] !== 'string') {
25936+
} else if (typeof wrap[keyName] === 'string') {
25937+
wrap[keyName] = endsWithNewLine(wrap[keyName]);
25938+
wrap[keyMapName] = [
25939+
function (fileContents, cfg, sourceMapGenerator) {
25940+
var absPath = build.makeAbsPath("config-wrap-" + keyName + "-default.js", absFilePath);
25941+
return appendToFileContents(fileContents, wrap[keyName], absPath, cfg, null, sourceMapGenerator);
25942+
}
25943+
];
25944+
} else {
2585025945
throw new Error('wrap.' + keyName + ' or wrap.' + keyFileName + ' malformed');
2585125946
}
2585225947
}
@@ -25858,12 +25953,27 @@ define('build', function (require) {
2585825953
if (config.wrap === true) {
2585925954
//Use default values.
2586025955
config.wrap = {
25861-
start: '(function () {',
25862-
end: '}());'
25956+
start: '(function () {\n',
25957+
end: '}());',
25958+
__startMap: [
25959+
function (fileContents, cfg, sourceMapGenerator) {
25960+
return appendToFileContents(fileContents, "(function () {\n",
25961+
build.makeAbsPath("config-wrap-start-default.js",
25962+
absFilePath), cfg, null,
25963+
sourceMapGenerator);
25964+
}
25965+
],
25966+
__endMap: [
25967+
function (fileContents, cfg, sourceMapGenerator) {
25968+
return appendToFileContents(fileContents, "}());",
25969+
build.makeAbsPath("config-wrap-end-default.js", absFilePath),
25970+
cfg, null, sourceMapGenerator);
25971+
}
25972+
]
2586325973
};
2586425974
} else {
25865-
flattenWrapFile(config.wrap, 'start', absFilePath);
25866-
flattenWrapFile(config.wrap, 'end', absFilePath);
25975+
flattenWrapFile(config, 'start', absFilePath);
25976+
flattenWrapFile(config, 'end', absFilePath);
2586725977
}
2586825978
}
2586925979
} catch (wrapError) {
@@ -26623,11 +26733,16 @@ define('build', function (require) {
2662326733
});
2662426734

2662526735
//Write the built module to disk, and build up the build output.
26626-
fileContents = config.wrap ? config.wrap.start : "";
26736+
fileContents = "";
26737+
if (config.wrap && config.wrap.__startMap) {
26738+
config.wrap.__startMap.forEach(function (wrapFunction) {
26739+
fileContents = wrapFunction(fileContents, config, sourceMapGenerator);
26740+
});
26741+
}
26742+
2662726743
return prim.serial(layer.buildFilePaths.map(function (path) {
2662826744
return function () {
26629-
var lineCount,
26630-
singleContents = '';
26745+
var singleContents = '';
2663126746

2663226747
moduleName = layer.buildFileToModule[path];
2663326748

@@ -26724,9 +26839,7 @@ define('build', function (require) {
2672426839
});
2672526840
}
2672626841
}).then(function () {
26727-
var refPath, pluginId, resourcePath, shimDeps,
26728-
sourceMapPath, sourceMapLineNumber,
26729-
shortPath = path.replace(config.dir, "");
26842+
var shimDeps, shortPath = path.replace(config.dir, "");
2673026843

2673126844
module.onCompleteData.included.push(shortPath);
2673226845
buildFileContents += shortPath + "\n";
@@ -26773,66 +26886,24 @@ define('build', function (require) {
2677326886
//for concatenation would cause an error otherwise.
2677426887
singleContents += '\n';
2677526888

26776-
//Add to the source map
26777-
if (sourceMapGenerator) {
26778-
refPath = config.out ? config.baseUrl : module._buildPath;
26779-
parts = path.split('!');
26780-
if (parts.length === 1) {
26781-
//Not a plugin resource, fix the path
26782-
sourceMapPath = build.makeRelativeFilePath(refPath, path);
26783-
} else {
26784-
//Plugin resource. If it looks like just a plugin
26785-
//followed by a module ID, pull off the plugin
26786-
//and put it at the end of the name, otherwise
26787-
//just leave it alone.
26788-
pluginId = parts.shift();
26789-
resourcePath = parts.join('!');
26790-
if (resourceIsModuleIdRegExp.test(resourcePath)) {
26791-
sourceMapPath = build.makeRelativeFilePath(refPath, require.toUrl(resourcePath)) +
26792-
'!' + pluginId;
26793-
} else {
26794-
sourceMapPath = path;
26795-
}
26796-
}
26797-
26798-
sourceMapLineNumber = fileContents.split('\n').length - 1;
26799-
lineCount = singleContents.split('\n').length;
26800-
for (var i = 1; i <= lineCount; i += 1) {
26801-
sourceMapGenerator.addMapping({
26802-
generated: {
26803-
line: sourceMapLineNumber + i,
26804-
column: 0
26805-
},
26806-
original: {
26807-
line: i,
26808-
column: 0
26809-
},
26810-
source: sourceMapPath
26811-
});
26812-
}
26813-
26814-
//Store the content of the original in the source
26815-
//map since other transforms later like minification
26816-
//can mess up translating back to the original
26817-
//source.
26818-
sourceMapGenerator.setSourceContent(sourceMapPath, singleContents);
26819-
}
26820-
26821-
//Add the file to the final contents
26822-
fileContents += singleContents;
26889+
//Add to the source map and to the final contents
26890+
fileContents = appendToFileContents(fileContents, singleContents, path, config, module,
26891+
sourceMapGenerator);
2682326892
});
2682426893
};
2682526894
})).then(function () {
2682626895
if (onLayerEnds.length) {
26827-
onLayerEnds.forEach(function (builder) {
26896+
onLayerEnds.forEach(function (builder, index) {
2682826897
var path;
2682926898
if (typeof module.out === 'string') {
2683026899
path = module.out;
2683126900
} else if (typeof module._buildPath === 'string') {
2683226901
path = module._buildPath;
2683326902
}
2683426903
builder.onLayerEnd(function (input) {
26835-
fileContents += "\n" + addSemiColon(input, config);
26904+
fileContents =
26905+
appendToFileContents(fileContents, "\n" + addSemiColon(input, config),
26906+
'onLayerEnd' + index + '.js', config, module, sourceMapGenerator);
2683626907
}, {
2683726908
name: module.name,
2683826909
path: path
@@ -26845,21 +26916,30 @@ define('build', function (require) {
2684526916
//a module definition for it in case the
2684626917
//built file is used with enforceDefine
2684726918
//(#432)
26848-
fileContents += '\n' + namespaceWithDot + 'define("' + module.name + '", function(){});\n';
26919+
fileContents =
26920+
appendToFileContents(fileContents, '\n' + namespaceWithDot + 'define("' + module.name +
26921+
'", function(){});\n', 'module-create.js', config, module,
26922+
sourceMapGenerator);
2684926923
}
2685026924

2685126925
//Add a require at the end to kick start module execution, if that
2685226926
//was desired. Usually this is only specified when using small shim
2685326927
//loaders like almond.
2685426928
if (module.insertRequire) {
26855-
fileContents += '\n' + namespaceWithDot + 'require(["' + module.insertRequire.join('", "') + '"]);\n';
26929+
fileContents =
26930+
appendToFileContents(fileContents, '\n' + namespaceWithDot + 'require(["' + module.insertRequire.join('", "') +
26931+
'"]);\n', 'module-insertRequire.js', config, module,
26932+
sourceMapGenerator);
2685626933
}
2685726934
});
2685826935
}).then(function () {
26936+
if (config.wrap && config.wrap.__endMap) {
26937+
config.wrap.__endMap.forEach(function (wrapFunction) {
26938+
fileContents = wrapFunction(fileContents, config, sourceMapGenerator);
26939+
});
26940+
}
2685926941
return {
26860-
text: config.wrap ?
26861-
fileContents + config.wrap.end :
26862-
fileContents,
26942+
text: fileContents,
2686326943
buildText: buildFileContents,
2686426944
sourceMap: sourceMapGenerator ?
2686526945
JSON.stringify(sourceMapGenerator.toJSON(), null, ' ') :

0 commit comments

Comments
 (0)