<|start_filename|>node_modules/browser-pack-flat/cli.js<|end_filename|>
#!/usr/bin/env node

var pack = require('./')

process.stdin
  .pipe(pack())
  .pipe(process.stdout)


<|start_filename|>node_modules/browser-pack-flat/test/module-parent/child.js<|end_filename|>
if (module.parent) {
  module.exports = 'required'
} else {
  module.exports = 'entry point'
}


<|start_filename|>node_modules/browser-pack-flat/test/set-exports/app.js<|end_filename|>
exports.moduleExports = require('./module-exports')
exports.both = require('./both')
exports.exportsOnly = require('./exports-only')
exports.quoted = require('./quoted')
exports.free = require('./free-module')


<|start_filename|>node_modules/multisplice/test.js<|end_filename|>
var test = require('tape')
var Splicer = require('./')

test('splice multiple things using original indices', function (t) {
  var str = Splicer('a b c d e')
    .splice(2, 3, 'beep')
    .splice(6, 7, 'boop')

  t.equal(str.toString(), 'a beep c boop e')
  t.end()
})

test('slice part of a spliced string using original indices', function (t) {
  var str = Splicer('a b c d e')
    .splice(2, 3, 'beep')
    .splice(6, 7, 'boop')

  t.equal(str.slice(2, 5), 'beep c')
  t.end()
})


<|start_filename|>node_modules/browser-pack-flat/test/bare-module/expected.js<|end_filename|>
(function(){
var _$wrapped_2 = { exports: {} };
(function (module) {
  module.exports = 'whatever'
})(_$wrapped_2)

_$wrapped_2 = _$wrapped_2.exports
var _$app_1 = { exports: {} };
_$wrapped_2

if ("object" === 'object' && _$app_1.exports) {
  console.log('commonjs')
}

_$app_1 = _$app_1.exports
}());


<|start_filename|>node_modules/browser-pack-flat/test/exports-name/app.js<|end_filename|>
console.log(
  require('./fn').name,
  require('./class').name,
  require('./var').name
)


<|start_filename|>node_modules/browser-pack-flat/test/colliding-unused/expected.js<|end_filename|>
(function(){
// this `External` variable is probably defined by some other script on the page
var _$External_2 = External

// https://github.com/browserify/tinyify/issues/10
var __URL_2 = null

var _$app_1 = {};
/* removed: var _$External_2 = require('./other') */;

_$External_2.boot()

new URL('xyz')

}());


<|start_filename|>node_modules/browser-pack-flat/test/dedupe/a/xyz.js<|end_filename|>
module.exports = 'a/xyz.js'


<|start_filename|>node_modules/browser-pack-flat/lib/createModuleFactory.js<|end_filename|>
/**
 * Helper used in the output bundle to resolve dependency cycles.
 * This helper wraps a module factory and lazily executes it.
 * Imports of a circular module will call the factory returned by this function.
 */
module.exports = function createModuleFactory (factory) {
  var module
  return function (parent) {
    if (!module) {
      module = { exports: {}, parent: parent }
      factory(module, module.exports)
    }
    return module.exports
  }
}


<|start_filename|>node_modules/browser-pack-flat/test/lazy-cycles/expected.js<|end_filename|>
(function(){
var createModuleFactory = function createModuleFactory(t){var e;return function(r){return e||t(e={exports:{},parent:r},e.exports),e.exports}};
var _$a_1 = createModuleFactory(function (module, exports) {
var b = _$b_3({})
module.exports = function () {
  return b()
}

});
var _$b_3 = createModuleFactory(function (module, exports) {
module.exports = function () {
  return _$a_1({}).toString()
}

});
var _$app_2 = {};
console.log(
  _$a_1({})()
)

}());


<|start_filename|>node_modules/minify-stream/index.js<|end_filename|>
var duplexify = require('duplexify')
var concat = require('concat-stream')
var fromString = require('from2-string')
var defaultUglify = require('terser')
var convert = require('convert-source-map')
var xtend = require('xtend')

module.exports = uglifyStream

function defaultOpts () {
  return {
    sourceMap: { content: 'inline' }
  }
}

function uglifyStream (opts) {
  opts = xtend(defaultOpts(), opts || {})
  var uglify = opts.uglify || defaultUglify
  delete opts.uglify

  var stream = duplexify()

  var writer = concat({ encoding: 'string' }, function (source) {
    var result = uglify.minify(source, opts)
    if (result.then) {
      result.then(onsuccess, onerror)
    } else if (result.error) {
      return onerror(result.error)
    } else onsuccess(result)

    function onsuccess (minified) {
      var final = minified.code
      if (minified.map) {
        final += '\n' + convert.fromJSON(minified.map).toComment()
      }
      var reader = fromString(final)
      stream.setReadable(reader)
    }
    function onerror (error) {
      stream.emit('error', error)
    }
  })

  stream.setWritable(writer)

  return stream
}


