# inline-source-map

> Adds source mappings and base64 encodes them, so they can be inlined in your generated file.

Latest version **0.6.3** (published 2024-02-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install inline-source-map
pnpm add inline-source-map
yarn add inline-source-map
bun add inline-source-map
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.3 |
| Published | 2024-02-24 |
| First published | 2013-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 27.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 36 |
| Author | Thorsten Lorenz |
| Maintainers | zertosh, thlorenz |
| Keywords | source, map, inline, base64, bundle, generate, transpile |

## Links

- npm: https://www.npmjs.com/package/inline-source-map
- Repository: https://github.com/thlorenz/inline-source-map
- Issues: https://github.com/thlorenz/inline-source-map/issues
- npm.io page: https://npm.io/package/inline-source-map

## Dependencies (1)

- [source-map](https://npm.io/package/source-map.md) ~0.5.3

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.6.3 (latest) — 2024-02-24
- 0.6.2 — 2016-04-13
- 0.6.1 — 2015-10-04
- 0.6.0 — 2015-07-17
- 0.5.0 — 2015-02-27
- 0.4.1 — 2015-02-19
- 0.4.0 — 2015-02-19
- 0.3.1 — 2015-02-19
- 0.3.0 — 2013-11-05
- 0.2.5 — 2013-07-06
- 0.2.4 — 2013-07-06
- 0.2.3 — 2013-03-27
- 0.2.2 — 2013-03-17
- 0.2.1 — 2013-03-11
- 0.2.0 — 2013-03-11
- … 4 more at https://npm.io/package/inline-source-map/versions

## README

# inline-source-map [![Node.js CI](https://github.com/thlorenz/inline-source-map/actions/workflows/node-test.js.yml/badge.svg)](https://github.com/thlorenz/inline-source-map/actions/workflows/node-test.js.yml)

Adds source mappings and base64 encodes them, so they can be inlined in your generated file.

```js
var generator = require('inline-source-map');

// default charset 'utf-8' is configurable
var gen = generator({ charset: 'utf-8' })
  .addMappings('foo.js', [{ original: { line: 2, column: 3 } , generated: { line: 5, column: 10 } }], { line: 5 })
  .addGeneratedMappings('bar.js', 'var a = 2;\nconsole.log(a)', { line: 23, column: 22 });

console.log('base64 mapping:', gen.base64Encode());
console.log('inline mapping url:', gen.inlineMappingUrl());
```

```
base64 mapping: eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmb28uanMiLCJiYXIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O1VBQ0c7Ozs7Ozs7Ozs7Ozs7O3NCQ0RIO3NCQUNBIn0=
inline mapping url: //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmb28uanMiLCJiYXIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O1VBQ0c7Ozs7Ozs7Ozs7Ozs7O3NCQ0RIO3NCQUNBIn0=
```

## API

### addMappings(sourceFile, mappings, offset)

```
/**
 * Adds the given mappings to the generator and offsets them if offset is given
 *
 * @name addMappings
 * @function
 * @param sourceFile {String} name of the source file
 * @param mappings {Array{{Object}} each object has the form { original: { line: _, column: _ }, generated: { line: _, column: _ } }
 * @param offset {Object} offset to apply to each mapping. Has the form { line: _, column: _ }
 * @return {Object} the generator to allow chaining
 */
```

### addGeneratedMappings(sourceFile, source, offset)

```
/**
 * Generates mappings for the given source and adds them, assuming that no translation from original to generated is necessary.
 *
 * @name addGeneratedMappings
 * @function
 * @param sourceFile {String} name of the source file
 * @param source {String} source of the file
 * @param offset {Object} offset to apply to each mapping. Has the form { line: _, column: _ }
 * @return {Object} the generator to allow chaining
 */
```

### addSourceContent(sourceFile, sourceContent)

```
/**
 * Adds source content for the given source file.
 *
 * @name addSourceContent
 * @function
 * @param sourceFile {String} The source file for which a mapping is included
 * @param sourceContent {String} The content of the source file
 * @return {Object} The generator to allow chaining
 */
```


### base64Encode()

```
/**
 * @name base64Encode
 * @function
 * @return {String} bas64 encoded representation of the added mappings
 */
```

If source contents were added, this will be included in the encoded mappings.

### inlineMappingUrl()

```
/**
 * @name inlineMappingUrl
 * @function
 * @return {String} comment with base64 encoded representation of the added mappings. Can be inlined at the end of the generated file.
 */
```

---
_Source: https://npm.io/package/inline-source-map · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
