jass 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +47 -0
- data/README.md +45 -0
- data/lib/jass.rb +55 -0
- data/lib/jass/base.rb +141 -0
- data/lib/jass/bundle_processor.rb +28 -0
- data/lib/jass/compiler.rb +112 -0
- data/lib/jass/dependency.rb +14 -0
- data/lib/jass/errors.rb +29 -0
- data/lib/jass/es6_processor.rb +17 -0
- data/lib/jass/function.rb +13 -0
- data/lib/jass/global_directive_processor.rb +12 -0
- data/lib/jass/plugin.rb +13 -0
- data/lib/jass/railtie.rb +12 -0
- data/lib/jass/version.rb +3 -0
- data/vendor/node_modules/@types/acorn/index.d.ts +256 -0
- data/vendor/node_modules/@types/acorn/package.json +29 -0
- data/vendor/node_modules/@types/estree/index.d.ts +546 -0
- data/vendor/node_modules/@types/estree/package.json +22 -0
- data/vendor/node_modules/acorn-dynamic-import/lib/index.js +17 -0
- data/vendor/node_modules/acorn-dynamic-import/lib/inject.js +72 -0
- data/vendor/node_modules/acorn-dynamic-import/lib/walk.js +22 -0
- data/vendor/node_modules/acorn-dynamic-import/package.json +45 -0
- data/vendor/node_modules/acorn-dynamic-import/src/index.js +4 -0
- data/vendor/node_modules/acorn-dynamic-import/src/inject.js +52 -0
- data/vendor/node_modules/acorn-dynamic-import/src/walk.js +12 -0
- data/vendor/node_modules/acorn-es7-plugin/acorn-es7-plugin.js +17 -0
- data/vendor/node_modules/acorn-es7-plugin/acorn-v3.js +333 -0
- data/vendor/node_modules/acorn-es7-plugin/acorn-v4.js +194 -0
- data/vendor/node_modules/acorn-es7-plugin/package.json +29 -0
- data/vendor/node_modules/acorn-jsx/index.js +3 -0
- data/vendor/node_modules/acorn-jsx/inject.js +449 -0
- data/vendor/node_modules/acorn-jsx/package.json +28 -0
- data/vendor/node_modules/acorn-jsx/xhtml.js +255 -0
- data/vendor/node_modules/acorn/bin/_acorn.js +69 -0
- data/vendor/node_modules/acorn/bin/acorn +4 -0
- data/vendor/node_modules/acorn/bin/run_test262.js +22 -0
- data/vendor/node_modules/acorn/bin/test262.whitelist +409 -0
- data/vendor/node_modules/acorn/dist/acorn.es.js +5305 -0
- data/vendor/node_modules/acorn/dist/acorn.js +5336 -0
- data/vendor/node_modules/acorn/dist/acorn_loose.es.js +1412 -0
- data/vendor/node_modules/acorn/dist/acorn_loose.js +1422 -0
- data/vendor/node_modules/acorn/dist/walk.es.js +419 -0
- data/vendor/node_modules/acorn/dist/walk.js +439 -0
- data/vendor/node_modules/acorn/package.json +56 -0
- data/vendor/node_modules/ansi-styles/index.js +165 -0
- data/vendor/node_modules/ansi-styles/package.json +56 -0
- data/vendor/node_modules/arr-diff/index.js +58 -0
- data/vendor/node_modules/arr-diff/package.json +49 -0
- data/vendor/node_modules/arr-flatten/index.js +22 -0
- data/vendor/node_modules/arr-flatten/package.json +76 -0
- data/vendor/node_modules/array-unique/index.js +28 -0
- data/vendor/node_modules/array-unique/package.json +37 -0
- data/vendor/node_modules/braces/index.js +399 -0
- data/vendor/node_modules/braces/package.json +83 -0
- data/vendor/node_modules/buble/bin/buble +24 -0
- data/vendor/node_modules/buble/bin/handleError.js +58 -0
- data/vendor/node_modules/buble/bin/runBuble.js +150 -0
- data/vendor/node_modules/buble/bin/showHelp.js +16 -0
- data/vendor/node_modules/buble/dist/buble-browser-deps.umd.js +14857 -0
- data/vendor/node_modules/buble/dist/buble-browser.cjs.js +9941 -0
- data/vendor/node_modules/buble/dist/buble-browser.es.js +9933 -0
- data/vendor/node_modules/buble/dist/buble.cjs.js +9433 -0
- data/vendor/node_modules/buble/dist/buble.es.js +9425 -0
- data/vendor/node_modules/buble/package.json +74 -0
- data/vendor/node_modules/buble/register.js +90 -0
- data/vendor/node_modules/buble/src/index.js +98 -0
- data/vendor/node_modules/buble/src/program/BlockStatement.js +373 -0
- data/vendor/node_modules/buble/src/program/Node.js +112 -0
- data/vendor/node_modules/buble/src/program/Program.js +74 -0
- data/vendor/node_modules/buble/src/program/Scope.js +116 -0
- data/vendor/node_modules/buble/src/program/extractNames.js +35 -0
- data/vendor/node_modules/buble/src/program/keys.js +4 -0
- data/vendor/node_modules/buble/src/program/types/ArrayExpression.js +70 -0
- data/vendor/node_modules/buble/src/program/types/ArrowFunctionExpression.js +52 -0
- data/vendor/node_modules/buble/src/program/types/AssignmentExpression.js +185 -0
- data/vendor/node_modules/buble/src/program/types/BinaryExpression.js +12 -0
- data/vendor/node_modules/buble/src/program/types/BreakStatement.js +26 -0
- data/vendor/node_modules/buble/src/program/types/CallExpression.js +104 -0
- data/vendor/node_modules/buble/src/program/types/ClassBody.js +237 -0
- data/vendor/node_modules/buble/src/program/types/ClassDeclaration.js +79 -0
- data/vendor/node_modules/buble/src/program/types/ClassExpression.js +51 -0
- data/vendor/node_modules/buble/src/program/types/ContinueStatement.js +17 -0
- data/vendor/node_modules/buble/src/program/types/ExportDefaultDeclaration.js +10 -0
- data/vendor/node_modules/buble/src/program/types/ExportNamedDeclaration.js +10 -0
- data/vendor/node_modules/buble/src/program/types/ForInStatement.js +76 -0
- data/vendor/node_modules/buble/src/program/types/ForOfStatement.js +89 -0
- data/vendor/node_modules/buble/src/program/types/ForStatement.js +54 -0
- data/vendor/node_modules/buble/src/program/types/FunctionDeclaration.js +25 -0
- data/vendor/node_modules/buble/src/program/types/FunctionExpression.js +74 -0
- data/vendor/node_modules/buble/src/program/types/Identifier.js +54 -0
- data/vendor/node_modules/buble/src/program/types/IfStatement.js +29 -0
- data/vendor/node_modules/buble/src/program/types/ImportDeclaration.js +10 -0
- data/vendor/node_modules/buble/src/program/types/ImportDefaultSpecifier.js +8 -0
- data/vendor/node_modules/buble/src/program/types/ImportSpecifier.js +8 -0
- data/vendor/node_modules/buble/src/program/types/JSXAttribute.js +20 -0
- data/vendor/node_modules/buble/src/program/types/JSXClosingElement.js +27 -0
- data/vendor/node_modules/buble/src/program/types/JSXClosingFragment.js +22 -0
- data/vendor/node_modules/buble/src/program/types/JSXElement.js +57 -0
- data/vendor/node_modules/buble/src/program/types/JSXExpressionContainer.js +10 -0
- data/vendor/node_modules/buble/src/program/types/JSXFragment.js +4 -0
- data/vendor/node_modules/buble/src/program/types/JSXOpeningElement.js +93 -0
- data/vendor/node_modules/buble/src/program/types/JSXOpeningFragment.js +7 -0
- data/vendor/node_modules/buble/src/program/types/JSXSpreadAttribute.js +10 -0
- data/vendor/node_modules/buble/src/program/types/Literal.js +43 -0
- data/vendor/node_modules/buble/src/program/types/MemberExpression.js +13 -0
- data/vendor/node_modules/buble/src/program/types/NewExpression.js +55 -0
- data/vendor/node_modules/buble/src/program/types/ObjectExpression.js +250 -0
- data/vendor/node_modules/buble/src/program/types/Property.js +52 -0
- data/vendor/node_modules/buble/src/program/types/ReturnStatement.js +32 -0
- data/vendor/node_modules/buble/src/program/types/SpreadElement.js +12 -0
- data/vendor/node_modules/buble/src/program/types/Super.js +88 -0
- data/vendor/node_modules/buble/src/program/types/TaggedTemplateExpression.js +63 -0
- data/vendor/node_modules/buble/src/program/types/TemplateElement.js +7 -0
- data/vendor/node_modules/buble/src/program/types/TemplateLiteral.js +80 -0
- data/vendor/node_modules/buble/src/program/types/ThisExpression.js +31 -0
- data/vendor/node_modules/buble/src/program/types/UpdateExpression.js +32 -0
- data/vendor/node_modules/buble/src/program/types/VariableDeclaration.js +101 -0
- data/vendor/node_modules/buble/src/program/types/VariableDeclarator.js +43 -0
- data/vendor/node_modules/buble/src/program/types/index.js +98 -0
- data/vendor/node_modules/buble/src/program/types/shared/LoopStatement.js +105 -0
- data/vendor/node_modules/buble/src/program/types/shared/ModuleDeclaration.js +10 -0
- data/vendor/node_modules/buble/src/program/wrap.js +68 -0
- data/vendor/node_modules/buble/src/support.js +97 -0
- data/vendor/node_modules/buble/src/utils/CompileError.js +30 -0
- data/vendor/node_modules/buble/src/utils/array.js +11 -0
- data/vendor/node_modules/buble/src/utils/checkConst.js +8 -0
- data/vendor/node_modules/buble/src/utils/deindent.js +30 -0
- data/vendor/node_modules/buble/src/utils/destructure.js +377 -0
- data/vendor/node_modules/buble/src/utils/getSnippet.js +30 -0
- data/vendor/node_modules/buble/src/utils/isReference.js +41 -0
- data/vendor/node_modules/buble/src/utils/locate.js +20 -0
- data/vendor/node_modules/buble/src/utils/patterns.js +1 -0
- data/vendor/node_modules/buble/src/utils/removeTrailingComma.js +13 -0
- data/vendor/node_modules/buble/src/utils/reserved.js +6 -0
- data/vendor/node_modules/buble/src/utils/spread.js +70 -0
- data/vendor/node_modules/builtin-modules/builtin-modules.json +39 -0
- data/vendor/node_modules/builtin-modules/index.js +10 -0
- data/vendor/node_modules/builtin-modules/package.json +40 -0
- data/vendor/node_modules/builtin-modules/static.js +2 -0
- data/vendor/node_modules/chalk/index.js +228 -0
- data/vendor/node_modules/chalk/package.json +66 -0
- data/vendor/node_modules/chalk/templates.js +128 -0
- data/vendor/node_modules/chalk/types/index.d.ts +97 -0
- data/vendor/node_modules/color-convert/conversions.js +861 -0
- data/vendor/node_modules/color-convert/index.js +78 -0
- data/vendor/node_modules/color-convert/package.json +46 -0
- data/vendor/node_modules/color-convert/route.js +97 -0
- data/vendor/node_modules/color-name/index.js +152 -0
- data/vendor/node_modules/color-name/package.json +25 -0
- data/vendor/node_modules/color-name/test.js +7 -0
- data/vendor/node_modules/date-time/index.js +33 -0
- data/vendor/node_modules/date-time/package.json +39 -0
- data/vendor/node_modules/escape-string-regexp/index.js +11 -0
- data/vendor/node_modules/escape-string-regexp/package.json +41 -0
- data/vendor/node_modules/estree-walker/dist/estree-walker.es.js +57 -0
- data/vendor/node_modules/estree-walker/dist/estree-walker.umd.js +68 -0
- data/vendor/node_modules/estree-walker/package.json +34 -0
- data/vendor/node_modules/estree-walker/src/estree-walker.js +51 -0
- data/vendor/node_modules/expand-brackets/index.js +163 -0
- data/vendor/node_modules/expand-brackets/package.json +62 -0
- data/vendor/node_modules/expand-range/index.js +43 -0
- data/vendor/node_modules/expand-range/package.json +73 -0
- data/vendor/node_modules/extglob/index.js +178 -0
- data/vendor/node_modules/extglob/package.json +60 -0
- data/vendor/node_modules/filename-regex/index.js +10 -0
- data/vendor/node_modules/filename-regex/package.json +50 -0
- data/vendor/node_modules/fill-range/index.js +408 -0
- data/vendor/node_modules/fill-range/package.json +61 -0
- data/vendor/node_modules/for-in/index.js +16 -0
- data/vendor/node_modules/for-in/package.json +68 -0
- data/vendor/node_modules/for-own/index.js +19 -0
- data/vendor/node_modules/for-own/package.json +70 -0
- data/vendor/node_modules/glob-base/index.js +51 -0
- data/vendor/node_modules/glob-base/package.json +52 -0
- data/vendor/node_modules/glob-parent/index.js +10 -0
- data/vendor/node_modules/glob-parent/package.json +35 -0
- data/vendor/node_modules/glob-parent/test.js +28 -0
- data/vendor/node_modules/has-flag/index.js +8 -0
- data/vendor/node_modules/has-flag/package.json +44 -0
- data/vendor/node_modules/irregular-plurals/irregular-plurals.json +146 -0
- data/vendor/node_modules/irregular-plurals/package.json +39 -0
- data/vendor/node_modules/is-buffer/index.js +21 -0
- data/vendor/node_modules/is-buffer/package.json +51 -0
- data/vendor/node_modules/is-dotfile/index.js +14 -0
- data/vendor/node_modules/is-dotfile/package.json +69 -0
- data/vendor/node_modules/is-equal-shallow/index.js +27 -0
- data/vendor/node_modules/is-equal-shallow/package.json +54 -0
- data/vendor/node_modules/is-extendable/index.js +13 -0
- data/vendor/node_modules/is-extendable/package.json +51 -0
- data/vendor/node_modules/is-extglob/index.js +11 -0
- data/vendor/node_modules/is-extglob/package.json +48 -0
- data/vendor/node_modules/is-glob/index.js +14 -0
- data/vendor/node_modules/is-glob/package.json +60 -0
- data/vendor/node_modules/is-module/index.js +11 -0
- data/vendor/node_modules/is-module/package.json +20 -0
- data/vendor/node_modules/is-number/index.js +19 -0
- data/vendor/node_modules/is-number/package.json +59 -0
- data/vendor/node_modules/is-posix-bracket/index.js +10 -0
- data/vendor/node_modules/is-posix-bracket/package.json +64 -0
- data/vendor/node_modules/is-primitive/index.js +13 -0
- data/vendor/node_modules/is-primitive/package.json +46 -0
- data/vendor/node_modules/is-reference/dist/is-reference.es.js +26 -0
- data/vendor/node_modules/is-reference/dist/is-reference.js +34 -0
- data/vendor/node_modules/is-reference/dist/types/index.d.ts +2 -0
- data/vendor/node_modules/is-reference/package.json +47 -0
- data/vendor/node_modules/isarray/index.js +5 -0
- data/vendor/node_modules/isarray/package.json +45 -0
- data/vendor/node_modules/isarray/test.js +20 -0
- data/vendor/node_modules/isobject/index.js +14 -0
- data/vendor/node_modules/isobject/package.json +67 -0
- data/vendor/node_modules/kind-of/index.js +116 -0
- data/vendor/node_modules/kind-of/package.json +90 -0
- data/vendor/node_modules/locate-character/dist/locate-character.es.js +43 -0
- data/vendor/node_modules/locate-character/dist/locate-character.umd.js +54 -0
- data/vendor/node_modules/locate-character/dist/types/index.d.ts +17 -0
- data/vendor/node_modules/locate-character/package.json +41 -0
- data/vendor/node_modules/magic-string/dist/magic-string.cjs.js +1300 -0
- data/vendor/node_modules/magic-string/dist/magic-string.es.js +1296 -0
- data/vendor/node_modules/magic-string/dist/magic-string.umd.js +1352 -0
- data/vendor/node_modules/magic-string/index.d.ts +83 -0
- data/vendor/node_modules/magic-string/node_modules/vlq/dist/vlq.js +91 -0
- data/vendor/node_modules/magic-string/node_modules/vlq/package.json +27 -0
- data/vendor/node_modules/magic-string/node_modules/vlq/src/vlq.js +78 -0
- data/vendor/node_modules/magic-string/package.json +55 -0
- data/vendor/node_modules/micromatch/index.js +431 -0
- data/vendor/node_modules/micromatch/lib/chars.js +67 -0
- data/vendor/node_modules/micromatch/lib/expand.js +304 -0
- data/vendor/node_modules/micromatch/lib/glob.js +193 -0
- data/vendor/node_modules/micromatch/lib/utils.js +149 -0
- data/vendor/node_modules/micromatch/package.json +114 -0
- data/vendor/node_modules/minimist/index.js +236 -0
- data/vendor/node_modules/minimist/package.json +45 -0
- data/vendor/node_modules/nodent-compiler/compiler.js +171 -0
- data/vendor/node_modules/nodent-compiler/lib/arboriculture.js +2694 -0
- data/vendor/node_modules/nodent-compiler/lib/output.js +934 -0
- data/vendor/node_modules/nodent-compiler/lib/parser.js +291 -0
- data/vendor/node_modules/nodent-compiler/package.json +37 -0
- data/vendor/node_modules/normalize-path/index.js +19 -0
- data/vendor/node_modules/normalize-path/package.json +78 -0
- data/vendor/node_modules/object.omit/index.js +40 -0
- data/vendor/node_modules/object.omit/package.json +67 -0
- data/vendor/node_modules/os-homedir/index.js +24 -0
- data/vendor/node_modules/os-homedir/package.json +41 -0
- data/vendor/node_modules/parse-glob/index.js +156 -0
- data/vendor/node_modules/parse-glob/package.json +62 -0
- data/vendor/node_modules/parse-ms/index.js +16 -0
- data/vendor/node_modules/parse-ms/package.json +34 -0
- data/vendor/node_modules/path-parse/index.js +93 -0
- data/vendor/node_modules/path-parse/index.min.js +1 -0
- data/vendor/node_modules/path-parse/package.json +33 -0
- data/vendor/node_modules/path-parse/test.js +77 -0
- data/vendor/node_modules/path-parse/test.min.js +1 -0
- data/vendor/node_modules/plur/index.js +20 -0
- data/vendor/node_modules/plur/package.json +42 -0
- data/vendor/node_modules/preserve/index.js +54 -0
- data/vendor/node_modules/preserve/package.json +48 -0
- data/vendor/node_modules/preserve/test.js +48 -0
- data/vendor/node_modules/pretty-ms/index.js +48 -0
- data/vendor/node_modules/pretty-ms/package.json +48 -0
- data/vendor/node_modules/randomatic/index.js +82 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/index.js +22 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/index.js +116 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/package.json +90 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/package.json +83 -0
- data/vendor/node_modules/randomatic/node_modules/kind-of/index.js +119 -0
- data/vendor/node_modules/randomatic/node_modules/kind-of/package.json +90 -0
- data/vendor/node_modules/randomatic/package.json +78 -0
- data/vendor/node_modules/regex-cache/index.js +68 -0
- data/vendor/node_modules/regex-cache/package.json +64 -0
- data/vendor/node_modules/remove-trailing-separator/index.js +17 -0
- data/vendor/node_modules/remove-trailing-separator/package.json +37 -0
- data/vendor/node_modules/repeat-element/index.js +18 -0
- data/vendor/node_modules/repeat-element/package.json +44 -0
- data/vendor/node_modules/repeat-string/index.js +70 -0
- data/vendor/node_modules/repeat-string/package.json +77 -0
- data/vendor/node_modules/require-relative/index.js +33 -0
- data/vendor/node_modules/require-relative/package.json +22 -0
- data/vendor/node_modules/resolve/index.js +8 -0
- data/vendor/node_modules/resolve/lib/async.js +203 -0
- data/vendor/node_modules/resolve/lib/caller.js +8 -0
- data/vendor/node_modules/resolve/lib/core.js +53 -0
- data/vendor/node_modules/resolve/lib/core.json +69 -0
- data/vendor/node_modules/resolve/lib/node-modules-paths.js +45 -0
- data/vendor/node_modules/resolve/lib/sync.js +93 -0
- data/vendor/node_modules/resolve/package.json +40 -0
- data/vendor/node_modules/rollup-plugin-commonjs/dist/rollup-plugin-commonjs.cjs.js +804 -0
- data/vendor/node_modules/rollup-plugin-commonjs/dist/rollup-plugin-commonjs.es.js +800 -0
- data/vendor/node_modules/rollup-plugin-commonjs/package.json +52 -0
- data/vendor/node_modules/rollup-plugin-commonjs/src/ast-utils.js +104 -0
- data/vendor/node_modules/rollup-plugin-commonjs/src/defaultResolver.js +39 -0
- data/vendor/node_modules/rollup-plugin-commonjs/src/helpers.js +19 -0
- data/vendor/node_modules/rollup-plugin-commonjs/src/index.js +198 -0
- data/vendor/node_modules/rollup-plugin-commonjs/src/transform.js +431 -0
- data/vendor/node_modules/rollup-plugin-commonjs/src/utils.js +13 -0
- data/vendor/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.cjs.js +218 -0
- data/vendor/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.es.js +214 -0
- data/vendor/node_modules/rollup-plugin-node-resolve/package.json +51 -0
- data/vendor/node_modules/rollup-plugin-node-resolve/src/empty.js +1 -0
- data/vendor/node_modules/rollup-plugin-node-resolve/src/index.js +205 -0
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.cjs.js +223 -0
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es.js +214 -0
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es6.js +217 -0
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/dist/estree-walker.es.js +55 -0
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/dist/estree-walker.es6.js +59 -0
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/dist/estree-walker.umd.js +65 -0
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/package.json +33 -0
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/src/estree-walker.js +49 -0
- data/vendor/node_modules/rollup-pluginutils/package.json +40 -0
- data/vendor/node_modules/rollup-pluginutils/src/addExtension.js +6 -0
- data/vendor/node_modules/rollup-pluginutils/src/attachScopes.js +147 -0
- data/vendor/node_modules/rollup-pluginutils/src/createFilter.js +33 -0
- data/vendor/node_modules/rollup-pluginutils/src/index.js +4 -0
- data/vendor/node_modules/rollup-pluginutils/src/makeLegalIdentifier.js +15 -0
- data/vendor/node_modules/rollup-pluginutils/src/utils/ensureArray.js +5 -0
- data/vendor/node_modules/rollup/bin/rollup +4085 -0
- data/vendor/node_modules/rollup/dist/rollup.browser.js +19829 -0
- data/vendor/node_modules/rollup/dist/rollup.es.js +23586 -0
- data/vendor/node_modules/rollup/dist/rollup.js +23597 -0
- data/vendor/node_modules/rollup/dist/typings/Chunk.d.ts +85 -0
- data/vendor/node_modules/rollup/dist/typings/ExternalModule.d.ts +30 -0
- data/vendor/node_modules/rollup/dist/typings/Graph.d.ts +47 -0
- data/vendor/node_modules/rollup/dist/typings/Module.d.ts +130 -0
- data/vendor/node_modules/rollup/dist/typings/ast/CallOptions.d.ts +20 -0
- data/vendor/node_modules/rollup/dist/typings/ast/Entity.d.ts +16 -0
- data/vendor/node_modules/rollup/dist/typings/ast/ExecutionPathOptions.d.ts +57 -0
- data/vendor/node_modules/rollup/dist/typings/ast/clone.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/ast/enhance.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/ast/keys.d.ts +4 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ArrayExpression.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ArrayPattern.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ArrowFunctionExpression.d.ts +25 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/AssignmentExpression.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/AssignmentPattern.d.ts +16 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/AssignmentProperty.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/AwaitExpression.d.ts +8 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/BinaryExpression.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/BlockStatement.d.ts +19 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/BreakStatement.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/CallExpression.d.ts +22 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/CatchClause.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ClassBody.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ClassDeclaration.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ClassExpression.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ConditionalExpression.d.ts +28 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/DoWhileStatement.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/EmptyStatement.d.ts +8 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ExportAllDeclaration.d.ts +12 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ExportDefaultDeclaration.d.ts +21 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ExportNamedDeclaration.d.ts +21 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ExportSpecifier.d.ts +8 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ExpressionStatement.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ForInStatement.d.ts +20 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ForOfStatement.d.ts +21 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ForStatement.d.ts +19 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/FunctionDeclaration.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/FunctionExpression.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/Identifier.d.ts +29 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/IfStatement.d.ts +17 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/Import.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ImportDeclaration.d.ts +17 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ImportDefaultSpecifier.d.ts +7 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ImportNamespaceSpecifier.d.ts +7 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ImportSpecifier.d.ts +8 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/LabeledStatement.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/Literal.d.ts +22 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/LogicalExpression.d.ts +23 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/MemberExpression.d.ts +34 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/MethodDefinition.d.ts +16 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/NewExpression.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/NodeType.d.ts +64 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ObjectExpression.d.ts +22 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ObjectPattern.d.ts +15 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/Program.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/Property.d.ts +30 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/RestElement.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ReturnStatement.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/SequenceExpression.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/SpreadElement.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/SwitchCase.d.ts +11 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/SwitchStatement.d.ts +12 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/TaggedTemplateExpression.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/TemplateElement.d.ts +12 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/TemplateLiteral.d.ts +12 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ThisExpression.d.ts +17 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ThrowStatement.d.ts +8 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/UnaryExpression.d.ts +16 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/UnknownNode.d.ts +5 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/UpdateExpression.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/VariableDeclaration.d.ts +21 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/VariableDeclarator.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/WhileStatement.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/YieldExpression.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/index.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/shared/ClassNode.d.ts +17 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/shared/Expression.d.ts +21 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/shared/FunctionNode.d.ts +25 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/shared/Node.d.ts +133 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/shared/Pattern.d.ts +4 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/shared/pureFunctions.d.ts +4 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/BlockScope.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/CatchScope.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/FunctionScope.d.ts +20 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/GlobalScope.d.ts +7 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/ModuleScope.d.ts +11 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/ParameterScope.d.ts +16 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/ReturnValueScope.d.ts +11 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/Scope.d.ts +42 -0
- data/vendor/node_modules/rollup/dist/typings/ast/utils/extractNames.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/ast/values.d.ts +31 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/ArgumentsVariable.d.ts +15 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/ExportDefaultVariable.d.ts +16 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/ExternalVariable.d.ts +12 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/GlobalVariable.d.ts +11 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/LocalVariable.d.ts +21 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/NamespaceVariable.d.ts +20 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/ParameterVariable.d.ts +5 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/ReplaceableInitializationVariable.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/ThisVariable.d.ts +4 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/Variable.d.ts +43 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/VariableReassignmentTracker.d.ts +11 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/amd.d.ts +11 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/cjs.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/es.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/iife.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/index.d.ts +15 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/esModuleExport.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/getExportBlock.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/getGlobalNameMaker.d.ts +4 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/getInteropBlock.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/sanitize.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/setupNamespace.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/trimEmptyImports.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/warnOnBuiltins.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/system.d.ts +8 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/umd.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/node-entry.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/rollup/index.d.ts +167 -0
- data/vendor/node_modules/rollup/dist/typings/utils/callIfFunction.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/utils/collapseSourcemaps.d.ts +5 -0
- data/vendor/node_modules/rollup/dist/typings/utils/commondir.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/utils/defaults.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/utils/deprecateOptions.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/utils/ensureArray.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/utils/entryHashing.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/utils/error.d.ts +18 -0
- data/vendor/node_modules/rollup/dist/typings/utils/first-sync.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/utils/first.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/utils/flushTime.d.ts +5 -0
- data/vendor/node_modules/rollup/dist/typings/utils/fs.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/utils/getCodeFrame.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/utils/getExportMode.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/utils/getIndentString.d.ts +4 -0
- data/vendor/node_modules/rollup/dist/typings/utils/identifierHelpers.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/utils/mergeOptions.d.ts +19 -0
- data/vendor/node_modules/rollup/dist/typings/utils/object.d.ts +7 -0
- data/vendor/node_modules/rollup/dist/typings/utils/path.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/utils/promise.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/utils/relativeId.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/utils/renderHelpers.d.ts +26 -0
- data/vendor/node_modules/rollup/dist/typings/utils/sourceMappingURL.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/utils/timers.d.ts +7 -0
- data/vendor/node_modules/rollup/dist/typings/utils/transform.d.ts +25 -0
- data/vendor/node_modules/rollup/dist/typings/utils/transformBundle.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/watch/chokidar.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/watch/fileWatchers.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/watch/index.d.ts +47 -0
- data/vendor/node_modules/rollup/package.json +122 -0
- data/vendor/node_modules/rollup/typings/package.json.d.ts +3 -0
- data/vendor/node_modules/signal-exit/index.js +157 -0
- data/vendor/node_modules/signal-exit/package.json +38 -0
- data/vendor/node_modules/signal-exit/signals.js +53 -0
- data/vendor/node_modules/source-map/dist/source-map.debug.js +3091 -0
- data/vendor/node_modules/source-map/dist/source-map.js +3090 -0
- data/vendor/node_modules/source-map/dist/source-map.min.js +2 -0
- data/vendor/node_modules/source-map/lib/array-set.js +121 -0
- data/vendor/node_modules/source-map/lib/base64-vlq.js +140 -0
- data/vendor/node_modules/source-map/lib/base64.js +67 -0
- data/vendor/node_modules/source-map/lib/binary-search.js +111 -0
- data/vendor/node_modules/source-map/lib/mapping-list.js +79 -0
- data/vendor/node_modules/source-map/lib/quick-sort.js +114 -0
- data/vendor/node_modules/source-map/lib/source-map-consumer.js +1082 -0
- data/vendor/node_modules/source-map/lib/source-map-generator.js +416 -0
- data/vendor/node_modules/source-map/lib/source-node.js +413 -0
- data/vendor/node_modules/source-map/lib/util.js +417 -0
- data/vendor/node_modules/source-map/package.json +72 -0
- data/vendor/node_modules/source-map/source-map.js +8 -0
- data/vendor/node_modules/sourcemap-codec/dist/sourcemap-codec.es.js +129 -0
- data/vendor/node_modules/sourcemap-codec/dist/sourcemap-codec.umd.js +140 -0
- data/vendor/node_modules/sourcemap-codec/dist/types/sourcemap-codec.d.ts +5 -0
- data/vendor/node_modules/sourcemap-codec/package.json +52 -0
- data/vendor/node_modules/supports-color/browser.js +5 -0
- data/vendor/node_modules/supports-color/index.js +135 -0
- data/vendor/node_modules/supports-color/package.json +53 -0
- data/vendor/node_modules/time-zone/index.js +10 -0
- data/vendor/node_modules/time-zone/package.json +35 -0
- data/vendor/node_modules/vlq/dist/types/vlq.d.ts +2 -0
- data/vendor/node_modules/vlq/dist/vlq.es.js +64 -0
- data/vendor/node_modules/vlq/dist/vlq.js +75 -0
- data/vendor/node_modules/vlq/package.json +30 -0
- data/vendor/package.json +15 -0
- data/vendor/yarn.lock +453 -0
- metadata +641 -0
@@ -0,0 +1,416 @@
|
|
1
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
4
|
+
* Licensed under the New BSD license. See LICENSE or:
|
5
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
6
|
+
*/
|
7
|
+
|
8
|
+
var base64VLQ = require('./base64-vlq');
|
9
|
+
var util = require('./util');
|
10
|
+
var ArraySet = require('./array-set').ArraySet;
|
11
|
+
var MappingList = require('./mapping-list').MappingList;
|
12
|
+
|
13
|
+
/**
|
14
|
+
* An instance of the SourceMapGenerator represents a source map which is
|
15
|
+
* being built incrementally. You may pass an object with the following
|
16
|
+
* properties:
|
17
|
+
*
|
18
|
+
* - file: The filename of the generated source.
|
19
|
+
* - sourceRoot: A root for all relative URLs in this source map.
|
20
|
+
*/
|
21
|
+
function SourceMapGenerator(aArgs) {
|
22
|
+
if (!aArgs) {
|
23
|
+
aArgs = {};
|
24
|
+
}
|
25
|
+
this._file = util.getArg(aArgs, 'file', null);
|
26
|
+
this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
|
27
|
+
this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
|
28
|
+
this._sources = new ArraySet();
|
29
|
+
this._names = new ArraySet();
|
30
|
+
this._mappings = new MappingList();
|
31
|
+
this._sourcesContents = null;
|
32
|
+
}
|
33
|
+
|
34
|
+
SourceMapGenerator.prototype._version = 3;
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Creates a new SourceMapGenerator based on a SourceMapConsumer
|
38
|
+
*
|
39
|
+
* @param aSourceMapConsumer The SourceMap.
|
40
|
+
*/
|
41
|
+
SourceMapGenerator.fromSourceMap =
|
42
|
+
function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
|
43
|
+
var sourceRoot = aSourceMapConsumer.sourceRoot;
|
44
|
+
var generator = new SourceMapGenerator({
|
45
|
+
file: aSourceMapConsumer.file,
|
46
|
+
sourceRoot: sourceRoot
|
47
|
+
});
|
48
|
+
aSourceMapConsumer.eachMapping(function (mapping) {
|
49
|
+
var newMapping = {
|
50
|
+
generated: {
|
51
|
+
line: mapping.generatedLine,
|
52
|
+
column: mapping.generatedColumn
|
53
|
+
}
|
54
|
+
};
|
55
|
+
|
56
|
+
if (mapping.source != null) {
|
57
|
+
newMapping.source = mapping.source;
|
58
|
+
if (sourceRoot != null) {
|
59
|
+
newMapping.source = util.relative(sourceRoot, newMapping.source);
|
60
|
+
}
|
61
|
+
|
62
|
+
newMapping.original = {
|
63
|
+
line: mapping.originalLine,
|
64
|
+
column: mapping.originalColumn
|
65
|
+
};
|
66
|
+
|
67
|
+
if (mapping.name != null) {
|
68
|
+
newMapping.name = mapping.name;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
generator.addMapping(newMapping);
|
73
|
+
});
|
74
|
+
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
75
|
+
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
76
|
+
if (content != null) {
|
77
|
+
generator.setSourceContent(sourceFile, content);
|
78
|
+
}
|
79
|
+
});
|
80
|
+
return generator;
|
81
|
+
};
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Add a single mapping from original source line and column to the generated
|
85
|
+
* source's line and column for this source map being created. The mapping
|
86
|
+
* object should have the following properties:
|
87
|
+
*
|
88
|
+
* - generated: An object with the generated line and column positions.
|
89
|
+
* - original: An object with the original line and column positions.
|
90
|
+
* - source: The original source file (relative to the sourceRoot).
|
91
|
+
* - name: An optional original token name for this mapping.
|
92
|
+
*/
|
93
|
+
SourceMapGenerator.prototype.addMapping =
|
94
|
+
function SourceMapGenerator_addMapping(aArgs) {
|
95
|
+
var generated = util.getArg(aArgs, 'generated');
|
96
|
+
var original = util.getArg(aArgs, 'original', null);
|
97
|
+
var source = util.getArg(aArgs, 'source', null);
|
98
|
+
var name = util.getArg(aArgs, 'name', null);
|
99
|
+
|
100
|
+
if (!this._skipValidation) {
|
101
|
+
this._validateMapping(generated, original, source, name);
|
102
|
+
}
|
103
|
+
|
104
|
+
if (source != null) {
|
105
|
+
source = String(source);
|
106
|
+
if (!this._sources.has(source)) {
|
107
|
+
this._sources.add(source);
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
if (name != null) {
|
112
|
+
name = String(name);
|
113
|
+
if (!this._names.has(name)) {
|
114
|
+
this._names.add(name);
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
this._mappings.add({
|
119
|
+
generatedLine: generated.line,
|
120
|
+
generatedColumn: generated.column,
|
121
|
+
originalLine: original != null && original.line,
|
122
|
+
originalColumn: original != null && original.column,
|
123
|
+
source: source,
|
124
|
+
name: name
|
125
|
+
});
|
126
|
+
};
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Set the source content for a source file.
|
130
|
+
*/
|
131
|
+
SourceMapGenerator.prototype.setSourceContent =
|
132
|
+
function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
|
133
|
+
var source = aSourceFile;
|
134
|
+
if (this._sourceRoot != null) {
|
135
|
+
source = util.relative(this._sourceRoot, source);
|
136
|
+
}
|
137
|
+
|
138
|
+
if (aSourceContent != null) {
|
139
|
+
// Add the source content to the _sourcesContents map.
|
140
|
+
// Create a new _sourcesContents map if the property is null.
|
141
|
+
if (!this._sourcesContents) {
|
142
|
+
this._sourcesContents = Object.create(null);
|
143
|
+
}
|
144
|
+
this._sourcesContents[util.toSetString(source)] = aSourceContent;
|
145
|
+
} else if (this._sourcesContents) {
|
146
|
+
// Remove the source file from the _sourcesContents map.
|
147
|
+
// If the _sourcesContents map is empty, set the property to null.
|
148
|
+
delete this._sourcesContents[util.toSetString(source)];
|
149
|
+
if (Object.keys(this._sourcesContents).length === 0) {
|
150
|
+
this._sourcesContents = null;
|
151
|
+
}
|
152
|
+
}
|
153
|
+
};
|
154
|
+
|
155
|
+
/**
|
156
|
+
* Applies the mappings of a sub-source-map for a specific source file to the
|
157
|
+
* source map being generated. Each mapping to the supplied source file is
|
158
|
+
* rewritten using the supplied source map. Note: The resolution for the
|
159
|
+
* resulting mappings is the minimium of this map and the supplied map.
|
160
|
+
*
|
161
|
+
* @param aSourceMapConsumer The source map to be applied.
|
162
|
+
* @param aSourceFile Optional. The filename of the source file.
|
163
|
+
* If omitted, SourceMapConsumer's file property will be used.
|
164
|
+
* @param aSourceMapPath Optional. The dirname of the path to the source map
|
165
|
+
* to be applied. If relative, it is relative to the SourceMapConsumer.
|
166
|
+
* This parameter is needed when the two source maps aren't in the same
|
167
|
+
* directory, and the source map to be applied contains relative source
|
168
|
+
* paths. If so, those relative source paths need to be rewritten
|
169
|
+
* relative to the SourceMapGenerator.
|
170
|
+
*/
|
171
|
+
SourceMapGenerator.prototype.applySourceMap =
|
172
|
+
function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
|
173
|
+
var sourceFile = aSourceFile;
|
174
|
+
// If aSourceFile is omitted, we will use the file property of the SourceMap
|
175
|
+
if (aSourceFile == null) {
|
176
|
+
if (aSourceMapConsumer.file == null) {
|
177
|
+
throw new Error(
|
178
|
+
'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
|
179
|
+
'or the source map\'s "file" property. Both were omitted.'
|
180
|
+
);
|
181
|
+
}
|
182
|
+
sourceFile = aSourceMapConsumer.file;
|
183
|
+
}
|
184
|
+
var sourceRoot = this._sourceRoot;
|
185
|
+
// Make "sourceFile" relative if an absolute Url is passed.
|
186
|
+
if (sourceRoot != null) {
|
187
|
+
sourceFile = util.relative(sourceRoot, sourceFile);
|
188
|
+
}
|
189
|
+
// Applying the SourceMap can add and remove items from the sources and
|
190
|
+
// the names array.
|
191
|
+
var newSources = new ArraySet();
|
192
|
+
var newNames = new ArraySet();
|
193
|
+
|
194
|
+
// Find mappings for the "sourceFile"
|
195
|
+
this._mappings.unsortedForEach(function (mapping) {
|
196
|
+
if (mapping.source === sourceFile && mapping.originalLine != null) {
|
197
|
+
// Check if it can be mapped by the source map, then update the mapping.
|
198
|
+
var original = aSourceMapConsumer.originalPositionFor({
|
199
|
+
line: mapping.originalLine,
|
200
|
+
column: mapping.originalColumn
|
201
|
+
});
|
202
|
+
if (original.source != null) {
|
203
|
+
// Copy mapping
|
204
|
+
mapping.source = original.source;
|
205
|
+
if (aSourceMapPath != null) {
|
206
|
+
mapping.source = util.join(aSourceMapPath, mapping.source)
|
207
|
+
}
|
208
|
+
if (sourceRoot != null) {
|
209
|
+
mapping.source = util.relative(sourceRoot, mapping.source);
|
210
|
+
}
|
211
|
+
mapping.originalLine = original.line;
|
212
|
+
mapping.originalColumn = original.column;
|
213
|
+
if (original.name != null) {
|
214
|
+
mapping.name = original.name;
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
|
219
|
+
var source = mapping.source;
|
220
|
+
if (source != null && !newSources.has(source)) {
|
221
|
+
newSources.add(source);
|
222
|
+
}
|
223
|
+
|
224
|
+
var name = mapping.name;
|
225
|
+
if (name != null && !newNames.has(name)) {
|
226
|
+
newNames.add(name);
|
227
|
+
}
|
228
|
+
|
229
|
+
}, this);
|
230
|
+
this._sources = newSources;
|
231
|
+
this._names = newNames;
|
232
|
+
|
233
|
+
// Copy sourcesContents of applied map.
|
234
|
+
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
235
|
+
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
236
|
+
if (content != null) {
|
237
|
+
if (aSourceMapPath != null) {
|
238
|
+
sourceFile = util.join(aSourceMapPath, sourceFile);
|
239
|
+
}
|
240
|
+
if (sourceRoot != null) {
|
241
|
+
sourceFile = util.relative(sourceRoot, sourceFile);
|
242
|
+
}
|
243
|
+
this.setSourceContent(sourceFile, content);
|
244
|
+
}
|
245
|
+
}, this);
|
246
|
+
};
|
247
|
+
|
248
|
+
/**
|
249
|
+
* A mapping can have one of the three levels of data:
|
250
|
+
*
|
251
|
+
* 1. Just the generated position.
|
252
|
+
* 2. The Generated position, original position, and original source.
|
253
|
+
* 3. Generated and original position, original source, as well as a name
|
254
|
+
* token.
|
255
|
+
*
|
256
|
+
* To maintain consistency, we validate that any new mapping being added falls
|
257
|
+
* in to one of these categories.
|
258
|
+
*/
|
259
|
+
SourceMapGenerator.prototype._validateMapping =
|
260
|
+
function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
|
261
|
+
aName) {
|
262
|
+
// When aOriginal is truthy but has empty values for .line and .column,
|
263
|
+
// it is most likely a programmer error. In this case we throw a very
|
264
|
+
// specific error message to try to guide them the right way.
|
265
|
+
// For example: https://github.com/Polymer/polymer-bundler/pull/519
|
266
|
+
if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {
|
267
|
+
throw new Error(
|
268
|
+
'original.line and original.column are not numbers -- you probably meant to omit ' +
|
269
|
+
'the original mapping entirely and only map the generated position. If so, pass ' +
|
270
|
+
'null for the original mapping instead of an object with empty or null values.'
|
271
|
+
);
|
272
|
+
}
|
273
|
+
|
274
|
+
if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
275
|
+
&& aGenerated.line > 0 && aGenerated.column >= 0
|
276
|
+
&& !aOriginal && !aSource && !aName) {
|
277
|
+
// Case 1.
|
278
|
+
return;
|
279
|
+
}
|
280
|
+
else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
|
281
|
+
&& aOriginal && 'line' in aOriginal && 'column' in aOriginal
|
282
|
+
&& aGenerated.line > 0 && aGenerated.column >= 0
|
283
|
+
&& aOriginal.line > 0 && aOriginal.column >= 0
|
284
|
+
&& aSource) {
|
285
|
+
// Cases 2 and 3.
|
286
|
+
return;
|
287
|
+
}
|
288
|
+
else {
|
289
|
+
throw new Error('Invalid mapping: ' + JSON.stringify({
|
290
|
+
generated: aGenerated,
|
291
|
+
source: aSource,
|
292
|
+
original: aOriginal,
|
293
|
+
name: aName
|
294
|
+
}));
|
295
|
+
}
|
296
|
+
};
|
297
|
+
|
298
|
+
/**
|
299
|
+
* Serialize the accumulated mappings in to the stream of base 64 VLQs
|
300
|
+
* specified by the source map format.
|
301
|
+
*/
|
302
|
+
SourceMapGenerator.prototype._serializeMappings =
|
303
|
+
function SourceMapGenerator_serializeMappings() {
|
304
|
+
var previousGeneratedColumn = 0;
|
305
|
+
var previousGeneratedLine = 1;
|
306
|
+
var previousOriginalColumn = 0;
|
307
|
+
var previousOriginalLine = 0;
|
308
|
+
var previousName = 0;
|
309
|
+
var previousSource = 0;
|
310
|
+
var result = '';
|
311
|
+
var next;
|
312
|
+
var mapping;
|
313
|
+
var nameIdx;
|
314
|
+
var sourceIdx;
|
315
|
+
|
316
|
+
var mappings = this._mappings.toArray();
|
317
|
+
for (var i = 0, len = mappings.length; i < len; i++) {
|
318
|
+
mapping = mappings[i];
|
319
|
+
next = ''
|
320
|
+
|
321
|
+
if (mapping.generatedLine !== previousGeneratedLine) {
|
322
|
+
previousGeneratedColumn = 0;
|
323
|
+
while (mapping.generatedLine !== previousGeneratedLine) {
|
324
|
+
next += ';';
|
325
|
+
previousGeneratedLine++;
|
326
|
+
}
|
327
|
+
}
|
328
|
+
else {
|
329
|
+
if (i > 0) {
|
330
|
+
if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
|
331
|
+
continue;
|
332
|
+
}
|
333
|
+
next += ',';
|
334
|
+
}
|
335
|
+
}
|
336
|
+
|
337
|
+
next += base64VLQ.encode(mapping.generatedColumn
|
338
|
+
- previousGeneratedColumn);
|
339
|
+
previousGeneratedColumn = mapping.generatedColumn;
|
340
|
+
|
341
|
+
if (mapping.source != null) {
|
342
|
+
sourceIdx = this._sources.indexOf(mapping.source);
|
343
|
+
next += base64VLQ.encode(sourceIdx - previousSource);
|
344
|
+
previousSource = sourceIdx;
|
345
|
+
|
346
|
+
// lines are stored 0-based in SourceMap spec version 3
|
347
|
+
next += base64VLQ.encode(mapping.originalLine - 1
|
348
|
+
- previousOriginalLine);
|
349
|
+
previousOriginalLine = mapping.originalLine - 1;
|
350
|
+
|
351
|
+
next += base64VLQ.encode(mapping.originalColumn
|
352
|
+
- previousOriginalColumn);
|
353
|
+
previousOriginalColumn = mapping.originalColumn;
|
354
|
+
|
355
|
+
if (mapping.name != null) {
|
356
|
+
nameIdx = this._names.indexOf(mapping.name);
|
357
|
+
next += base64VLQ.encode(nameIdx - previousName);
|
358
|
+
previousName = nameIdx;
|
359
|
+
}
|
360
|
+
}
|
361
|
+
|
362
|
+
result += next;
|
363
|
+
}
|
364
|
+
|
365
|
+
return result;
|
366
|
+
};
|
367
|
+
|
368
|
+
SourceMapGenerator.prototype._generateSourcesContent =
|
369
|
+
function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
|
370
|
+
return aSources.map(function (source) {
|
371
|
+
if (!this._sourcesContents) {
|
372
|
+
return null;
|
373
|
+
}
|
374
|
+
if (aSourceRoot != null) {
|
375
|
+
source = util.relative(aSourceRoot, source);
|
376
|
+
}
|
377
|
+
var key = util.toSetString(source);
|
378
|
+
return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
|
379
|
+
? this._sourcesContents[key]
|
380
|
+
: null;
|
381
|
+
}, this);
|
382
|
+
};
|
383
|
+
|
384
|
+
/**
|
385
|
+
* Externalize the source map.
|
386
|
+
*/
|
387
|
+
SourceMapGenerator.prototype.toJSON =
|
388
|
+
function SourceMapGenerator_toJSON() {
|
389
|
+
var map = {
|
390
|
+
version: this._version,
|
391
|
+
sources: this._sources.toArray(),
|
392
|
+
names: this._names.toArray(),
|
393
|
+
mappings: this._serializeMappings()
|
394
|
+
};
|
395
|
+
if (this._file != null) {
|
396
|
+
map.file = this._file;
|
397
|
+
}
|
398
|
+
if (this._sourceRoot != null) {
|
399
|
+
map.sourceRoot = this._sourceRoot;
|
400
|
+
}
|
401
|
+
if (this._sourcesContents) {
|
402
|
+
map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
|
403
|
+
}
|
404
|
+
|
405
|
+
return map;
|
406
|
+
};
|
407
|
+
|
408
|
+
/**
|
409
|
+
* Render the source map being generated to a string.
|
410
|
+
*/
|
411
|
+
SourceMapGenerator.prototype.toString =
|
412
|
+
function SourceMapGenerator_toString() {
|
413
|
+
return JSON.stringify(this.toJSON());
|
414
|
+
};
|
415
|
+
|
416
|
+
exports.SourceMapGenerator = SourceMapGenerator;
|
@@ -0,0 +1,413 @@
|
|
1
|
+
/* -*- Mode: js; js-indent-level: 2; -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2011 Mozilla Foundation and contributors
|
4
|
+
* Licensed under the New BSD license. See LICENSE or:
|
5
|
+
* http://opensource.org/licenses/BSD-3-Clause
|
6
|
+
*/
|
7
|
+
|
8
|
+
var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;
|
9
|
+
var util = require('./util');
|
10
|
+
|
11
|
+
// Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
|
12
|
+
// operating systems these days (capturing the result).
|
13
|
+
var REGEX_NEWLINE = /(\r?\n)/;
|
14
|
+
|
15
|
+
// Newline character code for charCodeAt() comparisons
|
16
|
+
var NEWLINE_CODE = 10;
|
17
|
+
|
18
|
+
// Private symbol for identifying `SourceNode`s when multiple versions of
|
19
|
+
// the source-map library are loaded. This MUST NOT CHANGE across
|
20
|
+
// versions!
|
21
|
+
var isSourceNode = "$$$isSourceNode$$$";
|
22
|
+
|
23
|
+
/**
|
24
|
+
* SourceNodes provide a way to abstract over interpolating/concatenating
|
25
|
+
* snippets of generated JavaScript source code while maintaining the line and
|
26
|
+
* column information associated with the original source code.
|
27
|
+
*
|
28
|
+
* @param aLine The original line number.
|
29
|
+
* @param aColumn The original column number.
|
30
|
+
* @param aSource The original source's filename.
|
31
|
+
* @param aChunks Optional. An array of strings which are snippets of
|
32
|
+
* generated JS, or other SourceNodes.
|
33
|
+
* @param aName The original identifier.
|
34
|
+
*/
|
35
|
+
function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
|
36
|
+
this.children = [];
|
37
|
+
this.sourceContents = {};
|
38
|
+
this.line = aLine == null ? null : aLine;
|
39
|
+
this.column = aColumn == null ? null : aColumn;
|
40
|
+
this.source = aSource == null ? null : aSource;
|
41
|
+
this.name = aName == null ? null : aName;
|
42
|
+
this[isSourceNode] = true;
|
43
|
+
if (aChunks != null) this.add(aChunks);
|
44
|
+
}
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Creates a SourceNode from generated code and a SourceMapConsumer.
|
48
|
+
*
|
49
|
+
* @param aGeneratedCode The generated code
|
50
|
+
* @param aSourceMapConsumer The SourceMap for the generated code
|
51
|
+
* @param aRelativePath Optional. The path that relative sources in the
|
52
|
+
* SourceMapConsumer should be relative to.
|
53
|
+
*/
|
54
|
+
SourceNode.fromStringWithSourceMap =
|
55
|
+
function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
|
56
|
+
// The SourceNode we want to fill with the generated code
|
57
|
+
// and the SourceMap
|
58
|
+
var node = new SourceNode();
|
59
|
+
|
60
|
+
// All even indices of this array are one line of the generated code,
|
61
|
+
// while all odd indices are the newlines between two adjacent lines
|
62
|
+
// (since `REGEX_NEWLINE` captures its match).
|
63
|
+
// Processed fragments are accessed by calling `shiftNextLine`.
|
64
|
+
var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
|
65
|
+
var remainingLinesIndex = 0;
|
66
|
+
var shiftNextLine = function() {
|
67
|
+
var lineContents = getNextLine();
|
68
|
+
// The last line of a file might not have a newline.
|
69
|
+
var newLine = getNextLine() || "";
|
70
|
+
return lineContents + newLine;
|
71
|
+
|
72
|
+
function getNextLine() {
|
73
|
+
return remainingLinesIndex < remainingLines.length ?
|
74
|
+
remainingLines[remainingLinesIndex++] : undefined;
|
75
|
+
}
|
76
|
+
};
|
77
|
+
|
78
|
+
// We need to remember the position of "remainingLines"
|
79
|
+
var lastGeneratedLine = 1, lastGeneratedColumn = 0;
|
80
|
+
|
81
|
+
// The generate SourceNodes we need a code range.
|
82
|
+
// To extract it current and last mapping is used.
|
83
|
+
// Here we store the last mapping.
|
84
|
+
var lastMapping = null;
|
85
|
+
|
86
|
+
aSourceMapConsumer.eachMapping(function (mapping) {
|
87
|
+
if (lastMapping !== null) {
|
88
|
+
// We add the code from "lastMapping" to "mapping":
|
89
|
+
// First check if there is a new line in between.
|
90
|
+
if (lastGeneratedLine < mapping.generatedLine) {
|
91
|
+
// Associate first line with "lastMapping"
|
92
|
+
addMappingWithCode(lastMapping, shiftNextLine());
|
93
|
+
lastGeneratedLine++;
|
94
|
+
lastGeneratedColumn = 0;
|
95
|
+
// The remaining code is added without mapping
|
96
|
+
} else {
|
97
|
+
// There is no new line in between.
|
98
|
+
// Associate the code between "lastGeneratedColumn" and
|
99
|
+
// "mapping.generatedColumn" with "lastMapping"
|
100
|
+
var nextLine = remainingLines[remainingLinesIndex];
|
101
|
+
var code = nextLine.substr(0, mapping.generatedColumn -
|
102
|
+
lastGeneratedColumn);
|
103
|
+
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -
|
104
|
+
lastGeneratedColumn);
|
105
|
+
lastGeneratedColumn = mapping.generatedColumn;
|
106
|
+
addMappingWithCode(lastMapping, code);
|
107
|
+
// No more remaining code, continue
|
108
|
+
lastMapping = mapping;
|
109
|
+
return;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
// We add the generated code until the first mapping
|
113
|
+
// to the SourceNode without any mapping.
|
114
|
+
// Each line is added as separate string.
|
115
|
+
while (lastGeneratedLine < mapping.generatedLine) {
|
116
|
+
node.add(shiftNextLine());
|
117
|
+
lastGeneratedLine++;
|
118
|
+
}
|
119
|
+
if (lastGeneratedColumn < mapping.generatedColumn) {
|
120
|
+
var nextLine = remainingLines[remainingLinesIndex];
|
121
|
+
node.add(nextLine.substr(0, mapping.generatedColumn));
|
122
|
+
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);
|
123
|
+
lastGeneratedColumn = mapping.generatedColumn;
|
124
|
+
}
|
125
|
+
lastMapping = mapping;
|
126
|
+
}, this);
|
127
|
+
// We have processed all mappings.
|
128
|
+
if (remainingLinesIndex < remainingLines.length) {
|
129
|
+
if (lastMapping) {
|
130
|
+
// Associate the remaining code in the current line with "lastMapping"
|
131
|
+
addMappingWithCode(lastMapping, shiftNextLine());
|
132
|
+
}
|
133
|
+
// and add the remaining lines without any mapping
|
134
|
+
node.add(remainingLines.splice(remainingLinesIndex).join(""));
|
135
|
+
}
|
136
|
+
|
137
|
+
// Copy sourcesContent into SourceNode
|
138
|
+
aSourceMapConsumer.sources.forEach(function (sourceFile) {
|
139
|
+
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
140
|
+
if (content != null) {
|
141
|
+
if (aRelativePath != null) {
|
142
|
+
sourceFile = util.join(aRelativePath, sourceFile);
|
143
|
+
}
|
144
|
+
node.setSourceContent(sourceFile, content);
|
145
|
+
}
|
146
|
+
});
|
147
|
+
|
148
|
+
return node;
|
149
|
+
|
150
|
+
function addMappingWithCode(mapping, code) {
|
151
|
+
if (mapping === null || mapping.source === undefined) {
|
152
|
+
node.add(code);
|
153
|
+
} else {
|
154
|
+
var source = aRelativePath
|
155
|
+
? util.join(aRelativePath, mapping.source)
|
156
|
+
: mapping.source;
|
157
|
+
node.add(new SourceNode(mapping.originalLine,
|
158
|
+
mapping.originalColumn,
|
159
|
+
source,
|
160
|
+
code,
|
161
|
+
mapping.name));
|
162
|
+
}
|
163
|
+
}
|
164
|
+
};
|
165
|
+
|
166
|
+
/**
|
167
|
+
* Add a chunk of generated JS to this source node.
|
168
|
+
*
|
169
|
+
* @param aChunk A string snippet of generated JS code, another instance of
|
170
|
+
* SourceNode, or an array where each member is one of those things.
|
171
|
+
*/
|
172
|
+
SourceNode.prototype.add = function SourceNode_add(aChunk) {
|
173
|
+
if (Array.isArray(aChunk)) {
|
174
|
+
aChunk.forEach(function (chunk) {
|
175
|
+
this.add(chunk);
|
176
|
+
}, this);
|
177
|
+
}
|
178
|
+
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
|
179
|
+
if (aChunk) {
|
180
|
+
this.children.push(aChunk);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
else {
|
184
|
+
throw new TypeError(
|
185
|
+
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
186
|
+
);
|
187
|
+
}
|
188
|
+
return this;
|
189
|
+
};
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Add a chunk of generated JS to the beginning of this source node.
|
193
|
+
*
|
194
|
+
* @param aChunk A string snippet of generated JS code, another instance of
|
195
|
+
* SourceNode, or an array where each member is one of those things.
|
196
|
+
*/
|
197
|
+
SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
|
198
|
+
if (Array.isArray(aChunk)) {
|
199
|
+
for (var i = aChunk.length-1; i >= 0; i--) {
|
200
|
+
this.prepend(aChunk[i]);
|
201
|
+
}
|
202
|
+
}
|
203
|
+
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
|
204
|
+
this.children.unshift(aChunk);
|
205
|
+
}
|
206
|
+
else {
|
207
|
+
throw new TypeError(
|
208
|
+
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
|
209
|
+
);
|
210
|
+
}
|
211
|
+
return this;
|
212
|
+
};
|
213
|
+
|
214
|
+
/**
|
215
|
+
* Walk over the tree of JS snippets in this node and its children. The
|
216
|
+
* walking function is called once for each snippet of JS and is passed that
|
217
|
+
* snippet and the its original associated source's line/column location.
|
218
|
+
*
|
219
|
+
* @param aFn The traversal function.
|
220
|
+
*/
|
221
|
+
SourceNode.prototype.walk = function SourceNode_walk(aFn) {
|
222
|
+
var chunk;
|
223
|
+
for (var i = 0, len = this.children.length; i < len; i++) {
|
224
|
+
chunk = this.children[i];
|
225
|
+
if (chunk[isSourceNode]) {
|
226
|
+
chunk.walk(aFn);
|
227
|
+
}
|
228
|
+
else {
|
229
|
+
if (chunk !== '') {
|
230
|
+
aFn(chunk, { source: this.source,
|
231
|
+
line: this.line,
|
232
|
+
column: this.column,
|
233
|
+
name: this.name });
|
234
|
+
}
|
235
|
+
}
|
236
|
+
}
|
237
|
+
};
|
238
|
+
|
239
|
+
/**
|
240
|
+
* Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
|
241
|
+
* each of `this.children`.
|
242
|
+
*
|
243
|
+
* @param aSep The separator.
|
244
|
+
*/
|
245
|
+
SourceNode.prototype.join = function SourceNode_join(aSep) {
|
246
|
+
var newChildren;
|
247
|
+
var i;
|
248
|
+
var len = this.children.length;
|
249
|
+
if (len > 0) {
|
250
|
+
newChildren = [];
|
251
|
+
for (i = 0; i < len-1; i++) {
|
252
|
+
newChildren.push(this.children[i]);
|
253
|
+
newChildren.push(aSep);
|
254
|
+
}
|
255
|
+
newChildren.push(this.children[i]);
|
256
|
+
this.children = newChildren;
|
257
|
+
}
|
258
|
+
return this;
|
259
|
+
};
|
260
|
+
|
261
|
+
/**
|
262
|
+
* Call String.prototype.replace on the very right-most source snippet. Useful
|
263
|
+
* for trimming whitespace from the end of a source node, etc.
|
264
|
+
*
|
265
|
+
* @param aPattern The pattern to replace.
|
266
|
+
* @param aReplacement The thing to replace the pattern with.
|
267
|
+
*/
|
268
|
+
SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
|
269
|
+
var lastChild = this.children[this.children.length - 1];
|
270
|
+
if (lastChild[isSourceNode]) {
|
271
|
+
lastChild.replaceRight(aPattern, aReplacement);
|
272
|
+
}
|
273
|
+
else if (typeof lastChild === 'string') {
|
274
|
+
this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
|
275
|
+
}
|
276
|
+
else {
|
277
|
+
this.children.push(''.replace(aPattern, aReplacement));
|
278
|
+
}
|
279
|
+
return this;
|
280
|
+
};
|
281
|
+
|
282
|
+
/**
|
283
|
+
* Set the source content for a source file. This will be added to the SourceMapGenerator
|
284
|
+
* in the sourcesContent field.
|
285
|
+
*
|
286
|
+
* @param aSourceFile The filename of the source file
|
287
|
+
* @param aSourceContent The content of the source file
|
288
|
+
*/
|
289
|
+
SourceNode.prototype.setSourceContent =
|
290
|
+
function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
|
291
|
+
this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
|
292
|
+
};
|
293
|
+
|
294
|
+
/**
|
295
|
+
* Walk over the tree of SourceNodes. The walking function is called for each
|
296
|
+
* source file content and is passed the filename and source content.
|
297
|
+
*
|
298
|
+
* @param aFn The traversal function.
|
299
|
+
*/
|
300
|
+
SourceNode.prototype.walkSourceContents =
|
301
|
+
function SourceNode_walkSourceContents(aFn) {
|
302
|
+
for (var i = 0, len = this.children.length; i < len; i++) {
|
303
|
+
if (this.children[i][isSourceNode]) {
|
304
|
+
this.children[i].walkSourceContents(aFn);
|
305
|
+
}
|
306
|
+
}
|
307
|
+
|
308
|
+
var sources = Object.keys(this.sourceContents);
|
309
|
+
for (var i = 0, len = sources.length; i < len; i++) {
|
310
|
+
aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
|
311
|
+
}
|
312
|
+
};
|
313
|
+
|
314
|
+
/**
|
315
|
+
* Return the string representation of this source node. Walks over the tree
|
316
|
+
* and concatenates all the various snippets together to one string.
|
317
|
+
*/
|
318
|
+
SourceNode.prototype.toString = function SourceNode_toString() {
|
319
|
+
var str = "";
|
320
|
+
this.walk(function (chunk) {
|
321
|
+
str += chunk;
|
322
|
+
});
|
323
|
+
return str;
|
324
|
+
};
|
325
|
+
|
326
|
+
/**
|
327
|
+
* Returns the string representation of this source node along with a source
|
328
|
+
* map.
|
329
|
+
*/
|
330
|
+
SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
|
331
|
+
var generated = {
|
332
|
+
code: "",
|
333
|
+
line: 1,
|
334
|
+
column: 0
|
335
|
+
};
|
336
|
+
var map = new SourceMapGenerator(aArgs);
|
337
|
+
var sourceMappingActive = false;
|
338
|
+
var lastOriginalSource = null;
|
339
|
+
var lastOriginalLine = null;
|
340
|
+
var lastOriginalColumn = null;
|
341
|
+
var lastOriginalName = null;
|
342
|
+
this.walk(function (chunk, original) {
|
343
|
+
generated.code += chunk;
|
344
|
+
if (original.source !== null
|
345
|
+
&& original.line !== null
|
346
|
+
&& original.column !== null) {
|
347
|
+
if(lastOriginalSource !== original.source
|
348
|
+
|| lastOriginalLine !== original.line
|
349
|
+
|| lastOriginalColumn !== original.column
|
350
|
+
|| lastOriginalName !== original.name) {
|
351
|
+
map.addMapping({
|
352
|
+
source: original.source,
|
353
|
+
original: {
|
354
|
+
line: original.line,
|
355
|
+
column: original.column
|
356
|
+
},
|
357
|
+
generated: {
|
358
|
+
line: generated.line,
|
359
|
+
column: generated.column
|
360
|
+
},
|
361
|
+
name: original.name
|
362
|
+
});
|
363
|
+
}
|
364
|
+
lastOriginalSource = original.source;
|
365
|
+
lastOriginalLine = original.line;
|
366
|
+
lastOriginalColumn = original.column;
|
367
|
+
lastOriginalName = original.name;
|
368
|
+
sourceMappingActive = true;
|
369
|
+
} else if (sourceMappingActive) {
|
370
|
+
map.addMapping({
|
371
|
+
generated: {
|
372
|
+
line: generated.line,
|
373
|
+
column: generated.column
|
374
|
+
}
|
375
|
+
});
|
376
|
+
lastOriginalSource = null;
|
377
|
+
sourceMappingActive = false;
|
378
|
+
}
|
379
|
+
for (var idx = 0, length = chunk.length; idx < length; idx++) {
|
380
|
+
if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
|
381
|
+
generated.line++;
|
382
|
+
generated.column = 0;
|
383
|
+
// Mappings end at eol
|
384
|
+
if (idx + 1 === length) {
|
385
|
+
lastOriginalSource = null;
|
386
|
+
sourceMappingActive = false;
|
387
|
+
} else if (sourceMappingActive) {
|
388
|
+
map.addMapping({
|
389
|
+
source: original.source,
|
390
|
+
original: {
|
391
|
+
line: original.line,
|
392
|
+
column: original.column
|
393
|
+
},
|
394
|
+
generated: {
|
395
|
+
line: generated.line,
|
396
|
+
column: generated.column
|
397
|
+
},
|
398
|
+
name: original.name
|
399
|
+
});
|
400
|
+
}
|
401
|
+
} else {
|
402
|
+
generated.column++;
|
403
|
+
}
|
404
|
+
}
|
405
|
+
});
|
406
|
+
this.walkSourceContents(function (sourceFile, sourceContent) {
|
407
|
+
map.setSourceContent(sourceFile, sourceContent);
|
408
|
+
});
|
409
|
+
|
410
|
+
return { code: generated.code, map: map };
|
411
|
+
};
|
412
|
+
|
413
|
+
exports.SourceNode = SourceNode;
|