<|start_filename|>node_modules/browser-pack-flat/test/input-source-map/app.js<|end_filename|>
import dep from "./dep"
import html from 'bel'

document.body.appendChild(html`
  <section class="mw7 center">
	 <h2 class="athelas ph3 ph0-l">News</h2>
	 <article class="pv4 bt bb b--black-10 ph3 ph0-l">
		<div class="flex flex-column flex-row-ns">
		  <div class="w-100 w-60-ns pr3-ns order-2 order-1-ns">
			 <h1 class="f3 athelas mt0 lh-title">${dep('title')}</h1>
			 <p class="f5 f4-l lh-copy athelas">
				${dep('excerpt')}
			 </p>
		  </div>
		  <div class="pl3-ns order-1 order-2-ns mb4 mb0-ns w-100 w-40-ns">
			 <img src="http://mrmrs.github.io/photos/cpu.jpg" class="db" alt="Photo of a dimly lit room with a computer interface terminal.">
		  </div>
		</div>
		<p class="f6 lh-copy gray mv0">By <span class="ttu">${dep('author')}</span></p>
		<time class="f6 db gray">${dep('timestamp')}</time>
	 </article>
  </section>
`)


<|start_filename|>node_modules/browser-pack-flat/test/input-source-map/dep.js<|end_filename|>
export default function whatever (xyz) {
  return xyz.toUpperCase()
}


<|start_filename|>node_modules/browser-pack-flat/test/variable/app.js<|end_filename|>
exports.param = require('./param')
exports.something = function () {
  var exports = {}
  exports.something = require('./param')
  return exports
}


<|start_filename|>node_modules/browser-pack-flat/build.js<|end_filename|>
var minify = require('uglify-js').minify
var fs = require('fs')

var createModuleFactory = minify(require('./lib/createModuleFactory').toString()).code
var exposedRequire = minify(require('./lib/exposedRequire').toString()).code

fs.writeFileSync('./_createModuleFactory.js', createModuleFactory)
fs.writeFileSync('./_exposedRequire.js', exposedRequire)


<|start_filename|>node_modules/unassert/index.js<|end_filename|>
/**
 * unassert
 *   Encourages programming with assertions by providing tools to compile them away.
 *
 * https://github.com/unassert-js/unassert
 *
 * Copyright (c) 2015-2019 <NAME>
 * Licensed under the MIT license.
 *   https://github.com/unassert-js/unassert/blob/master/LICENSE
 */
'use strict';

var estraverse = require('estraverse');
var syntax = estraverse.Syntax;
var esutils = require('esutils');
var objectAssign = require('object-assign');
var defaultOptions = require('./lib/default-options');
var createCallMatcher = require('./lib/create-call-matcher');
var createRequireMatcher = require('./lib/create-require-matcher');
var createImportMatcher = require('./lib/create-import-matcher');

function matches (node) {
    return function (matcher) {
        return matcher.test(node);
    };
}

function isBodyOfIfStatement (parentNode, key) {
    return parentNode.type === syntax.IfStatement && (key === 'consequent' || key === 'alternate');
}

function isBodyOfIterationStatement (parentNode, key) {
    return esutils.ast.isIterationStatement(parentNode) && key === 'body';
}

function isNonBlockChildOfIfStatementOrLoop (currentNode, parentNode, key) {
    return currentNode.type === syntax.ExpressionStatement &&
        currentNode.expression.type === syntax.CallExpression &&
        (isBodyOfIfStatement(parentNode, key) || isBodyOfIterationStatement(parentNode, key));
}

function compileMatchers (options) {
    var config = objectAssign(defaultOptions(), options);
    return {
        imports: config.importPatterns.map(createImportMatcher),
        requires: config.requirePatterns.map(createRequireMatcher),
        assertions: config.assertionPatterns.map(createCallMatcher)
    };
}

function createVisitorByMatchers (matchers) {
    var pathToRemove = {};
    return {
        enter: function (currentNode, parentNode) {
            var espathToRemove;
            switch (currentNode.type) {
            case syntax.ImportDeclaration:
                if (matchers.imports.some(matches(currentNode))) {
                    espathToRemove = this.path().join('/');
                    pathToRemove[espathToRemove] = true;
                    this.skip();
                }
                break;
            case syntax.VariableDeclarator:
                if (matchers.requires.some(matches(currentNode))) {
                    if (parentNode.declarations.length === 1) {
                        // remove parent VariableDeclaration
                        // body/1/declarations/0 -> body/1
                        espathToRemove = this.path().slice(0, -2).join('/');
                    } else {
                        // single var pattern
                        espathToRemove = this.path().join('/');
                    }
                    pathToRemove[espathToRemove] = true;
                    this.skip();
                }
                break;
            case syntax.AssignmentExpression:
                if (parentNode.type === syntax.ExpressionStatement &&
                    matchers.requires.some(matches(currentNode))) {
                    // remove parent ExpressionStatement
                    espathToRemove = this.path().slice(0, -1).join('/');
                    pathToRemove[espathToRemove] = true;
                    this.skip();
                }
                break;
            case syntax.CallExpression:
                if (parentNode.type === syntax.ExpressionStatement &&
                    matchers.assertions.some(matches(currentNode))) {
                    // remove parent ExpressionStatement
                    // body/1/body/body/0/expression -> body/1/body/body/0
                    espathToRemove = this.path().slice(0, -1).join('/');
                    pathToRemove[espathToRemove] = true;
                    this.skip();
                }
                break;
            }
        },
        leave: function (currentNode, parentNode) {
            var path = this.path();
            if (path && pathToRemove[path.join('/')]) {
                var key = path[path.length - 1];
                if (isNonBlockChildOfIfStatementOrLoop(currentNode, parentNode, key)) {
                    return {
                        type: syntax.BlockStatement,
                        body: []
                    };
                } else {
                    this.remove();
                }
            }
            return undefined;
        }
    };
}

var defaultMatchers = compileMatchers();

function unassert (ast) {
    return estraverse.replace(ast, createVisitorByMatchers(defaultMatchers));
}

function createVisitor (options) {
    return createVisitorByMatchers(compileMatchers(options));
}

unassert.defaultOptions = defaultOptions;
unassert.createVisitor = createVisitor;
module.exports = unassert;


<|start_filename|>node_modules/browser-pack-flat/test/colliding-unused/other.js<|end_filename|>
// this `External` variable is probably defined by some other script on the page
module.exports = External

// https://github.com/browserify/tinyify/issues/10
var URL = null


<|start_filename|>node_modules/browser-pack-flat/test/simplify/app.js<|end_filename|>
var hello = require('./hello')
var world = require('./world' /* comment */)

require('./asi'), console.log(hello, world)


<|start_filename|>node_modules/browser-pack-flat/test/globals/fn.js<|end_filename|>
function globalFunction () {
  var globalFunction = null
  !function globalFunction () { return null }()
}


<|start_filename|>node_modules/browser-pack-flat/test/variable/expected.js<|end_filename|>
(function(){
var _$param_2 = function (module) {
  return { exports: module }
}

var _$app_1 = {};
_$app_1.param = _$param_2
_$app_1.something = function () {
  var exports = {}
  exports.something = _$param_2
  return exports
}

}());


<|start_filename|>node_modules/@goto-bus-stop/common-shake/lib/shake.js<|end_filename|>
'use strict';

exports.walk = require('./shake/walk');
exports.evaluateConst = require('./shake/eval');

exports.Module = require('./shake/module');
exports.Analyzer = require('./shake/analyzer');
exports.Graph = require('./shake/graph');


<|start_filename|>node_modules/browser-pack-flat/example/src/app.js<|end_filename|>
var morph = require('nanomorph')
var view = require('./view')
var counter = 0

function render () {
  morph(document.body, view({
    counter: counter,
    increment: function () {
      counter++
      render()
    }
  }))
}

render()


<|start_filename|>node_modules/browser-pack-flat/test/remove-decl/a.js<|end_filename|>
module.exports = function test_module_please_ignore () {
}


<|start_filename|>node_modules/browser-pack-flat/example/src/view.js<|end_filename|>
var html = require('nanohtml')

module.exports = function render (props) {
  return html`
    <body>
      <div>${props.counter}</div>
      <button onclick=${onclick}>
        +1
      </button>
    </body>
  `

  function onclick () {
    props.increment()
  }
}


<|start_filename|>node_modules/browser-pack-flat/test/comment/app.js<|end_filename|>
var other = require('./other')

//


<|start_filename|>node_modules/browser-pack-flat/test/expose/localModule.js<|end_filename|>
module.exports = 'localModule'


<|start_filename|>node_modules/browser-pack-flat/test/lazy-order/app.js<|end_filename|>
require('./a')
global.later = function () {
  require('./b') // should not run immediately
}
if (require('./d')>0.5) {
  require('./c') // should not always run
}


