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,3 @@
define({
name: 'a'
});

View File

@@ -0,0 +1,5 @@
define(function () {
return {
name: "b"
};
});

View File

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

View File

@@ -0,0 +1,4 @@
//The refine plugin changes the word refine into define.
refine({
name: 'a'
});

View File

@@ -0,0 +1,25 @@
require.config({
baseUrl: requirejs.isBrowser ? './' : './plugins/fromTextEvalError',
paths: {
'refine': '../fromText/refine',
'text': '../../../../text/text'
},
map: {
'*': {
r: 'refine'
}
}
});
require(['delegated!r!a'], function (a) {
doh.register(
'pluginsDelegated',
[
function pluginsDelegated(t){
t.is('a', a.name);
}
]
);
doh.run();
});

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Delegated Map Plugin Test</title>
<script type="text/javascript" src="../../doh/runner.js"></script>
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
<script type="text/javascript" data-main="delegated-tests.js" src="../../../require.js"></script>
</head>
<body>
<h1>require.js: Delegated Map Plugin Test</h1>
<p>Make sure map works on plugin resource IDs. <a href="https://github.com/jrburke/requirejs/issues/563">More info</a>.</p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,5 @@
define({
load: function(name, req, load) {
req([name], load);
}
});

View File

@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Double Plugin Call Test</title>
<script type="text/javascript" src="../doh/runner.js"></script>
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
<script type="text/javascript" src="../../require.js"></script>
<script>
var master = new doh.Deferred(),
count = 0;
function done() {
count += 1;
if (count === 2) {
master.callback(true);
}
}
doh.register(
"doublePluginCall",
[
{
name: "doublePluginCall",
timeout: 5000,
runTest: function() {
return master;
}
}
]
);
doh.run();
require(['double!foo'], function (foo) {
if (foo === 'x') {
done();
}
});
require(['double!foo'], function (foo) {
if (foo === 'x') {
done();
}
});
</script>
</head>
<body>
<h1>require.js: Double Plugin Call Test</h1>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,5 @@
define({
load: function (name, req, load, config) {
load('x');
}
});

View File

@@ -0,0 +1,13 @@
define(function (require) {
return {
getA: function () {
return require("./index!0?./a:./b:./c");
},
getC: function () {
return require("./index!2?./a:./b:./c");
},
getB: function () {
return require("./index!1?./a:./b:./c");
}
};
});

View File

@@ -0,0 +1,4 @@
//The refine plugin changes the word refine into define.
refine({
name: 'a'
});

View File

@@ -0,0 +1,7 @@
//The refine plugin changes the word refine into define.
refine(function (require, exports, module) {
return {
name: 'b',
color: module.config().color
};
});

View File

@@ -0,0 +1,18 @@
require({
baseUrl: requirejs.isBrowser ? './' : './plugins/fromText',
paths: {
'text': '../../../../text/text'
}
}, ['refine!a'],
function (a) {
doh.register(
'pluginsFromText',
[
function pluginsFromText(t){
t.is('a', a.name);
}
]
);
doh.run();
});

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: fromText Plugin Test</title>
<script type="text/javascript" src="../../doh/runner.js"></script>
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
<script type="text/javascript" data-main="fromText-tests.js" src="../../../require.js"></script>
</head>
<body>
<h1>require.js: fromText Plugin Test</h1>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,38 @@
require({
baseUrl: requirejs.isBrowser ? './' : './plugins/fromText',
paths: {
'text': '../../../../text/text'
},
config: {
'refine!b': {
color: 'blue'
},
'refine!c': {
color: 'cyan'
}
}
});
//The refine plugin changes the word refine into define.
define('refine!c', function (require, exports, module) {
return {
name: 'c',
color: module.config().color
};
});
require(['refine!b', 'refine!c'], function (b, c) {
doh.register(
'pluginsFromTextConfig',
[
function pluginsFromTextConfig(t){
t.is('b', b.name);
t.is('blue', b.color);
t.is('c', c.name);
t.is('cyan', c.color);
}
]
);
doh.run();
});

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: fromText Config Test</title>
<script type="text/javascript" src="../../doh/runner.js"></script>
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
<script type="text/javascript" data-main="fromTextConfig-tests.js" src="../../../require.js"></script>
</head>
<body>
<h1>require.js: fromText Config Test</h1>
<p>Make sure built fromText modules get config values same as non-built
case. <a href="https://github.com/jrburke/requirejs/issues/538">More info</a>.
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,157 @@
/*jslint strict: false, plusplus: false */
/*global define: false, require: false, XMLHttpRequest: false, ActiveXObject: false,
window: false, Packages: false, java: false, process: false, Components, FileUtils */
(function () {
//Load the text plugin, so that the XHR calls can be made.
var buildMap = {}, fetchText, fs, Cc, Ci,
progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
function createXhr() {
//Would love to dump the ActiveX crap in here. Need IE 6 to die first.
var xhr, i, progId;
if (typeof XMLHttpRequest !== "undefined") {
return new XMLHttpRequest();
} else {
for (i = 0; i < 3; i++) {
progId = progIds[i];
try {
xhr = new ActiveXObject(progId);
} catch (e) {}
if (xhr) {
progIds = [progId]; // so faster next time
break;
}
}
}
if (!xhr) {
throw new Error("require.getXhr(): XMLHttpRequest not available");
}
return xhr;
}
if (typeof window !== "undefined" && window.navigator && window.document) {
fetchText = function (url, callback) {
var xhr = createXhr();
xhr.open('GET', url, true);
xhr.onreadystatechange = function (evt) {
//Do not explicitly handle errors, those should be
//visible via console output in the browser.
if (xhr.readyState === 4) {
callback(xhr.responseText);
}
};
xhr.send(null);
};
} else if (typeof process !== "undefined" &&
process.versions &&
!!process.versions.node) {
//Using special require.nodeRequire, something added by r.js.
fs = require.nodeRequire('fs');
fetchText = function (url, callback) {
callback(fs.readFileSync(url, 'utf8'));
};
} else if (typeof Packages !== 'undefined') {
//Why Java, why is this so awkward?
fetchText = function (url, callback) {
var encoding = "utf-8",
file = new java.io.File(url),
lineSeparator = java.lang.System.getProperty("line.separator"),
input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)),
stringBuffer, line,
content = '';
try {
stringBuffer = new java.lang.StringBuffer();
line = input.readLine();
// Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324
// http://www.unicode.org/faq/utf_bom.html
// Note that when we use utf-8, the BOM should appear as "EF BB BF", but it doesn't due to this bug in the JDK:
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
if (line && line.length() && line.charAt(0) === 0xfeff) {
// Eat the BOM, since we've already found the encoding on this file,
// and we plan to concatenating this buffer with others; the BOM should
// only appear at the top of a file.
line = line.substring(1);
}
stringBuffer.append(line);
while ((line = input.readLine()) !== null) {
stringBuffer.append(lineSeparator);
stringBuffer.append(line);
}
//Make sure we return a JavaScript string and not a Java string.
content = String(stringBuffer.toString()); //String
} finally {
input.close();
}
callback(content);
};
} else if (typeof Components !== 'undefined' && Components.classes &&
Components.interfaces) {
//Avert your gaze!
Cc = Components.classes,
Ci = Components.interfaces;
Components.utils['import']('resource://gre/modules/FileUtils.jsm');
fetchText = function (url, callback) {
var inStream, convertStream,
readData = {},
fileObj = new FileUtils.File(url);
//XPCOM, you so crazy
try {
inStream = Cc['@mozilla.org/network/file-input-stream;1']
.createInstance(Ci.nsIFileInputStream);
inStream.init(fileObj, 1, 0, false);
convertStream = Cc['@mozilla.org/intl/converter-input-stream;1']
.createInstance(Ci.nsIConverterInputStream);
convertStream.init(inStream, "utf-8", inStream.available(),
Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
convertStream.readString(inStream.available(), readData);
convertStream.close();
inStream.close();
callback(readData.value);
} catch (e) {
throw new Error((fileObj && fileObj.path || '') + ': ' + e);
}
};
}
define(function () {
return {
load: function (name, parentRequire, load, config) {
var url = parentRequire.toUrl(name + '.refine');
fetchText(url, function (text) {
text = text.replace(/refine\s*\(/g, 'define(');
if (config.isBuild) {
buildMap[name] = text;
}
//Add in helpful debug line
text += "\r\n//@ sourceURL=" + url;
load.fromText(text);
});
},
write: function (pluginName, name, write) {
if (name in buildMap) {
var text = buildMap[name];
write.asModule(pluginName + "!" + name, text);
}
}
};
});
}());

View File

@@ -0,0 +1,5 @@
//The refine plugin changes the word refine into define.
refine({
name: 'a'
//Notice missing curly
);

View File

@@ -0,0 +1,7 @@
//The refine plugin changes the word refine into define.
refine(function (require, exports, module) {
return {
name: 'b',
color: module.config().color
};
});

View File

@@ -0,0 +1,23 @@
require.config({
baseUrl: requirejs.isBrowser ? './' : './plugins/fromTextEvalError',
paths: {
'refine': '../fromText/refine',
'text': '../../../../text/text'
}
});
require(['refine!a'], function (a) {
//This should not be called
}, function (err) {
var message = err + '';
doh.register(
'pluginsFromTextEvalError',
[
function pluginsFromTextEvalError(t){
t.is(-1, message.indexOf('timeout'));
}
]
);
doh.run();
});

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: fromText Eval Error Plugin Test</title>
<script type="text/javascript" src="../../doh/runner.js"></script>
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
<script type="text/javascript" data-main="fromTextEvalError-tests.js" src="../../../require.js"></script>
</head>
<body>
<h1>require.js: fromText Eval Error Plugin Test</h1>
<p>Trigger errbacks for plugin fromText eval errors. <a href="https://github.com/jrburke/requirejs/issues/583">More info</a>.</p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,6 @@
//Note the use of window instead of var a = {},
//since the var will be created in the scope of the eval call,
//which is not global.
window.a = {
name: 'a'
};

View File

@@ -0,0 +1,18 @@
require({
baseUrl: requirejs.isBrowser ? './' : './plugins/fromText',
paths: {
'text': '../../../../text/text'
}
}, ['refine!a'],
function () {
doh.register(
'pluginsFromTextNoDefine',
[
function pluginsFromTextNoDefine(t){
t.is('a', a.name);
}
]
);
doh.run();
});

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: fromText Plugin No Define Test</title>
<script type="text/javascript" src="../../doh/runner.js"></script>
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
<script type="text/javascript" data-main="fromTextNoDefine-tests.js" src="../../../require.js"></script>
</head>
<body>
<h1>require.js: fromText Plugin No Define Test</h1>
<p>Tests that a plugin that transpiles to JS but does not call
define still works. More info:
<a href="https://github.com/jrburke/requirejs/issues/313">313</a>.
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,130 @@
/*jslint strict: false, plusplus: false */
/*global define: false, require: false, XMLHttpRequest: false, ActiveXObject: false,
window: false, Packages: false, java: false, process: false */
(function () {
//Load the text plugin, so that the XHR calls can be made.
var buildMap = {}, fetchText, fs,
progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
function createXhr() {
//Would love to dump the ActiveX crap in here. Need IE 6 to die first.
var xhr, i, progId;
if (typeof XMLHttpRequest !== "undefined") {
return new XMLHttpRequest();
} else {
for (i = 0; i < 3; i++) {
progId = progIds[i];
try {
xhr = new ActiveXObject(progId);
} catch (e) {}
if (xhr) {
progIds = [progId]; // so faster next time
break;
}
}
}
if (!xhr) {
throw new Error("require.getXhr(): XMLHttpRequest not available");
}
return xhr;
}
if (typeof window !== "undefined" && window.navigator && window.document) {
fetchText = function (url, callback) {
var xhr = createXhr();
xhr.open('GET', url, true);
xhr.onreadystatechange = function (evt) {
//Do not explicitly handle errors, those should be
//visible via console output in the browser.
if (xhr.readyState === 4) {
callback(xhr.responseText);
}
};
xhr.send(null);
};
} else if (typeof process !== "undefined" &&
process.versions &&
!!process.versions.node) {
//Using special require.nodeRequire, something added by r.js.
fs = require.nodeRequire('fs');
fetchText = function (url, callback) {
callback(fs.readFileSync(url, 'utf8'));
};
} else if (typeof Packages !== 'undefined') {
//Why Java, why is this so awkward?
fetchText = function (url, callback) {
var encoding = "utf-8",
file = new java.io.File(url),
lineSeparator = java.lang.System.getProperty("line.separator"),
input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)),
stringBuffer, line,
content = '';
try {
stringBuffer = new java.lang.StringBuffer();
line = input.readLine();
// Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324
// http://www.unicode.org/faq/utf_bom.html
// Note that when we use utf-8, the BOM should appear as "EF BB BF", but it doesn't due to this bug in the JDK:
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
if (line && line.length() && line.charAt(0) === 0xfeff) {
// Eat the BOM, since we've already found the encoding on this file,
// and we plan to concatenating this buffer with others; the BOM should
// only appear at the top of a file.
line = line.substring(1);
}
stringBuffer.append(line);
while ((line = input.readLine()) !== null) {
stringBuffer.append(lineSeparator);
stringBuffer.append(line);
}
//Make sure we return a JavaScript string and not a Java string.
content = String(stringBuffer.toString()); //String
} finally {
input.close();
}
callback(content);
};
}
define(function () {
return {
load: function (name, parentRequire, load, config) {
var url = parentRequire.toUrl(name + '.refine');
fetchText(url, function (text) {
text = text.replace(/refine/g, 'define');
if (config.isBuild) {
buildMap[name] = text;
}
//Add in helpful debug line
text += "\r\n//@ sourceURL=" + url;
load.fromText(name, text);
parentRequire([name], function (value) {
load(value);
});
});
},
write: function (pluginName, name, write) {
if (name in buildMap) {
var text = buildMap[name];
write.asModule(pluginName + "!" + name, text);
}
}
};
});
}());

View File

@@ -0,0 +1,37 @@
(function () {
function parse(name) {
var parts = name.split('?'),
index = parseInt(parts[0], 10),
choices = parts[1].split(':'),
choice = choices[index];
return {
index: index,
choices: choices,
choice: choice
};
}
define({
pluginBuilder: './indexBuilder',
normalize: function (name, normalize) {
var parsed = parse(name),
choices = parsed.choices;
//Normalize each path choice.
for (i = 0; i < choices.length; i++) {
choices[i] = normalize(choices[i]);
}
return parsed.index + '?' + choices.join(':');
},
load: function (name, req, load, config) {
req([parse(name).choice], function (value) {
load(value);
});
}
});
}());

View File

@@ -0,0 +1,44 @@
(function () {
function parse(name) {
var parts = name.split('?'),
index = parseInt(parts[0], 10),
choices = parts[1].split(':'),
choice = choices[index];
return {
index: index,
choices: choices,
choice: choice
};
}
define({
normalize: function (name, normalize) {
var parsed = parse(name),
choices = parsed.choices;
//Normalize each path choice.
for (i = 0; i < choices.length; i++) {
choices[i] = normalize(choices[i]);
}
return parsed.index + '?' + choices.join(':');
},
load: function (name, req, load, config) {
req([parse(name).choice], function (value) {
load(value);
});
},
//This is strictly not necessary (and *not* recommended),
//but just doing it as a test.
write: function (pluginName, moduleName, write) {
var parsed = parse(moduleName);
write("define('" + pluginName + "!" + moduleName +
"', ['" + parsed.choice + "'], function (value) { return value;});\n");
}
});
}());

View File

@@ -0,0 +1,15 @@
require({
baseUrl: requirejs.isBrowser ? "./" : "./plugins/"
}, ['require', 'nameOnly!'],
function (require, nameOnly) {
doh.register(
"pluginsNameOnly",
[
function pluginsNameOnly(t){
t.is("nameOnly", nameOnly.name);
}
]
);
doh.run();
});

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Name Only Plugin Test</title>
<script type="text/javascript" src="../doh/runner.js"></script>
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
<script type="text/javascript" data-main="nameOnly-tests.js" src="../../require.js"></script>
</head>
<body>
<h1>require.js: Name Only Plugin Test</h1>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,8 @@
define({
load: function (name, require, onLoad, config) {
onLoad({
name: 'nameOnly'
});
}
});

View File

@@ -0,0 +1,30 @@
var master = new doh.Deferred();
doh.register(
"pluginsOnError",
[
{
name: "pluginsOnError",
timeout: 5000,
runTest: function () {
return master;
}
}
]
);
doh.run();
require({
baseUrl: requirejs.isBrowser ? "./" : "./plugins/onerror",
enforceDefine: true
}, ['thrower!'],
function (thrower) {
master.callback(false);
},
function (err) {
master.callback(true);
});
//Since enforceDefine is used below, define somthing here.
define({});

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Plugin onerror Test</title>
<script type="text/javascript" src="../../doh/runner.js"></script>
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
<script type="text/javascript" data-main="onerror-tests.js" src="../../../require.js"></script>
</head>
<body>
<h1>require.js: Plugin onerror Test</h1>
<a href="https://github.com/jrburke/requirejs/pull/377">More info</a>.</body>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,6 @@
define({
load: function (name, req, load, config) {
req(['fake'], load, load.error);
}
});

View File

@@ -0,0 +1,16 @@
define('text', [], {
load: function () {
throw new Error('not implemented');
}
});
define('text!template.html', [], function () {
return 'main template';
});
define('main', ['text!template.html'], function(template) {
return {
name: 'main',
template: template
};
});

View File

@@ -0,0 +1,17 @@
require({
bundles: {
'main': ['text', 'text!template.html']
}
}, ['text!template.html'], function (template) {
doh.register(
'pluginBundles',
[
function pluginBundles(t){
t.is('main template', template);
}
]
);
doh.run();
});

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Plugin Bundles 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="pluginBundles-tests.js"></script>
</head>
<body>
<h1>require.js: Plugin Bundles Test</h1>
<p>Test using the bundles config with plugins. More info:
<a href="https://github.com/jrburke/requirejs/issues/497">497</a></p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,3 @@
define('text!template.html', [], function () {
return 'main template';
});

View File

@@ -0,0 +1,21 @@
require({
paths: {
'text': '../../../../text/text'
},
bundles: {
'main': ['text!template.html']
}
}, ['text!template.html', 'text!second.html'], function (template, secondTemplate) {
doh.register(
'pluginBundlesSeparateText',
[
function pluginBundlesSeparateText(t){
t.is('main template', template);
t.is('second template', secondTemplate);
}
]
);
doh.run();
});

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Plugin Bundles: Separate Text 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="pluginBundlesSeparateText-tests.js"></script>
</head>
<body>
<h1>require.js: Plugin Bundles: Separate Text Test</h1>
<p>Test using the bundles config with plugins. More info:
<a href="https://github.com/jrburke/requirejs/issues/497">497</a></p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1 @@
second template

View File

@@ -0,0 +1,8 @@
define(['specificCollection', 'bigCollection'], function (specificCollection, bigCollection) {
return {
name: 'app',
specificCollection: specificCollection,
bigCollection: bigCollection
}
});

View File

@@ -0,0 +1 @@
bigCollection

View File

@@ -0,0 +1,7 @@
define(['collection', 'text!bigCollection.html'], function (collection, html) {
return {
name: 'bigCollection',
html: html,
collection: collection
};
});

View File

@@ -0,0 +1,8 @@
define(['collectionHelper'], function (collectionHelper) {
return {
name: 'collection',
collectionHelperName: collectionHelper.name,
componentName: collectionHelper.componentName,
componentHtml: collectionHelper.componentHtml
};
});

View File

@@ -0,0 +1,7 @@
define(['component'], function (component) {
return {
name: 'collectionHelper',
componentName: component.name,
componentHtml: component.html
};
});

View File

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

View File

@@ -0,0 +1 @@
component

View File

@@ -0,0 +1,7 @@
define(['text!component.html'], function (html) {
return {
name: 'component',
html: html
};
});

View File

@@ -0,0 +1,39 @@
requirejs.config({
paths: {
text: '../../circular/complexPlugin/slowText'
}
});
//First make sure the plugin is loaded, so that there is nothing waiting for
//normalization.
require(['text'], function (text) {
function trim(text) {
return text.replace(/^\s+/, '').replace(/\s+$/, '');
}
require(['app'], function (app) {
doh.register(
"pluginsLast",
[
function pluginsLast(t){
t.is("app", app.name);
t.is("specificCollection", app.specificCollection.name);
t.is("specificCollection", app.specificCollection.html);
t.is("bigCollection", app.bigCollection.name);
t.is("bigCollection", app.bigCollection.html);
t.is("collection", app.bigCollection.collection.name);
t.is("collectionHelper", app.bigCollection.collection.collectionHelperName);
t.is("component", app.bigCollection.collection.componentName);
t.is("component", app.bigCollection.collection.componentHtml);
}
]
);
doh.run();
});
});

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Plugin Last Test</title>
<script type="text/javascript" src="../../doh/runner.js"></script>
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
<script type="text/javascript" data-main="main" src="../../../require.js"></script>
</head>
<body>
<h1>require.js: Plugin Last Test</h1>
<p>Test more complex plugin example where cycle breaking is being invoked
when it should not. More info:
<a href="https://github.com/jrburke/requirejs/issues/306">306</a>.</p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1 @@
specificCollection

View File

@@ -0,0 +1,7 @@
define(['collection', 'text!specificCollection.html'], function (collection, html) {
return {
name: 'specificCollection',
html: html,
collection: collection
};
});

View File

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

View File

@@ -0,0 +1,5 @@
define('employee', ['plugin!person'], function(person) {
return {
name: 'employed ' + person.name
};
});

View File

@@ -0,0 +1,23 @@
require({
map: {
'*': {
'person': 'employee'
},
'employee': {
'person': 'person'
}
}
}, ['application'], function (application) {
doh.register(
'pluginMapDynamic',
[
function pluginMapDynamic(t){
t.is('application', application.name);
t.is('employed person', application.person.name);
}
]
);
doh.run();
});

View File

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

View File

@@ -0,0 +1,7 @@
define('plugin', [], {
load: function (name, req, load, config) {
req([name], function (value) {
load(value);
});
}
});

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Plugin Map DynamicTest</title>
<script type="text/javascript" src="../../../doh/runner.js"></script>
<script type="text/javascript" src="../../../doh/_browserRunner.js"></script>
<script data-main="main" src="../../../../require.js"></script>
</head>
<body>
<h1>require.js: Plugin Map Test</h1>
<p>Test using the map config with plugins and dynamically loaded modules. More info:
<a href="https://github.com/jrburke/requirejs/issues/326">326</a></p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,48 @@
define('plugin', [], {
load: function (name, req, load, config) {
req([name], function (value) {
load(value);
});
}
});
define('person', [], {
name: 'person'
});
define('employee', ['plugin!person'], function(person) {
return {
name: 'employed ' + person.name
};
});
define('application', ['person'], function(person) {
return {
name: 'application',
person: person
};
});
require({
map: {
'*': {
'person': 'employee'
},
'employee': {
'person': 'person'
}
}
}, ['application'], function (application) {
doh.register(
'pluginMap',
[
function pluginMap(t){
t.is('application', application.name);
t.is('employed person', application.person.name);
}
]
);
doh.run();
});

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Plugin Map 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="pluginMap-tests.js"></script>
</head>
<body>
<h1>require.js: Plugin Map Test</h1>
<p>Test using the map config with plugins. More info:
<a href="https://github.com/jrburke/requirejs/issues/320">320</a></p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,6 @@
define({
load: function (id, require, load, config) {
load(id);
}
});

View File

