var compile = function (filename) { var result; var opts = extend({}, transformOpts); // this will be done when the file is transformed anyway but we need all // the options so we can generate the cache key resolveRc(filename, opts); var cacheKey = `${filename}:${JSON.stringify(opts)}:${babel.version}`; if (cache) { var cached = cache[cacheKey]; if (cached && cached.mtime === mtime(filename)) { result = cached; } } if (!result) { result = babel.transformFileSync(filename, extend(opts, { sourceMap: "both", ast: false })); } if (cache) { result.mtime = mtime(filename); cache[cacheKey] = result; } maps[filename] = result.map; return result.code; };
value: function init(config) { if (cli.env.configPath) { this._config = extend(this.config, config); logger.ok('Finished checking config file at [%s]', cli.env.configPath.cyan); } else { this._config = (0, _defaults.defaults)(); this._config = extend(this._config, config); this.write(this._config); } }
module.exports = function(target, name){ return { filter : extend(defaults, filters[target]) , glob : globs[target] , names : { kebab:kebabCase(name), class:capitalize(camelCase(name)) } } }
enter: function (node, parent, scope, formatter) { if (t.isImportDeclaration(node)) { formatter.hasLocalImports = true; extend(formatter.localImports, t.getBindingIdentifiers(node)); formatter.bumpImportOccurences(node); } }
function buildScript(file, watch) { var props = extend({}, watchify.args, { entries: [srcDir + 'js/' + file], debug: true, extensions: ['.js', '.jsx'] }); var bblfy = babelify.configure({ only: /(src\/js)/, optional: ['runtime'] }); var brwsfy = browserify(props).transform(bblfy); var bundler = watch ? watchify(brwsfy, { ignoreWatch: true }) : brwsfy; function rebundle() { return bundler.bundle() .on('error', handleError) .pipe(source(jsTargetName)) .pipe(buffer()) .pipe($.sourcemaps.init({ loadMaps: true })) .pipe($.sourcemaps.write(mapsDir)) .pipe(gulp.dest(buildDir)); } bundler.on('update', rebundle); bundler.on('log', $.util.log); bundler.on('error', $.util.log); return rebundle(); }
BlockScoping.prototype.getLetReferences = function () { var block = this.block; var declarators = block._letDeclarators || []; var declar; // for (var i = 0; i < declarators.length; i++) { declar = declarators[i]; extend(this.outsideLetReferences, t.getBindingIdentifiers(declar)); } // if (block.body) { for (i = 0; i < block.body.length; i++) { declar = block.body[i]; if (isLet(declar, block)) { declarators = declarators.concat(declar.declarations); } } } // for (i = 0; i < declarators.length; i++) { declar = declarators[i]; var keys = t.getBindingIdentifiers(declar); extend(this.letReferences, keys); this.hasLetReferences = true; } // no let references so we can just quit if (!this.hasLetReferences) return; // set let references to plain var references standardizeLets(declarators); var state = { letReferences: this.letReferences, closurify: false }; // traverse through this block, stopping on functions and checking if they // contain any local let references this.scope.traverse(this.block, letReferenceBlockVisitor, state); return state.closurify; };
getLetReferences() { let block = this.block; let declarators = []; if (this.loop) { let init = this.loop.left || this.loop.init; if (isBlockScoped(init)) { declarators.push(init); extend(this.outsideLetReferences, t.getBindingIdentifiers(init)); } } // if (block.body) { for (let i = 0; i < block.body.length; i++) { let declar = block.body[i]; if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar) || isBlockScoped(declar)) { if (isBlockScoped(declar)) convertBlockScopedToVar(declar, block, this.scope); declarators = declarators.concat(declar.declarations || declar); } } } // for (let i = 0; i < declarators.length; i++) { let declar = declarators[i]; let keys = t.getBindingIdentifiers(declar); extend(this.letReferences, keys); this.hasLetReferences = true; } // no let references so we can just quit if (!this.hasLetReferences) return; let state = { letReferences: this.letReferences, closurify: false, file: this.file }; // traverse through this block, stopping on functions and checking if they // contain any local let references this.blockPath.traverse(letReferenceBlockVisitor, state); return state.closurify; }
function Assets(options) { if (!(this instanceof Assets)) { return new Assets(options); } this.options = extend({}, options); Object.freeze(this); }
//--------------------------------------------------------------------------- /** * Add shade on your maps * * @constructor * * @mixes Composition */ function ShadeLayer(options) { _extend(this, new Layer(options)); this.type = Layer.Shade; this.params = this.default(); this.setAlphaBlend(); }
function RasterLayer(options) { _extend(this, new Layer(options)); this.type = Layer.Raster; this.sourceId = options.sourceId; this.setAlphaBlend(); }
Collection.prototype.configure = function (name, value) { if (!_.isUndefined(name)) { if (_.isPlainObject(name)) { this.config = extend(this.config, name); } else { this.config[name] = value; } } return this; };
surface.transaction(function(tx, args) { args.containerId = surface.getContainerId(); args.node = extend({ type: this.getAnnotationType() }, this.getAnnotationData()); args = insertInlineNode(tx, args); newAnno = args.result; return args; }.bind(this));
module.exports = function(inheritingConstructor, constructedObject) { var ProtoObject = function() {}; ProtoObject.prototype = constructedObject; var protoObject = new ProtoObject(); extend(protoObject, inheritingConstructor.prototype); inheritingConstructor.prototype = protoObject; inheritingConstructor.prototype.super_ = constructedObject; return inheritingConstructor; };
gulp.task('dist', ['dist-preprocess'], function() { var env = merge({ __DEV_MODE__: false, NODE_ENV: "\"production\"" }, options.env); var plugins = [ new webpack.DefinePlugin(env), new webpack.optimize.OccurenceOrderPlugin(), new webpack.optimize.DedupePlugin() ]; var argv = require('yargs').argv; if (!argv.skipMinify) { plugins.push(new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })); } var config = extend({ plugins: plugins }, webpackConfig, options.webpack || {}); if (!config.resolve) { config.resolve = {}; } if (!config.resolveLoader) { config.resolveLoader = {}; } if (options.webpack.module && options.webpack.module.loaders) { webpackConfig.module.loaders.forEach(function(loader) { config.module.loaders.push(loader); }); } config.resolve.extensions = merge(config.resolve.extensions || [], ['', '.js', '.json', '.htm', '.html', '.scss', '.md', '.svg']); config.resolve.modulesDirectories = merge(config.resolve.modulesDirectories || [], ['node_modules/grommet/node_modules', 'node_modules']); config.resolveLoader.modulesDirectories = merge(config.resolveLoader.modulesDirectories || [], ['node_modules/grommet/node_modules', 'node_modules']); return gulp.src(options.mainJs) .pipe(gulpWebpack(config)) .pipe(gulp.dest(dist)); });
function compile(filename) { let result; // merge in base options and resolve all the plugins and presets relative to this file let opts = new OptionManager().init(extend(deepClone(transformOpts), { filename })); let cacheKey = `${JSON.stringify(opts)}:${babel.version}`; let env = process.env.BABEL_ENV || process.env.NODE_ENV; if (env) cacheKey += `:${env}`; if (cache) { let cached = cache[cacheKey]; if (cached && cached.mtime === mtime(filename)) { result = cached; } } if (!result) { result = babel.transformFileSync(filename, extend(opts, { // Do not process config files since has already been done with the OptionManager // calls above and would introduce duplicates. babelrc: false, sourceMap: "both", ast: false })); } if (cache) { cache[cacheKey] = result; result.mtime = mtime(filename); } maps[filename] = result.map; return result.code; }
export default function (opts = {}) { if (opts.only != null) only = util.arrayify(opts.only, util.regexify); if (opts.ignore != null) ignore = util.arrayify(opts.ignore, util.regexify); if (opts.extensions) hookExtensions(util.arrayify(opts.extensions)); if (opts.cache === false) cache = null; delete opts.extensions; delete opts.ignore; delete opts.cache; delete opts.only; extend(transformOpts, opts); }
module.exports = function (to, options, callback) { if (typeof options === 'function') { callback = options; options = {}; } options = extend({ basePath: '.', baseUrl: '/', cachebuster: false, relativeTo: false }, options); if (options.cachebuster === true) { options.cachebuster = defaultCachebuster; } var toUrl = url.parse(to); return resolvePath(decodeURI(toUrl.pathname), options) .then(function (resolvedPath) { if (options.relativeTo) { toUrl.pathname = composeRelativePathname(options.basePath, options.relativeTo, resolvedPath); } else { toUrl.pathname = composeAbsolutePathname(options.baseUrl, options.basePath, resolvedPath); } if (options.cachebuster) { var cachebusterOutput = options.cachebuster(resolvedPath, toUrl.pathname); if (cachebusterOutput) { if (typeof cachebusterOutput !== 'object') { toUrl.search = composeQueryString(toUrl.search, String(cachebusterOutput)); } else { if (cachebusterOutput.pathname) { toUrl.pathname = cachebusterOutput.pathname; } if (cachebusterOutput.query) { toUrl.search = composeQueryString(toUrl.search, cachebusterOutput.query); } } } } return url.format(toUrl); }) .nodeify(callback); };
enter: function (node, parent, scope, formatter) { var declar = node && node.declaration; if (t.isExportDeclaration(node)) { formatter.hasLocalImports = true; if (declar && t.isStatement(declar)) { extend(formatter.localExports, t.getBindingIdentifiers(declar)); } if (!node.default) { formatter.hasNonDefaultExports = true; } if (node.source) { formatter.bumpImportOccurences(node); } } }
var Collection = function (options, data) { if (!(this instanceof Collection)) { return new Collection(options, data); } this.config = extend({ compare: naturalCompare, compareKey: objectKey, idAttribute: 'id', requestAttributes: {} }, options); // Convert data to models if (isArray(data)) { data.forEach(function (item) { this.add(item); }, this); this.order(); } };
var compile = function (filename, opts = {}) { var result; opts.filename = filename; var optsManager = new OptionManager; optsManager.mergeOptions(transformOpts); opts = optsManager.init(opts); var cacheKey = `${JSON.stringify(opts)}:${babel.version}`; var env = process.env.BABEL_ENV || process.env.NODE_ENV; if (env) cacheKey += `:${env}`; if (cache) { var cached = cache[cacheKey]; if (cached && cached.mtime === mtime(filename)) { result = cached; } } if (!result) { result = babel.transformFileSync(filename, extend(opts, { sourceMap: "both", ast: false })); } if (cache) { result.mtime = mtime(filename); cache[cacheKey] = result; } maps[filename] = result.map; return result.code; };
StencilEquationComponent.Prototype = function() { extend(this, StencilSourceComponent.prototype); this._renderMathJax = function() { var node = this.props.node; var tagName = this.props.node.constructor.static.isInline ? 'span' : 'div'; var typeAttr = node.format; if (!node.constructor.static.isInline) { typeAttr += "; mode=display"; } return $$(tagName) .addClass('se-math-output') .ref('output') // appending the script here as MJ then renders a preview .append( $$('script') .attr('type', typeAttr) .append(node.source) .ref('source') ) .append($$(tagName) .addClass('se-error') .ref('error') ); }; this.render = function() { var node = this.props.node; var el = $$('div') .addClass("stencil-equation " + node.type) .attr("data-id", node.id) .attr('contentEditable', false) .on('click', this.onEditSource) .on('mousedown', this.onMouseDown); el.append(this._renderMathJax()); if (this.revealSource()) { el.append( $$(TextProperty, { tagName: 'div', path: [node.id, "source"] }) .addClass('source') ) .ref('source'); } return el; }; this.didMount = function() { StencilNodeComponent.prototype.didMount.call(this); MathJax.Hub.Queue(["Process", MathJax.Hub,this.refs.source.el]); this.props.node.connect(this, { 'source:changed': this.rerenderMath }); }; this.rerenderMath = function() { var node = this.props.node; var scriptComp = this.refs.source; scriptComp.$el.text(node.source); MathJax.Hub.Queue(["Reprocess", MathJax.Hub, scriptComp.el]); }; this.onParseError = function(message) { console.error("MathJax error", message); this.refs.error.$el.text(message[1]); }; };
crawl() { var path = this.path; // var info = this.block._scopeInfo; if (info) return extend(this, info); info = this.block._scopeInfo = { bindings: object(), globals: object() }; extend(this, info); // ForStatement - left, init if (path.isLoop()) { for (let i = 0; i < t.FOR_INIT_KEYS.length; i++) { var node = path.get(t.FOR_INIT_KEYS[i]); if (node.isBlockScoped()) this.registerBinding(node.node.kind, node); } } // FunctionExpression - id if (path.isFunctionExpression() && path.has("id")) { if (!t.isProperty(path.parent, { method: true })) { this.registerBinding("var", path.get("id")); } } // Class if (path.isClass() && path.has("id")) { this.registerBinding("var", path.get("id")); } // Function - params, rest if (path.isFunction()) { var params = path.get("params"); for (let i = 0; i < params.length; i++) { this.registerBinding("param", params[i]); } this.traverse(path.get("body").node, blockVariableVisitor, this); } // Program, Function - var variables if (path.isProgram() || path.isFunction()) { this.traverse(path.node, functionVariableVisitor, { blockId: path.get("id").node, scope: this }); } // Program, BlockStatement, Function - let variables if (path.isBlockStatement() || path.isProgram()) { this.traverse(path.node, blockVariableVisitor, this); } // CatchClause - param if (path.isCatchClause()) { this.registerBinding("let", path.get("param")); } // ComprehensionExpression - blocks if (path.isComprehensionExpression()) { this.registerBinding("let", path); } // Program if (path.isProgram()) { this.traverse(path.node, programReferenceVisitor, this); } }
crawl() { var path = this.path; // var info = this.block._scopeInfo; if (info) return extend(this, info); info = this.block._scopeInfo = { references: object(), bindings: object(), globals: object(), uids: object(), }; extend(this, info); // ForStatement - left, init if (path.isLoop()) { for (let key of (t.FOR_INIT_KEYS: Array)) { var node = path.get(key); if (node.isBlockScoped()) this.registerBinding(node.node.kind, node); } } // FunctionExpression - id if (path.isFunctionExpression() && path.has("id")) { if (!t.isProperty(path.parent, { method: true })) { this.registerBinding("var", path.get("id")); } } // Class if (path.isClassDeclaration()) { var name = path.node.id.name; this.bindings[name] = this.parent.bindings[name]; } if (path.isClassExpression() && path.has("id")) { this.registerBinding("var", path); } // Function - params, rest if (path.isFunction()) { var params = path.get("params"); for (let param of (params: Array)) { this.registerBinding("param", param); } path.get("body").traverse(blockVariableVisitor, this); } // Program, Function - var variables if (path.isProgram() || path.isFunction()) { this.traverse(path.node, functionVariableVisitor, { blockId: path.get("id").node, scope: this }); } // Program, BlockStatement, Function - let variables if (path.isBlockStatement() || path.isProgram()) { this.traverse(path.node, blockVariableVisitor, this); } // CatchClause - param if (path.isCatchClause()) { this.registerBinding("let", path.get("param")); } // ComprehensionExpression - blocks if (path.isComprehensionExpression()) { this.registerBinding("let", path); } // Program if (path.isProgram()) { this.traverse(path.node, programReferenceVisitor, this); } }
if (this.isExportDeclaration() && this.has("specifiers")) { var specifiers = this.get("specifiers"); for (var specifier of (specifiers: Array)) { if (specifier.isExportSpecifier() && matchesLocal(specifier.node, "exported")) { specifier.get("exported").replaceWith(t.identifier(state.oldName)); } } } else if (this.isImportDeclaration() && this.has("specifiers")) { var specifiers = this.get("specifiers"); for (var specifier of (specifiers: Array)) { if (specifier.isImportSpecifier() && matchesLocal(specifier.node, "imported")) { state.binding = state.info.identifier = t.identifier(state.newName); specifier.get("local").replaceWith(state.binding); } else { extend(ids, specifier.getBindingIdentifiers()); } } } else { ids = this.getBindingIdentifiers(); } for (var name in ids) { if (name === state.oldName) ids[name].name = state.newName; } }, Scopable(node, parent, scope, state) { if (this.isScope()) { if (!scope.bindingIdentifierEquals(state.oldName, state.binding)) { this.skip();
set: function (value) { this._config = extend(this._config, value); cli.aurelia.configuration = this._config; }
MapView.prototype.prepareChildOptions = function(options, settings) { _extend(options, settings); options.container = document.createElement('div'); this.container.appendChild(options.container); };
MapView.prototype.addImageLayer = function(sourceId, options) { return this.layerManager.addLayer(Layer.Images, _extend({ sourceId: sourceId }, options)); };
Scope.prototype.crawl = function crawl() { var block = this.block; var i; // var info = block._scopeInfo; if (info) { extend(this, info); return; } info = block._scopeInfo = { bindings: object(), globals: object() }; extend(this, info); // ForStatement - left, init if (t.isLoop(block)) { for (i = 0; i < t.FOR_INIT_KEYS.length; i++) { var node = block[t.FOR_INIT_KEYS[i]]; if (t.isBlockScoped(node)) this.registerBinding("let", node); } if (t.isBlockStatement(block.body)) { block = block.body; } } // FunctionExpression - id if (t.isFunctionExpression(block) && block.id) { if (!t.isProperty(this.parentBlock, { method: true })) { this.registerBinding("var", block.id); } } // Function - params, rest if (t.isFunction(block)) { for (i = 0; i < block.params.length; i++) { this.registerBinding("param", block.params[i]); } this.traverse(block.body, blockVariableVisitor, this); } // Program, BlockStatement, Function - let variables if (t.isBlockStatement(block) || t.isProgram(block)) { this.traverse(block, blockVariableVisitor, this); } // CatchClause - param if (t.isCatchClause(block)) { this.registerBinding("let", block.param); } // ComprehensionExpression - blocks if (t.isComprehensionExpression(block)) { this.registerBinding("let", block); } // Program, Function - var variables if (t.isProgram(block) || t.isFunction(block)) { this.traverse(block, functionVariableVisitor, { blockId: block.id, scope: this }); } // Program if (t.isProgram(block)) { this.traverse(block, programReferenceVisitor, this); } };
crawl() { var path = this.path; // var info = this.block._scopeInfo; if (info) return extend(this, info); info = this.block._scopeInfo = { references: object(), bindings: object(), globals: object(), uids: object(), }; extend(this, info); // ForStatement - left, init if (path.isLoop()) { for (let key of (t.FOR_INIT_KEYS: Array)) { var node = path.get(key); if (node.isBlockScoped()) this.registerBinding(node.node.kind, node); } } // FunctionExpression - id if (path.isFunctionExpression() && path.has("id")) { if (!t.isProperty(path.parent, { method: true })) { this.registerBinding("var", path); } } // Class if (path.isClassExpression() && path.has("id")) { this.registerBinding("var", path); } // Function - params, rest if (path.isFunction()) { var params = path.get("params"); for (let param of (params: Array)) { this.registerBinding("param", param); } } // CatchClause - param if (path.isCatchClause()) { this.registerBinding("let", path); } // ComprehensionExpression - blocks if (path.isComprehensionExpression()) { this.registerBinding("let", path); } // Program var parent = this.getProgramParent(); if (parent.crawling) return; this.crawling = true; path.traverse(collectorVisitor); this.crawling = false; }
each(CodeGenerator.generators, function (generator) { extend(CodeGenerator.prototype, generator); });