<|start_filename|>node_modules/estree-is-identifier/test.js<|end_filename|>
var test = require('tape')
var parseFull = require('acorn').parse
var isIdentifier = require('./')

function parse (expr) {
  return parseFull(expr).body[0].expression
}

test('isIdentifier', function (t) {
  t.ok(isIdentifier(parse('abc')))
  t.notOk(isIdentifier(parse('abc.xyz')))
  t.notOk(isIdentifier(parseFull('function a () {}').body[0]))

  t.ok(isIdentifier(parse('abc'), 'abc'))
  t.notOk(isIdentifier(parse('xyz'), 'abc'))

  t.end()
})


<|start_filename|>node_modules/browser-pack-flat/test/input-source-map/options.json<|end_filename|>
{
  "debug": true,
  "preludePath": "node_modules/browserify/_prelude.js",
  "transform": "babelify"
}


<|start_filename|>node_modules/browser-pack-flat/test/bare-module/wrapped.js<|end_filename|>
(function (module) {
  module.exports = 'whatever'
})(module)


<|start_filename|>node_modules/transform-ast/example/arrows.js<|end_filename|>
var transform = require('../')

var result = transform(`
var multiply = (a, b) => {
  return a * b
}
var add = (a, b) => a + b
`, function (node) {
  if (node.type === 'ArrowFunctionExpression') {
    var params = node.params.map(function (param) { return param.getSource() })
    if (node.body.type !== 'BlockStatement') {
      node.body.edit.update(`{ return ${node.body.getSource()} }`)
    }
    node.edit.update(`function (${params.join(', ')}) ${node.body.getSource()}`)
  }
})

console.log(
  result.toString() +
  '\n//# sourceMappingURL=' +
  result.generateMap({ hires: true }).toUrl()
)


<|start_filename|>node_modules/browser-pack-flat/test/plugin.js<|end_filename|>
var test = require('tape')
var through = require('through2')
var fromString = require('from2-string')
var browserify = require('browserify')
var packFlat = require('../plugin')

test('plugin should replace browser-pack', function (t) {
  t.plan(1)

  var input = fromString('module.exports = "whatever"')
  var b = browserify(input)
  // Add some streams around the browser-pack stream
  b.pipeline.get('pack').unshift(through.obj())
  b.pipeline.get('pack').push(through.obj())

  b.plugin(packFlat)
  b.bundle(onbundle)

  function onbundle (err) {
    t.ifError(err)
  }
})


<|start_filename|>node_modules/browser-pack-flat/test/lazy-order/a.js<|end_filename|>
console.log('always')


<|start_filename|>node_modules/transform-ast/test/source.js<|end_filename|>
var test = require('tape')
var transform = require('../')

test('getSource()', function (t) {
  t.plan(2)
  var source = `
    import something from 'somewhere'
    
    something.whatever()
  `

  transform(source, { sourceType: 'module' }, function (node) {
    if (node.type === 'ImportDeclaration') {
      t.is(node.getSource(), "import something from 'somewhere'")
      t.is(node.source.value, 'somewhere')
    }
  })

  t.end()
})

test('keys that are both functions and objects', function (t) {
  t.plan(3)

  var source = `
    for (;; xyz) {} // update.name === "xyz"
    for (;; xyz(1, 2)) {} // update.arguments === [1, 2]
  `

  t.doesNotThrow(function () {
    transform(source, function (node) {
      if (node.type === 'ForStatement' && node.update.type === 'Identifier') {
        t.is(node.update.name, 'xyz')
      }
      if (node.type === 'ForStatement' && node.update.type === 'CallExpression') {
        t.is(node.update.arguments.length, 2)
      }
    })
  })

  t.end()
})


<|start_filename|>node_modules/multisplice/example.js<|end_filename|>
var multisplice = require('./')
var dedent = require('dedent')
var astw = require('astw')

var src = dedent`
  function beep (boop) {
    boop *= baz
    console.log(boop)
  }
  var baz = 10
  beep(17)
`

var splicer = multisplice(src)
var renames = {}
var nextName = 'a'.charCodeAt()
astw(src)(function (node) {
  if (node.type === 'Identifier') {
    if (!renames[node.name]) renames[node.name] = String.fromCharCode(nextName++)

    splicer.splice(node.start, node.end, renames[node.name])
  }
})

console.log(splicer.toString())


<|start_filename|>node_modules/browser-pack-flat/test/dedupe/b/index.js<|end_filename|>
module.exports = require('./xyz')


<|start_filename|>node_modules/browser-pack-flat/test/set-exports/exports-only.js<|end_filename|>
exports = 3


<|start_filename|>node_modules/@goto-bus-stop/common-shake/lib/shake/eval.js<|end_filename|>
'use strict';

function evaluateBinary(node) {
  const op = node.operator;

  const left = evaluateConst(node.left);
  const right = evaluateConst(node.right);

  if (op === '+')
    return left + right;

  throw new Error(`Unsupported binary operation: "${op}"`);
}

function evaluateConst(node) {
  if (node.type === 'Literal')
    return node.value;

  if (node.type === 'BinaryExpression')
    return evaluateBinary(node);

  throw new Error(`Unsupported node type: "${node.type}"`);
}
module.exports = evaluateConst;


<|start_filename|>node_modules/browser-pack-flat/test/typeof-require/expected.js<|end_filename|>
(function(){
var _$app_1 = { exports: {} };
if ("function" === 'function' && typeof _$app_1.exports === 'object' && "object" === 'object') {
  console.log('should do this')
  _$app_1.exports = factory()
} else {
  console.log('should not do this')
  this.Standalone = factory()
}

function factory () {
  return { value: 10 }
}

_$app_1 = _$app_1.exports
}());


<|start_filename|>node_modules/browser-unpack/index.js<|end_filename|>
var parse = require('acorn-node').parse;

module.exports = function (src) {
    // If src is a Buffer, esprima will just stringify it, so we beat them to
    // the punch. This avoids the problem where we're using esprima's range
    // indexes -- which are meant for a UTF-16 string -- in a buffer that
    // contains UTF-8 encoded text.
    if (typeof src !== 'string') {
        src = String(src);
    }

    var ast = parse(src, { range: true });

    ast.body = ast.body.filter(function(node) {
        return node.type !== 'EmptyStatement';
    });

    if (ast.body.length !== 1) return;
    if (ast.body[0].type !== 'ExpressionStatement') return;
    if (ast.body[0].expression.type === 'UnaryExpression') {
        var body = ast.body[0].expression.argument;
    } else if (ast.body[0].expression.type === 'AssignmentExpression') {
        var body = ast.body[0].expression.right;
    } else {
        var body = ast.body[0].expression;
    }

    if (body.type !== 'CallExpression') return;

    var args = body.arguments;
    if (args.length === 1) args = extractStandalone(args) || args;
    if (args.length !== 3) return;
    
    if (args[0].type !== 'ObjectExpression') return;
    if (args[1].type !== 'ObjectExpression') return;
    if (args[2].type !== 'ArrayExpression') return;
    
    var files = args[0].properties;
    var cache = args[1];
    var entries = args[2].elements.map(function (e) {
        return e.value
    });
    
    return files.map(function (file) {
        var body = file.value.elements[0].body.body;
        var start, end;
        if (body.length === 0) {
            start = body.start || 0;
            end = body.end || 0;
        }
        else {
            start = body[0].start;
            end = body[body.length-1].end;
        }
        
        var depProps = file.value.elements[1].properties;
        var deps = depProps.reduce(function (acc, dep) {
            var key = dep.key.type === 'Literal' 
                ? dep.key.value 
                : dep.key.name;
            acc[key] = dep.value.value;
            return acc;
        }, {});
        var row = {
            id: file.key.value,
            source: src.slice(start, end),
            deps: deps
        };
        if (entries.indexOf(row.id) >= 0) row.entry = true;
        return row;
    });
};

function extractStandalone (args) {
    if (args[0].type !== 'FunctionExpression') return;
    if (args[0].body.length < 2) return;
    if (args[0].body.body.length < 2) return;

    args = args[0].body.body[1].argument;
    if (args.type !== 'CallExpression') return;
    if (args.callee.type !== 'CallExpression') return;

    return args.callee.arguments;
};


<|start_filename|>node_modules/browser-pack-flat/plugin.js<|end_filename|>
var pack = require('./index')

module.exports = function apply (b, opts) {
  // When used as a transform
  if (typeof b !== 'object') {
    throw new Error('browser-pack-flat: must be used as a plugin, not a transform')
  }

  opts = Object.assign({}, opts || {}, {
    raw: true,
    debug: opts.debug || b._options.debug,
    basedir: b._options.basedir || process.cwd()
  })

  function addHooks () {
    var streams = b.pipeline.get('pack')
    var index = streams.indexOf(b._bpack)

    streams.splice(index, 1,
      pack(Object.assign({}, opts, {
        standalone: b._options.standalone,
        standaloneModule: b._options.standaloneModule
      }))
    )
  }

  addHooks()
  b.on('reset', addHooks)
}
