Comparing version 0.0.39 to 0.0.40
@@ -45,2 +45,8 @@ (function(global) { | ||
var symbolValues = $create(null); | ||
var privateNames = $create(null); | ||
function createPrivateName() { | ||
var s = newUniqueString(); | ||
privateNames[s] = true; | ||
return s; | ||
} | ||
function isSymbol(symbol) { | ||
@@ -97,3 +103,3 @@ return typeof symbol === 'object' && symbol instanceof SymbolValue; | ||
}); | ||
var hashProperty = newUniqueString(); | ||
var hashProperty = createPrivateName(); | ||
var hashPropertyDescriptor = {value: undefined}; | ||
@@ -142,3 +148,3 @@ var hashObjectProperties = { | ||
var name = names[i]; | ||
if (!symbolValues[name] && name !== hashProperty) | ||
if (!symbolValues[name] && !privateNames[name]) | ||
rv.push(name); | ||
@@ -212,3 +218,3 @@ } | ||
var name = props[p]; | ||
if (name === hashProperty) | ||
if (privateNames[name]) | ||
continue; | ||
@@ -228,3 +234,3 @@ target[name] = source[name]; | ||
var name = props[p]; | ||
if (name === hashProperty) | ||
if (privateNames[name]) | ||
continue; | ||
@@ -243,3 +249,3 @@ descriptor = $getOwnPropertyDescriptor(source, props[p]); | ||
var name = names[j]; | ||
if (name === hashProperty) | ||
if (privateNames[name]) | ||
continue; | ||
@@ -362,7 +368,2 @@ (function(mod, name) { | ||
var RETHROW_STATE = -3; | ||
function addIterator(object) { | ||
return defineProperty(object, Symbol.iterator, nonEnum(function() { | ||
return this; | ||
})); | ||
} | ||
function getInternalError(state) { | ||
@@ -436,40 +437,66 @@ return new Error('Traceur compiler bug: invalid state in state machine: ' + state); | ||
}; | ||
function getNextOrThrow(ctx, moveNext, action) { | ||
return function(x) { | ||
switch (ctx.GState) { | ||
case ST_EXECUTING: | ||
throw new Error(("\"" + action + "\" on executing generator")); | ||
case ST_CLOSED: | ||
throw new Error(("\"" + action + "\" on closed generator")); | ||
case ST_NEWBORN: | ||
if (action === 'throw') { | ||
ctx.GState = ST_CLOSED; | ||
throw x; | ||
} | ||
if (x !== undefined) | ||
throw $TypeError('Sent value to newborn generator'); | ||
case ST_SUSPENDED: | ||
ctx.GState = ST_EXECUTING; | ||
ctx.action = action; | ||
ctx.sent = x; | ||
var value = moveNext(ctx); | ||
var done = value === ctx; | ||
if (done) | ||
value = ctx.returnValue; | ||
ctx.GState = done ? ST_CLOSED : ST_SUSPENDED; | ||
return { | ||
value: value, | ||
done: done | ||
}; | ||
} | ||
}; | ||
function nextOrThrow(ctx, moveNext, action, x) { | ||
switch (ctx.GState) { | ||
case ST_EXECUTING: | ||
throw new Error(("\"" + action + "\" on executing generator")); | ||
case ST_CLOSED: | ||
throw new Error(("\"" + action + "\" on closed generator")); | ||
case ST_NEWBORN: | ||
if (action === 'throw') { | ||
ctx.GState = ST_CLOSED; | ||
throw x; | ||
} | ||
if (x !== undefined) | ||
throw $TypeError('Sent value to newborn generator'); | ||
case ST_SUSPENDED: | ||
ctx.GState = ST_EXECUTING; | ||
ctx.action = action; | ||
ctx.sent = x; | ||
var value = moveNext(ctx); | ||
var done = value === ctx; | ||
if (done) | ||
value = ctx.returnValue; | ||
ctx.GState = done ? ST_CLOSED : ST_SUSPENDED; | ||
return { | ||
value: value, | ||
done: done | ||
}; | ||
} | ||
} | ||
function generatorWrap(innerFunction, self) { | ||
var ctxName = createPrivateName(); | ||
var moveNextName = createPrivateName(); | ||
function GeneratorFunction() {} | ||
function GeneratorFunctionPrototype() {} | ||
GeneratorFunction.prototype = GeneratorFunctionPrototype; | ||
$defineProperty(GeneratorFunctionPrototype, 'constructor', nonEnum(GeneratorFunction)); | ||
GeneratorFunctionPrototype.prototype = { | ||
constructor: GeneratorFunctionPrototype, | ||
next: function(v) { | ||
return nextOrThrow(this[ctxName], this[moveNextName], 'next', v); | ||
}, | ||
throw: function(v) { | ||
return nextOrThrow(this[ctxName], this[moveNextName], 'throw', v); | ||
} | ||
}; | ||
$defineProperties(GeneratorFunctionPrototype.prototype, { | ||
constructor: {enumerable: false}, | ||
next: {enumerable: false}, | ||
throw: {enumerable: false} | ||
}); | ||
defineProperty(GeneratorFunctionPrototype.prototype, Symbol.iterator, nonEnum(function() { | ||
return this; | ||
})); | ||
function createGeneratorInstance(innerFunction, functionObject, self) { | ||
var moveNext = getMoveNext(innerFunction, self); | ||
var ctx = new GeneratorContext(); | ||
return addIterator({ | ||
next: getNextOrThrow(ctx, moveNext, 'next'), | ||
throw: getNextOrThrow(ctx, moveNext, 'throw') | ||
}); | ||
var object = $create(functionObject.prototype); | ||
object[ctxName] = ctx; | ||
object[moveNextName] = moveNext; | ||
return object; | ||
} | ||
function initGeneratorFunction(functionObject) { | ||
functionObject.prototype = $create(GeneratorFunctionPrototype.prototype); | ||
functionObject.__proto__ = GeneratorFunctionPrototype; | ||
return functionObject; | ||
} | ||
function AsyncFunctionContext() { | ||
@@ -550,3 +577,5 @@ GeneratorContext.call(this); | ||
exportStar: exportStar, | ||
generatorWrap: generatorWrap, | ||
initGeneratorFunction: initGeneratorFunction, | ||
createGeneratorInstance: createGeneratorInstance, | ||
getOwnHashObject: getOwnHashObject, | ||
setProperty: setProperty, | ||
@@ -561,4 +590,3 @@ setupGlobals: setupGlobals, | ||
type: types, | ||
typeof: typeOf, | ||
getOwnHashObject: getOwnHashObject | ||
typeof: typeOf | ||
}; | ||
@@ -792,3 +820,3 @@ })(typeof global !== 'undefined' ? global : this); | ||
register: function(name, deps, func) { | ||
if (!deps || !deps.length) { | ||
if (!deps || !deps.length && !func.length) { | ||
this.registerModule(name, func); | ||
@@ -798,3 +826,12 @@ } else { | ||
deps: deps, | ||
execute: func | ||
execute: function() { | ||
var $__0 = arguments; | ||
var depMap = {}; | ||
deps.forEach((function(dep, index) { | ||
return depMap[dep] = $__0[index]; | ||
})); | ||
var registryEntry = func.call(this, depMap); | ||
registryEntry.execute.call(this); | ||
return registryEntry.exports; | ||
} | ||
}; | ||
@@ -837,5 +874,5 @@ } | ||
})(typeof global !== 'undefined' ? global : this); | ||
System.register("traceur-runtime@0.0.39/src/runtime/polyfills/utils", [], function() { | ||
System.register("traceur-runtime@0.0.40/src/runtime/polyfills/utils", [], function() { | ||
"use strict"; | ||
var __moduleName = "traceur-runtime@0.0.39/src/runtime/polyfills/utils"; | ||
var __moduleName = "traceur-runtime@0.0.40/src/runtime/polyfills/utils"; | ||
var toObject = $traceurRuntime.toObject; | ||
@@ -860,7 +897,7 @@ function toUint32(x) { | ||
}); | ||
System.register("traceur-runtime@0.0.39/src/runtime/polyfills/ArrayIterator", [], function() { | ||
System.register("traceur-runtime@0.0.40/src/runtime/polyfills/ArrayIterator", [], function() { | ||
"use strict"; | ||
var $__4; | ||
var __moduleName = "traceur-runtime@0.0.39/src/runtime/polyfills/ArrayIterator"; | ||
var $__5 = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.39/src/runtime/polyfills/utils")), | ||
var __moduleName = "traceur-runtime@0.0.40/src/runtime/polyfills/ArrayIterator"; | ||
var $__5 = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.40/src/runtime/polyfills/utils")), | ||
toObject = $__5.toObject, | ||
@@ -939,6 +976,6 @@ toUint32 = $__5.toUint32; | ||
}); | ||
System.register("traceur-runtime@0.0.39/src/runtime/polyfills/Map", [], function() { | ||
System.register("traceur-runtime@0.0.40/src/runtime/polyfills/Map", [], function() { | ||
"use strict"; | ||
var __moduleName = "traceur-runtime@0.0.39/src/runtime/polyfills/Map"; | ||
var isObject = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.39/src/runtime/polyfills/utils")).isObject; | ||
var __moduleName = "traceur-runtime@0.0.40/src/runtime/polyfills/Map"; | ||
var isObject = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.40/src/runtime/polyfills/utils")).isObject; | ||
var getOwnHashObject = $traceurRuntime.getOwnHashObject; | ||
@@ -1063,5 +1100,5 @@ var $hasOwnProperty = Object.prototype.hasOwnProperty; | ||
}); | ||
System.register("traceur-runtime@0.0.39/node_modules/rsvp/lib/rsvp/asap", [], function() { | ||
System.register("traceur-runtime@0.0.40/node_modules/rsvp/lib/rsvp/asap", [], function() { | ||
"use strict"; | ||
var __moduleName = "traceur-runtime@0.0.39/node_modules/rsvp/lib/rsvp/asap"; | ||
var __moduleName = "traceur-runtime@0.0.40/node_modules/rsvp/lib/rsvp/asap"; | ||
var $__default = function asap(callback, arg) { | ||
@@ -1116,6 +1153,6 @@ var length = queue.push([callback, arg]); | ||
}); | ||
System.register("traceur-runtime@0.0.39/src/runtime/polyfills/Promise", [], function() { | ||
System.register("traceur-runtime@0.0.40/src/runtime/polyfills/Promise", [], function() { | ||
"use strict"; | ||
var __moduleName = "traceur-runtime@0.0.39/src/runtime/polyfills/Promise"; | ||
var async = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.39/node_modules/rsvp/lib/rsvp/asap")).default; | ||
var __moduleName = "traceur-runtime@0.0.40/src/runtime/polyfills/Promise"; | ||
var async = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.40/node_modules/rsvp/lib/rsvp/asap")).default; | ||
var promiseRaw = {}; | ||
@@ -1354,5 +1391,5 @@ function isPromise(x) { | ||
}); | ||
System.register("traceur-runtime@0.0.39/src/runtime/polyfills/String", [], function() { | ||
System.register("traceur-runtime@0.0.40/src/runtime/polyfills/String", [], function() { | ||
"use strict"; | ||
var __moduleName = "traceur-runtime@0.0.39/src/runtime/polyfills/String"; | ||
var __moduleName = "traceur-runtime@0.0.40/src/runtime/polyfills/String"; | ||
var $toString = Object.prototype.toString; | ||
@@ -1526,8 +1563,8 @@ var $indexOf = String.prototype.indexOf; | ||
}); | ||
System.register("traceur-runtime@0.0.39/src/runtime/polyfills/polyfills", [], function() { | ||
System.register("traceur-runtime@0.0.40/src/runtime/polyfills/polyfills", [], function() { | ||
"use strict"; | ||
var __moduleName = "traceur-runtime@0.0.39/src/runtime/polyfills/polyfills"; | ||
var Map = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.39/src/runtime/polyfills/Map")).Map; | ||
var Promise = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.39/src/runtime/polyfills/Promise")).Promise; | ||
var $__12 = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.39/src/runtime/polyfills/String")), | ||
var __moduleName = "traceur-runtime@0.0.40/src/runtime/polyfills/polyfills"; | ||
var Map = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.40/src/runtime/polyfills/Map")).Map; | ||
var Promise = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.40/src/runtime/polyfills/Promise")).Promise; | ||
var $__12 = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.40/src/runtime/polyfills/String")), | ||
codePointAt = $__12.codePointAt, | ||
@@ -1540,3 +1577,3 @@ contains = $__12.contains, | ||
startsWith = $__12.startsWith; | ||
var $__12 = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.39/src/runtime/polyfills/ArrayIterator")), | ||
var $__12 = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.40/src/runtime/polyfills/ArrayIterator")), | ||
entries = $__12.entries, | ||
@@ -1599,8 +1636,8 @@ keys = $__12.keys, | ||
}); | ||
System.register("traceur-runtime@0.0.39/src/runtime/polyfill-import", [], function() { | ||
System.register("traceur-runtime@0.0.40/src/runtime/polyfill-import", [], function() { | ||
"use strict"; | ||
var __moduleName = "traceur-runtime@0.0.39/src/runtime/polyfill-import"; | ||
var $__14 = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.39/src/runtime/polyfills/polyfills")); | ||
var __moduleName = "traceur-runtime@0.0.40/src/runtime/polyfill-import"; | ||
var $__14 = $traceurRuntime.assertObject(System.get("traceur-runtime@0.0.40/src/runtime/polyfills/polyfills")); | ||
return {}; | ||
}); | ||
System.get("traceur-runtime@0.0.39/src/runtime/polyfill-import" + ''); | ||
System.get("traceur-runtime@0.0.40/src/runtime/polyfill-import" + ''); |
{ | ||
"name": "traceur", | ||
"version": "0.0.39", | ||
"version": "0.0.40", | ||
"description": "ES6 to ES5 compiler", | ||
@@ -48,3 +48,3 @@ "keywords": [ | ||
"semver": "2.2.1", | ||
"traceur": "0.0.38", | ||
"traceur": "0.0.39", | ||
"promises-aplus-tests": "~2.0.4" | ||
@@ -51,0 +51,0 @@ }, |
@@ -66,5 +66,8 @@ // Copyright 2013 Traceur Authors. | ||
sourceMap: false, | ||
cwd: process.cwd() | ||
cwd: process.cwd(), | ||
moduleName: false | ||
}, options || {}); | ||
var moduleName = options.moduleName; | ||
traceurOptions.reset(); | ||
@@ -77,6 +80,9 @@ merge(traceurOptions, options); | ||
var tree = parser.parseModule(); | ||
var moduleName = options.filename.replace(/\.js$/, ''); | ||
moduleName = path.relative(options.cwd, moduleName).replace(/\\/g,'/'); | ||
var transformer = new AttachModuleNameTransformer(moduleName); | ||
tree = transformer.transformAny(tree); | ||
var transformer; | ||
if (moduleName === true || options.modules == 'register' || options.modules == 'inline') { | ||
moduleName = options.filename.replace(/\.js$/, ''); | ||
moduleName = path.relative(options.cwd, moduleName).replace(/\\/g,'/'); | ||
transformer = new AttachModuleNameTransformer(moduleName); | ||
tree = transformer.transformAny(tree); | ||
} | ||
@@ -83,0 +89,0 @@ if (options.outputLanguage.toLowerCase() === 'es6') { |
@@ -208,3 +208,3 @@ // Copyright 2013 Traceur Authors. | ||
var compileAllJsFilesInDir = require('./compile-single-file.js').compileAllJsFilesInDir; | ||
compileAllJsFilesInDir(dir, includes[0]); | ||
compileAllJsFilesInDir(dir, includes[0], true); | ||
} | ||
@@ -211,0 +211,0 @@ else { |
@@ -29,3 +29,3 @@ // Copyright 2013 Traceur Authors. | ||
function compileSingleFile(inputFilePath, outputFilePath) { | ||
function compileSingleFile(inputFilePath, outputFilePath, anonymousModules) { | ||
return fs.read(inputFilePath).then(function(contents) { | ||
@@ -36,8 +36,11 @@ var reporter = new ErrorReporter(); | ||
var tree = parser.parseModule(); | ||
var moduleName = inputFilePath.replace(/\.js$/, '').replace(/\\/g,'/'); | ||
// Module naming uses ./ to signal relative names. | ||
if (moduleName[0] !== '/') | ||
moduleName = './' + moduleName; | ||
var transformer = new AttachModuleNameTransformer(moduleName); | ||
tree = transformer.transformAny(tree); | ||
var moduleName, transformer; | ||
if (!anonymousModules) { | ||
moduleName = inputFilePath.replace(/\.js$/, '').replace(/\\/g,'/'); | ||
// Module naming uses ./ to signal relative names. | ||
if (moduleName[0] !== '/') | ||
moduleName = './' + moduleName; | ||
transformer = new AttachModuleNameTransformer(moduleName); | ||
tree = transformer.transformAny(tree); | ||
} | ||
transformer = new FromOptionsTransformer(reporter); | ||
@@ -56,3 +59,3 @@ var transformed = transformer.transform(tree); | ||
function compileAllJsFilesInDir(inputDir, outputDir) { | ||
function compileAllJsFilesInDir(inputDir, outputDir, anonymousModules) { | ||
inputDir = path.normalize(inputDir); | ||
@@ -63,3 +66,3 @@ outputDir = path.normalize(outputDir); | ||
var outputFilePath = inputFilePath.replace(inputDir, outputDir); | ||
compileSingleFile(inputFilePath, outputFilePath).done(); | ||
compileSingleFile(inputFilePath, outputFilePath, anonymousModules).done(); | ||
}); | ||
@@ -66,0 +69,0 @@ }).done(); |
@@ -33,2 +33,2 @@ // Copyright 2013 Traceur Authors. | ||
compileAllJsFilesInDir(inputDir, outputDir); | ||
compileAllJsFilesInDir(inputDir, outputDir, true); |
@@ -33,2 +33,2 @@ // Copyright 2013 Traceur Authors. | ||
compileAllJsFilesInDir(inputDir, outputDir); | ||
compileAllJsFilesInDir(inputDir, outputDir, true); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1004506
25339