Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
todomvc
Commits
83fef80f
Commit
83fef80f
authored
Nov 20, 2014
by
TasteBot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update the build files for gh-pages [ci skip]
parent
7be92e46
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
241 additions
and
184 deletions
+241
-184
examples/olives/bower_components/emily/build/Emily.js
examples/olives/bower_components/emily/build/Emily.js
+40
-40
examples/olives/bower_components/requirejs/require.js
examples/olives/bower_components/requirejs/require.js
+201
-144
No files found.
examples/olives/bower_components/emily/build/Emily.js
View file @
83fef80f
...
...
@@ -26,10 +26,10 @@ function Tools(){
* @returns {Object} the global object
*/
getGlobal
:
function
getGlobal
()
{
var
func
=
function
()
{
return
this
;
};
return
func
.
call
(
null
);
var
func
=
function
()
{
return
this
;
};
return
func
.
call
(
null
);
},
/**
...
...
@@ -822,43 +822,43 @@ function Promise(Observable, StateMachine) {
* @returns {Promise} the new promise
*/
this
.
then
=
function
then
()
{
var
promise
=
new
PromiseConstructor
;
// If a fulfillment callback is given
if
(
arguments
[
0
]
instanceof
Function
)
{
// If the second argument is also a function, then no scope is given
if
(
arguments
[
1
]
instanceof
Function
)
{
_stateMachine
.
event
(
"
toFulfill
"
,
this
.
makeResolver
(
promise
,
arguments
[
0
]));
}
else
{
// If the second argument is not a function, it's the scope
_stateMachine
.
event
(
"
toFulfill
"
,
this
.
makeResolver
(
promise
,
arguments
[
0
],
arguments
[
1
]));
}
}
else
{
// If no fulfillment callback given, give a default one
_stateMachine
.
event
(
"
toFulfill
"
,
this
.
makeResolver
(
promise
,
function
()
{
promise
.
fulfill
(
_value
);
}));
}
// if the second arguments is a callback, it's the rejection one, and the next argument is the scope
if
(
arguments
[
1
]
instanceof
Function
)
{
_stateMachine
.
event
(
"
toReject
"
,
this
.
makeResolver
(
promise
,
arguments
[
1
],
arguments
[
2
]));
}
// if the third arguments is a callback, it's the rejection one, and the next arguments is the sopce
if
(
arguments
[
2
]
instanceof
Function
)
{
var
promise
=
new
PromiseConstructor
;
// If a fulfillment callback is given
if
(
arguments
[
0
]
instanceof
Function
)
{
// If the second argument is also a function, then no scope is given
if
(
arguments
[
1
]
instanceof
Function
)
{
_stateMachine
.
event
(
"
toFulfill
"
,
this
.
makeResolver
(
promise
,
arguments
[
0
]));
}
else
{
// If the second argument is not a function, it's the scope
_stateMachine
.
event
(
"
toFulfill
"
,
this
.
makeResolver
(
promise
,
arguments
[
0
],
arguments
[
1
]));
}
}
else
{
// If no fulfillment callback given, give a default one
_stateMachine
.
event
(
"
toFulfill
"
,
this
.
makeResolver
(
promise
,
function
()
{
promise
.
fulfill
(
_value
);
}));
}
// if the second arguments is a callback, it's the rejection one, and the next argument is the scope
if
(
arguments
[
1
]
instanceof
Function
)
{
_stateMachine
.
event
(
"
toReject
"
,
this
.
makeResolver
(
promise
,
arguments
[
1
],
arguments
[
2
]));
}
// if the third arguments is a callback, it's the rejection one, and the next arguments is the sopce
if
(
arguments
[
2
]
instanceof
Function
)
{
_stateMachine
.
event
(
"
toReject
"
,
this
.
makeResolver
(
promise
,
arguments
[
2
],
arguments
[
3
]));
}
}
// If no rejection callback is given, give a default one
if
(
!
(
arguments
[
1
]
instanceof
Function
)
&&
!
(
arguments
[
2
]
instanceof
Function
))
{
_stateMachine
.
event
(
"
toReject
"
,
this
.
makeResolver
(
promise
,
function
()
{
promise
.
reject
(
_reason
);
}));
}
// If no rejection callback is given, give a default one
if
(
!
(
arguments
[
1
]
instanceof
Function
)
&&
!
(
arguments
[
2
]
instanceof
Function
))
{
_stateMachine
.
event
(
"
toReject
"
,
this
.
makeResolver
(
promise
,
function
()
{
promise
.
reject
(
_reason
);
}));
}
return
promise
;
return
promise
;
};
/**
...
...
@@ -912,7 +912,7 @@ function Promise(Observable, StateMachine) {
* @private
*/
this
.
getReason
=
function
getReason
()
{
return
_reason
;
return
_reason
;
};
/**
...
...
@@ -921,7 +921,7 @@ function Promise(Observable, StateMachine) {
* @private
*/
this
.
getValue
=
function
getValue
()
{
return
_value
;
return
_value
;
};
/**
...
...
examples/olives/bower_components/requirejs/require.js
View file @
83fef80f
/** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.1.
5 Copyright (c) 2010-2012
, The Dojo Foundation All Rights Reserved.
* @license RequireJS 2.1.
15 Copyright (c) 2010-2014
, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
...
...
@@ -12,7 +12,7 @@ var requirejs, require, define;
(
function
(
global
)
{
var
req
,
s
,
head
,
baseElement
,
dataMain
,
src
,
interactiveScript
,
currentlyAddingScript
,
mainScript
,
subPath
,
version
=
'
2.1.5
'
,
version
=
'
2.1.
1
5
'
,
commentRegExp
=
/
(\/\*([\s\S]
*
?)\*\/
|
([^
:
]
|^
)\/\/(
.*
)
$
)
/mg
,
cjsRequireRegExp
=
/
[^
.
]\s
*require
\s
*
\(\s
*
[
"'
]([^
'"
\s]
+
)[
"'
]\s
*
\)
/g
,
jsSuffixRegExp
=
/
\.
js$/
,
...
...
@@ -22,7 +22,7 @@ var requirejs, require, define;
hasOwn
=
op
.
hasOwnProperty
,
ap
=
Array
.
prototype
,
apsp
=
ap
.
splice
,
isBrowser
=
!!
(
typeof
window
!==
'
undefined
'
&&
navigator
&&
document
),
isBrowser
=
!!
(
typeof
window
!==
'
undefined
'
&&
typeof
navigator
!==
'
undefined
'
&&
window
.
document
),
isWebWorker
=
!
isBrowser
&&
typeof
importScripts
!==
'
undefined
'
,
//PS3 indicates loaded and complete, but need to wait for complete
//specifically. Sequence is 'loading', 'loaded', execution,
...
...
@@ -108,7 +108,10 @@ var requirejs, require, define;
if
(
source
)
{
eachProp
(
source
,
function
(
value
,
prop
)
{
if
(
force
||
!
hasProp
(
target
,
prop
))
{
if
(
deepStringMixin
&&
typeof
value
!==
'
string
'
)
{
if
(
deepStringMixin
&&
typeof
value
===
'
object
'
&&
value
&&
!
isArray
(
value
)
&&
!
isFunction
(
value
)
&&
!
(
value
instanceof
RegExp
))
{
if
(
!
target
[
prop
])
{
target
[
prop
]
=
{};
}
...
...
@@ -134,7 +137,11 @@ var requirejs, require, define;
return
document
.
getElementsByTagName
(
'
script
'
);
}
//Allow getting a global that expressed in
function
defaultOnError
(
err
)
{
throw
err
;
}
//Allow getting a global that is expressed in
//dot notation, like 'a.b.c'.
function
getGlobal
(
value
)
{
if
(
!
value
)
{
...
...
@@ -173,7 +180,7 @@ var requirejs, require, define;
if
(
typeof
requirejs
!==
'
undefined
'
)
{
if
(
isFunction
(
requirejs
))
{
//Do not overwrite an
d
existing requirejs instance.
//Do not overwrite an existing requirejs instance.
return
;
}
cfg
=
requirejs
;
...
...
@@ -197,6 +204,7 @@ var requirejs, require, define;
waitSeconds
:
7
,
baseUrl
:
'
./
'
,
paths
:
{},
bundles
:
{},
pkgs
:
{},
shim
:
{},
config
:
{}
...
...
@@ -210,6 +218,7 @@ var requirejs, require, define;
defQueue
=
[],
defined
=
{},
urlFetched
=
{},
bundlesMap
=
{},
requireCounter
=
1
,
unnormalizedCounter
=
1
;
...
...
@@ -224,20 +233,19 @@ var requirejs, require, define;
*/
function
trimDots
(
ary
)
{
var
i
,
part
;
for
(
i
=
0
;
ary
[
i
];
i
+=
1
)
{
for
(
i
=
0
;
i
<
ary
.
length
;
i
++
)
{
part
=
ary
[
i
];
if
(
part
===
'
.
'
)
{
ary
.
splice
(
i
,
1
);
i
-=
1
;
}
else
if
(
part
===
'
..
'
)
{
if
(
i
===
1
&&
(
ary
[
2
]
===
'
..
'
||
ary
[
0
]
===
'
..
'
))
{
//End of the line. Keep at least one non-dot
//path segment at the front so it can be mapped
//correctly to disk. Otherwise, there is likely
//no path mapping for a path starting with '..'.
//This can still fail, but catches the most reasonable
//uses of ..
break
;
// If at the start, or previous value is still ..,
// keep them so that when converted to a path it may
// still work when converted to a path, even though
// as an ID it is less than ideal. In larger point
// releases, may be better to just kick out an error.
if
(
i
===
0
||
(
i
==
1
&&
ary
[
2
]
===
'
..
'
)
||
ary
[
i
-
1
]
===
'
..
'
)
{
continue
;
}
else
if
(
i
>
0
)
{
ary
.
splice
(
i
-
1
,
2
);
i
-=
2
;
...
...
@@ -257,54 +265,45 @@ var requirejs, require, define;
* @returns {String} normalized name
*/
function
normalize
(
name
,
baseName
,
applyMap
)
{
var
pkgName
,
pkgConfig
,
mapValue
,
nameParts
,
i
,
j
,
nameSegment
,
foundMap
,
foundI
,
foundStarMap
,
starI
,
baseParts
=
baseName
&&
baseName
.
split
(
'
/
'
),
normalizedBaseParts
=
baseParts
,
var
pkgMain
,
mapValue
,
nameParts
,
i
,
j
,
nameSegment
,
lastIndex
,
foundMap
,
foundI
,
foundStarMap
,
starI
,
normalizedBaseParts
,
baseParts
=
(
baseName
&&
baseName
.
split
(
'
/
'
)),
map
=
config
.
map
,
starMap
=
map
&&
map
[
'
*
'
];
//Adjust any relative paths.
if
(
name
&&
name
.
charAt
(
0
)
===
'
.
'
)
{
//If have a base name, try to normalize against it,
//otherwise, assume it is a top-level require that will
//be relative to baseUrl in the end.
if
(
baseName
)
{
if
(
getOwn
(
config
.
pkgs
,
baseName
))
{
//If the baseName is a package name, then just treat it as one
//name to concat the name with.
normalizedBaseParts
=
baseParts
=
[
baseName
];
}
else
{
//Convert baseName to array, and lop off the last part,
//so that . matches that 'directory' and not name of the baseName's
//module. For instance, baseName of 'one/two/three', maps to
//'one/two/three.js', but we want the directory, 'one/two' for
//this normalization.
normalizedBaseParts
=
baseParts
.
slice
(
0
,
baseParts
.
length
-
1
);
}
name
=
normalizedBaseParts
.
concat
(
name
.
split
(
'
/
'
));
trimDots
(
name
);
if
(
name
)
{
name
=
name
.
split
(
'
/
'
);
lastIndex
=
name
.
length
-
1
;
// If wanting node ID compatibility, strip .js from end
// of IDs. Have to do this here, and not in nameToUrl
// because node allows either .js or non .js to map
// to same file.
if
(
config
.
nodeIdCompat
&&
jsSuffixRegExp
.
test
(
name
[
lastIndex
]))
{
name
[
lastIndex
]
=
name
[
lastIndex
].
replace
(
jsSuffixRegExp
,
''
);
}
//Some use of packages may use a . path to reference the
//'main' module name, so normalize for that.
pkgConfig
=
getOwn
(
config
.
pkgs
,
(
pkgName
=
name
[
0
]));
name
=
name
.
join
(
'
/
'
);
if
(
pkgConfig
&&
name
===
pkgName
+
'
/
'
+
pkgConfig
.
main
)
{
name
=
pkgName
;
}
}
else
if
(
name
.
indexOf
(
'
./
'
)
===
0
)
{
// No baseName, so this is ID is resolved relative
// to baseUrl, pull off the leading dot.
name
=
name
.
substring
(
2
);
// Starts with a '.' so need the baseName
if
(
name
[
0
].
charAt
(
0
)
===
'
.
'
&&
baseParts
)
{
//Convert baseName to array, and lop off the last part,
//so that . matches that 'directory' and not name of the baseName's
//module. For instance, baseName of 'one/two/three', maps to
//'one/two/three.js', but we want the directory, 'one/two' for
//this normalization.
normalizedBaseParts
=
baseParts
.
slice
(
0
,
baseParts
.
length
-
1
);
name
=
normalizedBaseParts
.
concat
(
name
);
}
trimDots
(
name
);
name
=
name
.
join
(
'
/
'
);
}
//Apply map config if available.
if
(
applyMap
&&
map
&&
(
baseParts
||
starMap
))
{
nameParts
=
name
.
split
(
'
/
'
);
for
(
i
=
nameParts
.
length
;
i
>
0
;
i
-=
1
)
{
outerLoop
:
for
(
i
=
nameParts
.
length
;
i
>
0
;
i
-=
1
)
{
nameSegment
=
nameParts
.
slice
(
0
,
i
).
join
(
'
/
'
);
if
(
baseParts
)
{
...
...
@@ -321,16 +320,12 @@ var requirejs, require, define;
//Match, update name to the new value.
foundMap
=
mapValue
;
foundI
=
i
;
break
;
break
outerLoop
;
}
}
}
}
if
(
foundMap
)
{
break
;
}
//Check for a star map match, but just hold on to it,
//if there is a shorter segment match later in a matching
//config, then favor over this star map.
...
...
@@ -351,7 +346,11 @@ var requirejs, require, define;
}
}
return
name
;
// If the name points to a package's name, use
// the package main instead.
pkgMain
=
getOwn
(
config
.
pkgs
,
name
);
return
pkgMain
?
pkgMain
:
name
;
}
function
removeScript
(
name
)
{
...
...
@@ -369,12 +368,17 @@ var requirejs, require, define;
function
hasPathFallback
(
id
)
{
var
pathConfig
=
getOwn
(
config
.
paths
,
id
);
if
(
pathConfig
&&
isArray
(
pathConfig
)
&&
pathConfig
.
length
>
1
)
{
removeScript
(
id
);
//Pop off the first array value, since it failed, and
//retry
pathConfig
.
shift
();
context
.
require
.
undef
(
id
);
context
.
require
([
id
]);
//Custom require that does not do map translation, since
//ID is "absolute", already mapped/resolved.
context
.
makeRequire
(
null
,
{
skipMap
:
true
})([
id
]);
return
true
;
}
}
...
...
@@ -440,7 +444,16 @@ var requirejs, require, define;
return
normalize
(
name
,
parentName
,
applyMap
);
});
}
else
{
normalizedName
=
normalize
(
name
,
parentName
,
applyMap
);
// If nested plugin references, then do not try to
// normalize, as it will not normalize correctly. This
// places a restriction on resourceIds, and the longer
// term solution is not to normalize until plugins are
// loaded and all normalizations to allow for async
// loading of a loader plugin. But for now, fixes the
// common uses. Details in #1131
normalizedName
=
name
.
indexOf
(
'
!
'
)
===
-
1
?
normalize
(
name
,
parentName
,
applyMap
)
:
name
;
}
}
else
{
//A regular module.
...
...
@@ -500,7 +513,12 @@ var requirejs, require, define;
fn
(
defined
[
id
]);
}
}
else
{
getModule
(
depMap
).
on
(
name
,
fn
);
mod
=
getModule
(
depMap
);
if
(
mod
.
error
&&
name
===
'
error
'
)
{
fn
(
mod
.
error
);
}
else
{
mod
.
on
(
name
,
fn
);
}
}
}
...
...
@@ -540,7 +558,7 @@ var requirejs, require, define;
//local var ref to defQueue, so cannot just reassign the one
//on context.
apsp
.
apply
(
defQueue
,
[
defQueue
.
length
-
1
,
0
].
concat
(
globalDefQueue
));
[
defQueue
.
length
,
0
].
concat
(
globalDefQueue
));
globalDefQueue
=
[];
}
}
...
...
@@ -557,7 +575,7 @@ var requirejs, require, define;
mod
.
usingExports
=
true
;
if
(
mod
.
map
.
isDefine
)
{
if
(
mod
.
exports
)
{
return
mod
.
exports
;
return
(
defined
[
mod
.
map
.
id
]
=
mod
.
exports
)
;
}
else
{
return
(
mod
.
exports
=
defined
[
mod
.
map
.
id
]
=
{});
}
...
...
@@ -571,9 +589,9 @@ var requirejs, require, define;
id
:
mod
.
map
.
id
,
uri
:
mod
.
map
.
url
,
config
:
function
()
{
return
(
config
.
config
&&
getOwn
(
config
.
config
,
mod
.
map
.
id
)
)
||
{};
return
getOwn
(
config
.
config
,
mod
.
map
.
id
)
||
{};
},
exports
:
defined
[
mod
.
map
.
id
]
exports
:
mod
.
exports
||
(
mod
.
exports
=
{})
});
}
}
...
...
@@ -614,7 +632,7 @@ var requirejs, require, define;
}
function
checkLoaded
()
{
var
map
,
modId
,
err
,
usingPathFallback
,
var
err
,
usingPathFallback
,
waitInterval
=
config
.
waitSeconds
*
1000
,
//It is possible to disable the wait interval by using waitSeconds of 0.
expired
=
waitInterval
&&
(
context
.
startTime
+
waitInterval
)
<
new
Date
().
getTime
(),
...
...
@@ -632,8 +650,8 @@ var requirejs, require, define;
//Figure out the state of all the modules.
eachProp
(
enabledRegistry
,
function
(
mod
)
{
map
=
mod
.
map
;
modId
=
map
.
id
;
var
map
=
mod
.
map
,
modId
=
map
.
id
;
//Skip things that are not enabled or in error state.
if
(
!
mod
.
enabled
)
{
...
...
@@ -840,8 +858,13 @@ var requirejs, require, define;
if
(
this
.
depCount
<
1
&&
!
this
.
defined
)
{
if
(
isFunction
(
factory
))
{
//If there is an error listener, favor passing
//to that instead of throwing an error.
if
(
this
.
events
.
error
)
{
//to that instead of throwing an error. However,
//only do it for define()'d modules. require
//errbacks should not be called for failures in
//their callbacks (#699). However if a global
//onError is set, use that.
if
((
this
.
events
.
error
&&
this
.
map
.
isDefine
)
||
req
.
onError
!==
defaultOnError
)
{
try
{
exports
=
context
.
execCb
(
id
,
factory
,
depExports
,
exports
);
}
catch
(
e
)
{
...
...
@@ -851,17 +874,14 @@ var requirejs, require, define;
exports
=
context
.
execCb
(
id
,
factory
,
depExports
,
exports
);
}
if
(
this
.
map
.
isDefine
)
{
//If setting exports via 'module' is in play,
//favor that over return value and exports. After that,
//favor a non-undefined return value over exports use.
// Favor return value over exports. If node/cjs in play,
// then will not have a return value anyway. Favor
// module.exports assignment over exports object.
if
(
this
.
map
.
isDefine
&&
exports
===
undefined
)
{
cjsModule
=
this
.
module
;
if
(
cjsModule
&&
cjsModule
.
exports
!==
undefined
&&
//Make sure it is not already the exports value
cjsModule
.
exports
!==
this
.
exports
)
{
if
(
cjsModule
)
{
exports
=
cjsModule
.
exports
;
}
else
if
(
exports
===
undefined
&&
this
.
usingExports
)
{
}
else
if
(
this
.
usingExports
)
{
//exports already set the defined value.
exports
=
this
.
exports
;
}
...
...
@@ -869,8 +889,8 @@ var requirejs, require, define;
if
(
err
)
{
err
.
requireMap
=
this
.
map
;
err
.
requireModules
=
[
this
.
map
.
id
]
;
err
.
requireType
=
'
defin
e
'
;
err
.
requireModules
=
this
.
map
.
isDefine
?
[
this
.
map
.
id
]
:
null
;
err
.
requireType
=
this
.
map
.
isDefine
?
'
define
'
:
'
requir
e
'
;
return
onError
((
this
.
error
=
err
));
}
...
...
@@ -921,6 +941,7 @@ var requirejs, require, define;
on
(
pluginMap
,
'
defined
'
,
bind
(
this
,
function
(
plugin
)
{
var
load
,
normalizedMap
,
normalizedMod
,
bundleId
=
getOwn
(
bundlesMap
,
this
.
map
.
id
),
name
=
this
.
map
.
name
,
parentName
=
this
.
map
.
parentMap
?
this
.
map
.
parentMap
.
name
:
null
,
localRequire
=
context
.
makeRequire
(
map
.
parentMap
,
{
...
...
@@ -966,6 +987,14 @@ var requirejs, require, define;
return
;
}
//If a paths config, then just load that file instead to
//resolve the plugin, as it is built into that paths layer.
if
(
bundleId
)
{
this
.
map
.
url
=
context
.
nameToUrl
(
bundleId
);
this
.
load
();
return
;
}
load
=
bind
(
this
,
function
(
value
)
{
this
.
init
([],
function
()
{
return
value
;
},
null
,
{
enabled
:
true
...
...
@@ -1093,7 +1122,7 @@ var requirejs, require, define;
}));
if
(
this
.
errback
)
{
on
(
depMap
,
'
error
'
,
this
.
errback
);
on
(
depMap
,
'
error
'
,
bind
(
this
,
this
.
errback
)
);
}
}
...
...
@@ -1230,31 +1259,38 @@ var requirejs, require, define;
}
}
//Save off the paths
and packages
since they require special processing,
//Save off the paths since they require special processing,
//they are additive.
var
pkgs
=
config
.
pkgs
,
shim
=
config
.
shim
,
var
shim
=
config
.
shim
,
objs
=
{
paths
:
true
,
bundles
:
true
,
config
:
true
,
map
:
true
};
eachProp
(
cfg
,
function
(
value
,
prop
)
{
if
(
objs
[
prop
])
{
if
(
prop
===
'
map
'
)
{
if
(
!
config
.
map
)
{
config
.
map
=
{};
}
mixin
(
config
[
prop
],
value
,
true
,
true
);
}
else
{
mixin
(
config
[
prop
],
value
,
true
);
if
(
!
config
[
prop
])
{
config
[
prop
]
=
{};
}
mixin
(
config
[
prop
],
value
,
true
,
true
);
}
else
{
config
[
prop
]
=
value
;
}
});
//Reverse map the bundles
if
(
cfg
.
bundles
)
{
eachProp
(
cfg
.
bundles
,
function
(
value
,
prop
)
{
each
(
value
,
function
(
v
)
{
if
(
v
!==
prop
)
{
bundlesMap
[
v
]
=
prop
;
}
});
});
}
//Merge shim
if
(
cfg
.
shim
)
{
eachProp
(
cfg
.
shim
,
function
(
value
,
id
)
{
...
...
@@ -1275,29 +1311,25 @@ var requirejs, require, define;
//Adjust packages if necessary.
if
(
cfg
.
packages
)
{
each
(
cfg
.
packages
,
function
(
pkgObj
)
{
var
location
;
var
location
,
name
;
pkgObj
=
typeof
pkgObj
===
'
string
'
?
{
name
:
pkgObj
}
:
pkgObj
;
name
=
pkgObj
.
name
;
location
=
pkgObj
.
location
;
if
(
location
)
{
config
.
paths
[
name
]
=
pkgObj
.
location
;
}
//Create a brand new object on pkgs, since currentPackages can
//be passed in again, and config.pkgs is the internal transformed
//state for all package configs.
pkgs
[
pkgObj
.
name
]
=
{
name
:
pkgObj
.
name
,
location
:
location
||
pkgObj
.
name
,
//Remove leading dot in main, so main paths are normalized,
//and remove any trailing .js, since different package
//envs have different conventions: some use a module name,
//some use a file name.
main
:
(
pkgObj
.
main
||
'
main
'
)
.
replace
(
currDirRegExp
,
''
)
.
replace
(
jsSuffixRegExp
,
''
)
};
//Save pointer to main module ID for pkg name.
//Remove leading dot in main, so main paths are normalized,
//and remove any trailing .js, since different package
//envs have different conventions: some use a module name,
//some use a file name.
config
.
pkgs
[
name
]
=
pkgObj
.
name
+
'
/
'
+
(
pkgObj
.
main
||
'
main
'
)
.
replace
(
currDirRegExp
,
''
)
.
replace
(
jsSuffixRegExp
,
''
);
});
//Done with modifications, assing packages back to context config
config
.
pkgs
=
pkgs
;
}
//If there are any "waiting to execute" modules in the registry,
...
...
@@ -1444,10 +1476,21 @@ var requirejs, require, define;
var
map
=
makeModuleMap
(
id
,
relMap
,
true
),
mod
=
getOwn
(
registry
,
id
);
removeScript
(
id
);
delete
defined
[
id
];
delete
urlFetched
[
map
.
url
];
delete
undefEvents
[
id
];
//Clean queued defines too. Go backwards
//in array so that the splices do not
//mess up the iteration.
eachReverse
(
defQueue
,
function
(
args
,
i
)
{
if
(
args
[
0
]
===
id
)
{
defQueue
.
splice
(
i
,
1
);
}
});
if
(
mod
)
{
//Hold on to listeners in case the
//module will be attempted to be reloaded
...
...
@@ -1467,7 +1510,7 @@ var requirejs, require, define;
/**
* Called to enable a module if it is still in the registry
* awaiting enablement. A second arg, parent, the parent module,
* is passed in for context, when this method is overriden by
* is passed in for context, when this method is overrid
d
en by
* the optimizer. Not shown here to keep code compact.
*/
enable
:
function
(
depMap
)
{
...
...
@@ -1541,8 +1584,19 @@ var requirejs, require, define;
* internal API, not a public one. Use toUrl for the public API.
*/
nameToUrl
:
function
(
moduleName
,
ext
,
skipExt
)
{
var
paths
,
pkgs
,
pkg
,
pkgPath
,
syms
,
i
,
parentModule
,
url
,
parentPath
;
var
paths
,
syms
,
i
,
parentModule
,
url
,
parentPath
,
bundleId
,
pkgMain
=
getOwn
(
config
.
pkgs
,
moduleName
);
if
(
pkgMain
)
{
moduleName
=
pkgMain
;
}
bundleId
=
getOwn
(
bundlesMap
,
moduleName
);
if
(
bundleId
)
{
return
context
.
nameToUrl
(
bundleId
,
ext
,
skipExt
);
}
//If a colon is in the URL, it indicates a protocol is used and it is just
//an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
...
...
@@ -1556,7 +1610,6 @@ var requirejs, require, define;
}
else
{
//A module that needs to be converted to a path.
paths
=
config
.
paths
;
pkgs
=
config
.
pkgs
;
syms
=
moduleName
.
split
(
'
/
'
);
//For each module name segment, see if there is a path
...
...
@@ -1564,7 +1617,7 @@ var requirejs, require, define;
//and work up from it.
for
(
i
=
syms
.
length
;
i
>
0
;
i
-=
1
)
{
parentModule
=
syms
.
slice
(
0
,
i
).
join
(
'
/
'
);
pkg
=
getOwn
(
pkgs
,
parentModule
);
parentPath
=
getOwn
(
paths
,
parentModule
);
if
(
parentPath
)
{
//If an array, it means there are a few choices,
...
...
@@ -1574,22 +1627,12 @@ var requirejs, require, define;
}
syms
.
splice
(
0
,
i
,
parentPath
);
break
;
}
else
if
(
pkg
)
{
//If module name is just the package name, then looking
//for the main module.
if
(
moduleName
===
pkg
.
name
)
{
pkgPath
=
pkg
.
location
+
'
/
'
+
pkg
.
main
;
}
else
{
pkgPath
=
pkg
.
location
;
}
syms
.
splice
(
0
,
i
,
pkgPath
);
break
;
}
}
//Join the path parts together, then figure out if baseUrl is needed.
url
=
syms
.
join
(
'
/
'
);
url
+=
(
ext
||
(
/
\?
/
.
test
(
url
)
||
skipExt
?
''
:
'
.js
'
));
url
+=
(
ext
||
(
/
^data
\:
|
\?
/
.
test
(
url
)
||
skipExt
?
''
:
'
.js
'
));
url
=
(
url
.
charAt
(
0
)
===
'
/
'
||
url
.
match
(
/^
[\w\+\.\-]
+:/
)
?
''
:
config
.
baseUrl
)
+
url
;
}
...
...
@@ -1605,7 +1648,7 @@ var requirejs, require, define;
},
/**
* Executes a module callack function. Broken out as a separate function
* Executes a module call
b
ack function. Broken out as a separate function
* solely to allow the build system to sequence the files in the built
* layer in the right sequence.
*
...
...
@@ -1643,7 +1686,7 @@ var requirejs, require, define;
onScriptError
:
function
(
evt
)
{
var
data
=
getScriptData
(
evt
);
if
(
!
hasPathFallback
(
data
.
id
))
{
return
onError
(
makeError
(
'
scripterror
'
,
'
Script error
'
,
evt
,
[
data
.
id
]));
return
onError
(
makeError
(
'
scripterror
'
,
'
Script error
for:
'
+
data
.
id
,
evt
,
[
data
.
id
]));
}
}
};
...
...
@@ -1772,8 +1815,19 @@ var requirejs, require, define;
* function. Intercept/override it if you want custom error handling.
* @param {Error} err the error object.
*/
req
.
onError
=
function
(
err
)
{
throw
err
;
req
.
onError
=
defaultOnError
;
/**
* Creates the node for the load command. Only used in browser envs.
*/
req
.
createNode
=
function
(
config
,
moduleName
,
url
)
{
var
node
=
config
.
xhtml
?
document
.
createElementNS
(
'
http://www.w3.org/1999/xhtml
'
,
'
html:script
'
)
:
document
.
createElement
(
'
script
'
);
node
.
type
=
config
.
scriptType
||
'
text/javascript
'
;
node
.
charset
=
'
utf-8
'
;
node
.
async
=
true
;
return
node
;
};
/**
...
...
@@ -1790,12 +1844,7 @@ var requirejs, require, define;
node
;
if
(
isBrowser
)
{
//In the browser so use a script tag
node
=
config
.
xhtml
?
document
.
createElementNS
(
'
http://www.w3.org/1999/xhtml
'
,
'
html:script
'
)
:
document
.
createElement
(
'
script
'
);
node
.
type
=
config
.
scriptType
||
'
text/javascript
'
;
node
.
charset
=
'
utf-8
'
;
node
.
async
=
true
;
node
=
req
.
createNode
(
config
,
moduleName
,
url
);
node
.
setAttribute
(
'
data-requirecontext
'
,
context
.
contextName
);
node
.
setAttribute
(
'
data-requiremodule
'
,
moduleName
);
...
...
@@ -1892,7 +1941,7 @@ var requirejs, require, define;
}
//Look for a data-main script attribute, which could also adjust the baseUrl.
if
(
isBrowser
)
{
if
(
isBrowser
&&
!
cfg
.
skipDataMain
)
{
//Figure out baseUrl. Get it from the script tag with require.js in it.
eachReverse
(
scripts
(),
function
(
script
)
{
//Set the 'head' where we can append children by
...
...
@@ -1906,24 +1955,31 @@ var requirejs, require, define;
//baseUrl, if it is not already set.
dataMain
=
script
.
getAttribute
(
'
data-main
'
);
if
(
dataMain
)
{
//Preserve dataMain in case it is a path (i.e. contains '?')
mainScript
=
dataMain
;
//Set final baseUrl if there is not already an explicit one.
if
(
!
cfg
.
baseUrl
)
{
//Pull off the directory of data-main for use as the
//baseUrl.
src
=
dataMain
.
split
(
'
/
'
);
src
=
mainScript
.
split
(
'
/
'
);
mainScript
=
src
.
pop
();
subPath
=
src
.
length
?
src
.
join
(
'
/
'
)
+
'
/
'
:
'
./
'
;
cfg
.
baseUrl
=
subPath
;
dataMain
=
mainScript
;
}
//Strip off any trailing .js since
dataMain
is now
//Strip off any trailing .js since
mainScript
is now
//like a module name.
dataMain
=
dataMain
.
replace
(
jsSuffixRegExp
,
''
);
mainScript
=
mainScript
.
replace
(
jsSuffixRegExp
,
''
);
//If mainScript is still a path, fall back to dataMain
if
(
req
.
jsExtRegExp
.
test
(
mainScript
))
{
mainScript
=
dataMain
;
}
//Put the data-main script in the files to load.
cfg
.
deps
=
cfg
.
deps
?
cfg
.
deps
.
concat
(
dataMain
)
:
[
dataMain
];
cfg
.
deps
=
cfg
.
deps
?
cfg
.
deps
.
concat
(
mainScript
)
:
[
mainScript
];
return
true
;
}
...
...
@@ -1951,12 +2007,13 @@ var requirejs, require, define;
//This module may not have dependencies
if
(
!
isArray
(
deps
))
{
callback
=
deps
;
deps
=
[]
;
deps
=
null
;
}
//If no name, and callback is a function, then figure out if it a
//CommonJS thing with dependencies.
if
(
!
deps
.
length
&&
isFunction
(
callback
))
{
if
(
!
deps
&&
isFunction
(
callback
))
{
deps
=
[];
//Remove comments from the callback string,
//look for require calls, and pull them into the dependencies,
//but only if there are function args.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment