mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Include Acorn / Esprima only into local PaperScript scope, and locally deactivate AMD.
Closes #255.
This commit is contained in:
parent
85d7237c0f
commit
098f3e84cc
2 changed files with 13 additions and 5 deletions
|
@ -15,7 +15,7 @@
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"straps": "~1.1.3",
|
"straps": "~1.1.3",
|
||||||
"acorn": "~0.3.1",
|
"acorn": "git://github.com/paperjs/acorn#0.3.2",
|
||||||
"esprima": "~1.0.3",
|
"esprima": "~1.0.3",
|
||||||
"stats.js": "r11"
|
"stats.js": "r11"
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,16 @@
|
||||||
paper.PaperScope.prototype.PaperScript = new function() {
|
paper.PaperScope.prototype.PaperScript = new function() {
|
||||||
var Base = paper.Base,
|
var Base = paper.Base,
|
||||||
PaperScope = paper.PaperScope,
|
PaperScope = paper.PaperScope,
|
||||||
// Locally turn of exporst for inlined acorn / esprima.
|
// Locally turn of exports and define for inlined acorn / esprima.
|
||||||
exports = undefined;
|
// Just declaring the local vars is enough, as they will be undefined.
|
||||||
|
exports, define,
|
||||||
|
// The scope into which the library is loaded.
|
||||||
|
scope = this;
|
||||||
|
/*#*/ if (options.version == 'dev') {
|
||||||
|
// As the above inclusion loads code into the global scope during dev,
|
||||||
|
// set scope to window, so we can find the library.
|
||||||
|
scope = window;
|
||||||
|
/*#*/ }
|
||||||
/*#*/ if (options.parser == 'acorn') {
|
/*#*/ if (options.parser == 'acorn') {
|
||||||
/*#*/ include('../../components/acorn/acorn.min.js', { exports: false });
|
/*#*/ include('../../components/acorn/acorn.min.js', { exports: false });
|
||||||
/*#*/ } else if (options.parser == 'esprima') {
|
/*#*/ } else if (options.parser == 'esprima') {
|
||||||
|
@ -210,9 +218,9 @@ paper.PaperScope.prototype.PaperScript = new function() {
|
||||||
}
|
}
|
||||||
// Now do the parsing magic
|
// Now do the parsing magic
|
||||||
/*#*/ if (options.parser == 'acorn') {
|
/*#*/ if (options.parser == 'acorn') {
|
||||||
walkAst(acorn.parse(code, { ranges: true }));
|
walkAst(scope.acorn.parse(code, { ranges: true }));
|
||||||
/*#*/ } else if (options.parser == 'esprima') {
|
/*#*/ } else if (options.parser == 'esprima') {
|
||||||
walkAst(esprima.parse(code, { range: true }));
|
walkAst(scope.esprima.parse(code, { range: true }));
|
||||||
/*#*/ }
|
/*#*/ }
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue