3.0 source code

This commit is contained in:
agolybev
2015-04-28 17:59:00 +03:00
parent c69fd34bdd
commit 7b3b2248e5
16311 changed files with 1445974 additions and 3108429 deletions

View File

@@ -0,0 +1,6 @@
define(['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});

View File

@@ -0,0 +1,6 @@
define(['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});

View File

@@ -0,0 +1,4 @@
define(['d'], function(d) {
d.adapted = true;
return d;
});

View File

@@ -0,0 +1,6 @@
define(['./minor'], function (minor) {
return {
name: 'another/c',
minorName: minor.name
};
});

View File

@@ -0,0 +1,3 @@
define({
name: 'another/c/dim'
});

View File

@@ -0,0 +1,6 @@
define(['./dim'], function (dim) {
return {
name: 'another/c/sub',
dimName: dim.name
};
});

View File

@@ -0,0 +1,4 @@
define({
name: 'another/minor'
});

View File

@@ -0,0 +1,6 @@
define(['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});

View File

@@ -0,0 +1,82 @@
define('c1',{
name: 'c1'
});
define('c1/sub',{
name: 'c1/sub'
});
define('a',['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});
define('c',{
name: 'c'
});
define('c/sub',{
name: 'c/sub'
});
define('b',['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});
define('c2',{
name: 'c2'
});
define('c2/sub',{
name: 'c2/sub'
});
define('a/sub/one',['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});
require({
baseUrl: './',
paths: {
a: 'a1'
},
map: {
'a': {
c: 'c1'
},
'a/sub/one': {
'c': 'c2'
}
}
},
['a', 'b', 'c', 'a/sub/one'],
function(a, b, c, one) {
doh.register(
'mapConfig',
[
function mapConfig(t){
t.is('c1', a.c.name);
t.is('c1/sub', a.csub.name);
t.is('c2', one.c.name);
t.is('c2/sub', one.csub.name);
t.is('c', b.c.name);
t.is('c/sub', b.csub.name);
t.is('c', c.name);
}
]
);
doh.run();
}
);
define("mapConfig-tests", function(){});

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Map Config Built Test</title>
<script type="text/javascript" src="../../../require.js"></script>
<script type="text/javascript" src="../../doh/runner.js"></script>
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
<script type="text/javascript" src="mapConfig-tests.js"></script>
</head>
<body>
<h1>require.js: Map Config Built Test</h1>
<p>Test using the map config after a build.</p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,91 @@
define('plug',{
load: function (name, require, load, config) {
if (!name) {
name = 'main';
} else if (name.charAt(0) === '/') {
name = 'main' + name;
}
//Only grab the first segment of the name.
//This is just to be different, nothing
//that is required behavior.
name = name.split('/').shift();
name = 'plug/' + name;
require([name], load);
}
});
define('plug/c1',{
name: 'plug!c1'
});
define('a',['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});
define('plug/main',{
name: 'plug!main'
});
define('b',['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});
define('plug/c2',{
name: 'plug!c2'
});
define('a/sub/one',['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});
require({
baseUrl: './',
paths: {
a: 'a1'
},
map: {
'*': {
c: 'plug!'
},
'a': {
c: 'plug!c1'
},
'a/sub/one': {
'c': 'plug!c2'
}
}
},
['a', 'b', 'c', 'a/sub/one'],
function(a, b, c, one) {
doh.register(
'mapConfigPlugin',
[
function mapConfigPlugin(t){
t.is('plug!c1', a.c.name);
t.is('plug!c1', a.csub.name);
t.is('plug!c2', one.c.name);
t.is('plug!c2', one.csub.name);
t.is('plug!main', b.c.name);
t.is('plug!main', b.csub.name);
t.is('plug!main', c.name);
}
]
);
doh.run();
}
);
define("mapConfigPlugin-tests", function(){});

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Map Config Plugin Built Test</title>
<script type="text/javascript" src="../../../require.js"></script>
<script type="text/javascript" src="../../doh/runner.js"></script>
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
<script type="text/javascript" src="mapConfigPlugin-tests.js"></script>
</head>
<body>
<h1>require.js: Map Config Plugin Built Test</h1>
<p>Test using the map config with plugin value after a build.</p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,100 @@
define('c1',{
name: 'c1'
});
define('c1/sub',{
name: 'c1/sub'
});
define('a',['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});
define('another/minor',{
name: 'another/minor'
});
define('another/c',['./minor'], function (minor) {
return {
name: 'another/c',
minorName: minor.name
};
});
define('another/c/dim',{
name: 'another/c/dim'
});
define('another/c/sub',['./dim'], function (dim) {
return {
name: 'another/c/sub',
dimName: dim.name
};
});
define('b',['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});
define('c2',{
name: 'c2'
});
define('a/sub/one',['c', 'c/sub'], function (c, csub) {
return {
c: c,
csub: csub
};
});
require({
baseUrl: './',
paths: {
a: 'a1'
},
map: {
'*': {
'c': 'another/c'
},
'a': {
c: 'c1'
},
'a/sub/one': {
'c': 'c2',
'c/sub': 'another/c/sub'
}
}
},
['a', 'b', 'c', 'a/sub/one'],
function(a, b, c, one) {
doh.register(
'mapConfigStar',
[
function mapConfigStar(t){
t.is('c1', a.c.name);
t.is('c1/sub', a.csub.name);
t.is('c2', one.c.name);
t.is('another/c/sub', one.csub.name);
t.is('another/c/dim', one.csub.dimName);
t.is('another/c', b.c.name);
t.is('another/minor', b.c.minorName);
t.is('another/c/sub', b.csub.name);
t.is('another/c', c.name);
t.is('another/minor', c.minorName);
}
]
);
doh.run();
}
);
define("mapConfigStar-tests", function(){});

View File

@@ -0,0 +1,49 @@
define('d',{
name: 'd'
});
define('adapter/d',['d'], function(d) {
d.adapted = true;
return d;
});
define('e',['d'], function (d) {
return {
name: 'e',
d: d
};
});
/*global doh */
require({
baseUrl: './',
map: {
'*': {
'd': 'adapter/d'
},
'adapter/d': {
d: 'd'
}
}
},
['e', 'adapter/d'],
function(e, adapterD) {
doh.register(
'mapConfigStarAdapter',
[
function mapConfigStarAdapter(t){
t.is('e', e.name);
t.is('d', e.d.name);
t.is(true, e.d.adapted);
t.is(true, adapterD.adapted);
t.is('d', adapterD.name);
}
]
);
doh.run();
}
);
define("mapConfigStarAdapter-tests", function(){});

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Map Config Star Adapter Built Test</title>
<script type="text/javascript" src="../../../require.js"></script>
<script type="text/javascript" src="../../doh/runner.js"></script>
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
<script type="text/javascript" src="mapConfigStarAdapter-tests.js"></script>
</head>
<body>
<h1>require.js: Map Config Star Adapter Built Test</h1>
<p>Test using '*' with an adapter in the built map config.</p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Map Config Star Built Test</title>
<script type="text/javascript" src="../../../require.js"></script>
<script type="text/javascript" src="../../doh/runner.js"></script>
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
<script type="text/javascript" src="mapConfigStar-tests.js"></script>
</head>
<body>
<h1>require.js: Map Config Star Built Test</h1>
<p>Test using '*' in the built map config.</p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,3 @@
define({
name: 'c'
});

View File

@@ -0,0 +1,3 @@
define({
name: 'c/sub'
});

View File

@@ -0,0 +1,3 @@
define({
name: 'c1'
});

View File

@@ -0,0 +1,3 @@
define({
name: 'c1/sub'
});

View File

@@ -0,0 +1,3 @@
define({
name: 'c2'
});

View File

@@ -0,0 +1,3 @@
define({
name: 'c2/sub'
});

View File

@@ -0,0 +1,3 @@
define({
name: 'd'
});

View File

@@ -0,0 +1,6 @@
define(['d'], function (d) {
return {
name: 'e',
d: d
};
});

View File

@@ -0,0 +1,34 @@
require({
baseUrl: './',
paths: {
a: 'a1'
},
map: {
'a': {
c: 'c1'
},
'a/sub/one': {
'c': 'c2'
}
}
},
['a', 'b', 'c', 'a/sub/one'],
function(a, b, c, one) {
doh.register(
'mapConfig',
[
function mapConfig(t){
t.is('c1', a.c.name);
t.is('c1/sub', a.csub.name);
t.is('c2', one.c.name);
t.is('c2/sub', one.csub.name);
t.is('c', b.c.name);
t.is('c/sub', b.csub.name);
t.is('c', c.name);
}
]
);
doh.run();
}
);

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Map Config Test</title>
<script type="text/javascript" src="../../require.js"></script>
<script type="text/javascript" src="../doh/runner.js"></script>
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
<script type="text/javascript" src="mapConfig-tests.js"></script>
</head>
<body>
<h1>require.js: Map Config Test</h1>
<p>Test using the map config.</p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,39 @@
define('one', function () {
return { name: 'one' };
});
define('two', function () {
return { name: 'two' };
});
define('three', ['one'], function (one) {
return { name: 'three',
one: one
};
});
require([], function() {
require({
map : {
'*': {
'one': 'two'
}
}
},
['three'],
function (three) {
doh.register(
'mapConfigDelayed',
[
function mapConfigDelayed(t){
t.is('three', three.name);
t.is('two', three.one.name);
}
]
);
doh.run();
}
);
});
define("app", function(){});

View File

@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Multiple Map Delayed Test</title>
<script type="text/javascript" src="../../require.js"></script>
<script type="text/javascript" src="../doh/runner.js"></script>
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
<script type="text/javascript" src="mapConfigDelayed-tests.js"></script>
</head>
<body>
<h1>require.js: Multiple Map Config Delayed Test</h1>
<p>Test application of map config after some have already registered
modules via define, but have not activated them yet. Related to:
<a href="https://github.com/jrburke/requirejs/issues/309">309</a></p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,39 @@
require({
baseUrl: './',
paths: {
a: 'a1'
},
map: {
'a': {
c: 'c1'
}
}
});
require({
map: {
'a/sub/one': {
'c': 'c2'
}
}
},
['a', 'b', 'c', 'a/sub/one'],
function(a, b, c, one) {
doh.register(
'mapConfig',
[
function mapConfig(t){
t.is('c1', a.c.name);
t.is('c1/sub', a.csub.name);
t.is('c2', one.c.name);
t.is('c2/sub', one.csub.name);
t.is('c', b.c.name);
t.is('c/sub', b.csub.name);
t.is('c', c.name);
}
]
);
doh.run();
}
);

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Multiple Map Config Test</title>
<script type="text/javascript" src="../../require.js"></script>
<script type="text/javascript" src="../doh/runner.js"></script>
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
<script type="text/javascript" src="mapConfigMulti-tests.js"></script>
</head>
<body>
<h1>require.js: Multiple Map Config Test</h1>
<p>Test using the map config.</p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,37 @@
require({
baseUrl: './',
paths: {
a: 'a1'
},
map: {
'*': {
c: 'plug!'
},
'a': {
c: 'plug!c1'
},
'a/sub/one': {
'c': 'plug!c2'
}
}
},
['a', 'b', 'c', 'a/sub/one'],
function(a, b, c, one) {
doh.register(
'mapConfigPlugin',
[
function mapConfigPlugin(t){
t.is('plug!c1', a.c.name);
t.is('plug!c1', a.csub.name);
t.is('plug!c2', one.c.name);
t.is('plug!c2', one.csub.name);
t.is('plug!main', b.c.name);
t.is('plug!main', b.csub.name);
t.is('plug!main', c.name);
}
]
);
doh.run();
}
);

View File

@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Map Config Plugin Test</title>
<script type="text/javascript" src="../../require.js"></script>
<script type="text/javascript" src="../doh/runner.js"></script>
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
<script type="text/javascript" src="mapConfigPlugin-tests.js"></script>
</head>
<body>
<h1>require.js: Map Config Plugin Test</h1>
<p>Test using the map config that has a plugin
for a value.
<a href="https://github.com/jrburke/requirejs/issues/466">More info</a>.
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,29 @@
define('lib/b', [], { name: 'b' });
define('b1', [], { name: 'b1' });
define('lib/a', ['./b'], function(b) {
return {
name: 'a',
b: b
};
});
require({
map: {
'lib/a': {
'lib/b': 'b1'
}
}
},['lib/a'], function(a) {
doh.register(
'mapConfigRelative',
[
function mapConfigRelative(t){
t.is('a', a.name);
t.is('b1', a.b.name);
}
]
);
doh.run();
});

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Map Config Relative Test</title>
<script type="text/javascript" src="../../require.js"></script>
<script type="text/javascript" src="../doh/runner.js"></script>
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
<script type="text/javascript" src="mapConfigRelative-tests.js"></script>
</head>
<body>
<h1>require.js: Map Config Relative Test</h1>
<p>Test using the map config on a relative dependency ID. More info:
<a href="https://github.com/jrburke/requirejs/issues/350">350</a></p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,39 @@
define('foo-1.0/bar/baz', [], function(){ return '1.0'; });
define('foo-1.2/bar/baz', [], function(){ return '1.2'; });
define('oldmodule', ['foo/bar/baz'], function(baz) {
return {
name: 'oldmodule',
baz: baz
};
});
require({
baseUrl: './',
map: {
'oldmodule': {
//This one should be favored over the * value.
'foo' : 'foo-1.0'
},
'*': {
'foo/bar' : 'foo-1.2/bar'
}
}
},
['oldmodule'],
function(oldmodule) {
doh.register(
'mapConfigSpecificity',
[
function mapConfigSpecificity(t){
t.is('oldmodule', oldmodule.name);
t.is('1.0', oldmodule.baz);
}
]
);
doh.run();
}
);

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Map Config Specificity Test</title>
<script type="text/javascript" src="../../require.js"></script>
<script type="text/javascript" src="../doh/runner.js"></script>
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
<script type="text/javascript" src="mapConfigSpecificity-tests.js"></script>
</head>
<body>
<h1>require.js: Map Config Specificity Test</h1>
<p>Test specificity of the map config.
<a href="https://github.com/jrburke/requirejs/issues/390">More info</a>.</p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,41 @@
require({
baseUrl: './',
paths: {
a: 'a1'
},
map: {
'*': {
'c': 'another/c'
},
'a': {
c: 'c1'
},
'a/sub/one': {
'c': 'c2',
'c/sub': 'another/c/sub'
}
}
},
['a', 'b', 'c', 'a/sub/one'],
function(a, b, c, one) {
doh.register(
'mapConfigStar',
[
function mapConfigStar(t){
t.is('c1', a.c.name);
t.is('c1/sub', a.csub.name);
t.is('c2', one.c.name);
t.is('another/c/sub', one.csub.name);
t.is('another/c/dim', one.csub.dimName);
t.is('another/c', b.c.name);
t.is('another/minor', b.c.minorName);
t.is('another/c/sub', b.csub.name);
t.is('another/c', c.name);
t.is('another/minor', c.minorName);
}
]
);
doh.run();
}
);

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Map Config Star Test</title>
<script type="text/javascript" src="../../require.js"></script>
<script type="text/javascript" src="../doh/runner.js"></script>
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
<script type="text/javascript" src="mapConfigStar-tests.js"></script>
</head>
<body>
<h1>require.js: Map Config Star Test</h1>
<p>Test using '*' in the map config.</p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,30 @@
/*global doh */
require({
baseUrl: './',
map: {
'*': {
'd': 'adapter/d'
},
'adapter/d': {
d: 'd'
}
}
},
['e', 'adapter/d'],
function(e, adapterD) {
'use strict';
doh.register(
'mapConfigStarAdapter',
[
function mapConfigStarAdapter(t){
t.is('e', e.name);
t.is('d', e.d.name);
t.is(true, e.d.adapted);
t.is(true, adapterD.adapted);
t.is('d', adapterD.name);
}
]
);
doh.run();
}
);

View File

@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Map Config Star Swap Test</title>
<script type="text/javascript" src="../../require.js"></script>
<script type="text/javascript" src="../doh/runner.js"></script>
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
<script type="text/javascript" src="mapConfigStarAdapter-tests.js"></script>
</head>
<body>
<h1>require.js: Map Config Star Swap Test</h1>
<p>Test using '*' in the map config, but with an adapter module
that is used to load the non-* version and add to it. More info:
<a href="https://github.com/jrburke/requirejs/issues/277">#277</a></p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,18 @@
define({
load: function (name, require, load, config) {
if (!name) {
name = 'main';
} else if (name.charAt(0) === '/') {
name = 'main' + name;
}
//Only grab the first segment of the name.
//This is just to be different, nothing
//that is required behavior.
name = name.split('/').shift();
name = 'plug/' + name;
require([name], load);
}
});

View File

@@ -0,0 +1,3 @@
define({
name: 'plug!c1'
});

View File

@@ -0,0 +1,3 @@
define({
name: 'plug!c2'
});

View File

@@ -0,0 +1,3 @@
define({
name: 'plug!main'
});