@@ -0,0 +1,19 @@
require({
map: {
'*': {
'plugin': 'plugin/plugin'
}
}
}, ['plugin!foo'], function (value) {
doh.register(
'pluginMapSameName',
[
function pluginMapSameName(t){
t.is('foo', value);
}
]
);
doh.run();
});

View File

@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Plugin Map Same Name 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="pluginMapSameName-tests.js"></script>
</head>
<body>
<h1>require.js: Plugin Map Same Name Test</h1>
<p>Test using the map config with plugins. but include a map value that
contains the original name of the plugin, to confirm the map translation
is only done once:
<a href="https://github.com/jrburke/requirejs/issues/484">484</a></p>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,4 @@
//The refine plugin changes the word refine into define.
refine({
name: 'a' + window.legacy.name
});

View File

@@ -0,0 +1,4 @@
window.legacy = {
name: 'legacy'
};

View File

@@ -0,0 +1,22 @@
require({
baseUrl: requirejs.isBrowser ? './' : './plugins/pluginShim',
paths: {
'text': '../../../../text/text',
'refine': '../fromText/refine'
},
shim: {
'refine!a': ['!legacy']
}
}, ['refine!a'],
function (a) {
doh.register(
'pluginShim',
[
function pluginShim(t){
t.is('alegacy', a.name);
}
]
);
doh.run();
});

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: pluginShim Plugin Test</title>
<script type="text/javascript" src="../../doh/runner.js"></script>
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
<script type="text/javascript" data-main="pluginShim-tests.js" src="../../../require.js"></script>
</head>
<body>
<h1>require.js: pluginShim Plugin Test</h1>
<p>Confirms that shim config works with plugin resources. More info:
<a href="https://github.com/jrburke/requirejs/issues/324">324</a>.
<p>Check console for messages</p>
</body>
</html>

View File

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

View File

@@ -0,0 +1,5 @@
define(function () {
return {
name: "bPrime"
};
});

View File

@@ -0,0 +1,3 @@
define({
name: "cPrime"
});

View File

@@ -0,0 +1,13 @@
define(function (require) {
return {
getA: function () {
return require("../index!0?./a:./b:./c");
},
getC: function () {
return require("../index!2?./a:./b:./c");
},
getB: function () {
return require("../index!1?./a:./b:./c");
}
};
});

View File

@@ -0,0 +1,20 @@
require({
baseUrl: requirejs.isBrowser ? "./" : "./plugins/"
}, ['require', 'earth', 'prime/earth'],
function (require, earth, primeEarth) {
doh.register(
"pluginsSync",
[
function pluginsSync(t){
t.is("a", earth.getA().name);
t.is("c", earth.getC().name);
t.is("b", earth.getB().name);
t.is("aPrime", primeEarth.getA().name);
t.is("cPrime", primeEarth.getC().name);
t.is("bPrime", primeEarth.getB().name);
}
]
);
doh.run();
});

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Sync Plugin Test</title>
<script type="text/javascript" src="../doh/runner.js"></script>
<script type="text/javascript" src="../doh/_browserRunner.js"></script>
<script type="text/javascript" data-main="sync-tests.js" src="../../require.js"></script>
</head>
<body>
<h1>require.js: Sync Plugin Test</h1>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1 @@
hello world

View File

@@ -0,0 +1,18 @@
require({
baseUrl: requirejs.isBrowser ? './' : './plugins/textDepend',
paths: {
'text': '../../../../text/text'
}
}, ['textDepend!a'],
function (textValue) {
doh.register(
'textDepend',
[
function textDepend(t){
t.is('hello world', textValue);
}
]
);
doh.run();
});

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>require.js: Plugin that has text! Dependency Test</title>
<script type="text/javascript" src="../../doh/runner.js"></script>
<script type="text/javascript" src="../../doh/_browserRunner.js"></script>
<script type="text/javascript" data-main="textDepend-tests.js" src="../../../require.js"></script>
</head>
<body>
<h1>require.js: Plugin that has text! Dependency Test</h1>
<p>Check console for messages</p>
</body>
</html>

View File

@@ -0,0 +1,7 @@
define(['text!test.txt'], function (text) {
return {
load: function (name, req, load, config) {
load(text);
}
};
});