[Pkg-javascript-commits] [node-sourcemap-codec] 01/03: New upstream version 1.4.0
Julien Puydt
julien.puydt at laposte.net
Mon Feb 19 21:45:40 UTC 2018
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to branch master
in repository node-sourcemap-codec.
commit 678e8af1d8379b7de32db8919cfec37cde206b6d
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Mon Feb 19 22:18:30 2018 +0100
New upstream version 1.4.0
---
.gitignore | 2 +-
.travis.yml | 5 ++--
CHANGELOG.md | 4 +++
package.json | 18 +++++++------
rollup.config.js | 25 +++++++++++-------
src/{sourcemap-codec.js => sourcemap-codec.ts} | 36 ++++++++++++++------------
tsconfig.json | 18 +++++++++++++
7 files changed, 71 insertions(+), 37 deletions(-)
diff --git a/.gitignore b/.gitignore
index f21b148..5504f10 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
.DS_Store
node_modules
dist
-.gobbl*
coverage
+package-lock.json
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index f5bf60c..89230fd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,9 +1,8 @@
sudo: false
language: node_js
node_js:
- - "0.12"
- - "4"
- - "5"
+ - "6"
+ - "stable"
env:
global:
- BUILD_TIMEOUT=10000
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 90d7048..a656a33 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# sourcemap-codec changelog
+## 1.4.0
+
+* Add TypeScript declarations ([#70](https://github.com/Rich-Harris/sourcemap-codec/pull/70))
+
## 1.3.1
* Update build process, expose `pkg.module`
diff --git a/package.json b/package.json
index 70c312c..a7c94a7 100644
--- a/package.json
+++ b/package.json
@@ -1,12 +1,13 @@
{
"name": "sourcemap-codec",
- "version": "1.3.1",
+ "version": "1.4.0",
"description": "Encode/decode sourcemap mappings",
"main": "dist/sourcemap-codec.umd.js",
"module": "dist/sourcemap-codec.es.js",
+ "types": "dist/types/sourcemap-codec.d.ts",
"scripts": {
"test": "mocha",
- "build": "rm -rf dist && rollup -c",
+ "build": "rm -rf dist && rollup -c && tsc",
"pretest": "npm run build",
"prepublish": "npm test",
"lint": "eslint src",
@@ -30,7 +31,7 @@
},
"homepage": "https://github.com/Rich-Harris/sourcemap-codec",
"dependencies": {
- "vlq": "^0.2.1"
+ "vlq": "^1.0.0"
},
"devDependencies": {
"codecov.io": "^0.1.6",
@@ -40,13 +41,14 @@
"istanbul": "^0.4.5",
"mocha": "^3.2.0",
"remap-istanbul": "^0.9.5",
- "rollup": "^0.41.6",
- "rollup-plugin-buble": "^0.15.0",
- "rollup-plugin-node-resolve": "^3.0.0"
+ "rollup": "^0.54.0",
+ "rollup-plugin-node-resolve": "^3.0.0",
+ "rollup-plugin-typescript": "^0.8.1",
+ "typescript": "^2.7.1"
},
"files": [
- "src",
- "dist",
+ "dist/*.js",
+ "dist/**/*.d.ts",
"README.md"
]
}
diff --git a/rollup.config.js b/rollup.config.js
index b3191ee..d7a5f72 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -1,18 +1,25 @@
-import buble from 'rollup-plugin-buble';
+import typescript from 'rollup-plugin-typescript';
import resolve from 'rollup-plugin-node-resolve';
const pkg = require( './package.json' );
export default {
- entry: 'src/sourcemap-codec.js',
+ input: 'src/sourcemap-codec.ts',
plugins: [
- buble({ exclude: 'node_modules/**' }),
+ typescript({
+ exclude: 'node_modules/**',
+ typescript: require('typescript')
+ }),
resolve({ jsnext: true })
],
- moduleName: 'sourcemapCodec',
- sourceMap: true,
- targets: [
- { dest: pkg.main, format: 'umd' },
- { dest: pkg.module, format: 'es' }
- ]
+ output: [{
+ file: pkg.main,
+ format: 'umd',
+ name: 'sourcemapCodec',
+ sourcemap: true
+ }, {
+ file: pkg.module,
+ format: 'es',
+ sourcemap: true
+ }]
};
diff --git a/src/sourcemap-codec.js b/src/sourcemap-codec.ts
similarity index 73%
rename from src/sourcemap-codec.js
rename to src/sourcemap-codec.ts
index a66429f..5052a47 100644
--- a/src/sourcemap-codec.js
+++ b/src/sourcemap-codec.ts
@@ -1,14 +1,18 @@
import { decode as decodeVlq, encode as encodeVlq } from 'vlq';
-function decodeSegments ( encodedSegments ) {
+export type SourceMapSegment = [number] | [number, number, number, number] | [number, number, number, number, number];
+export type SourceMapLine = SourceMapSegment[];
+export type SourceMapMappings = SourceMapLine[];
+
+function decodeSegments ( encodedSegments: string[] ): number[][] {
let i = encodedSegments.length;
- const segments = new Array( i );
+ const segments = new Array<number[]>( i );
while ( i-- ) segments[i] = decodeVlq( encodedSegments[i] );
return segments;
}
-export function decode ( mappings ) {
+export function decode ( mappings: string ): SourceMapMappings {
let sourceFileIndex = 0; // second field
let sourceCodeLine = 0; // third field
let sourceCodeColumn = 0; // fourth field
@@ -16,16 +20,16 @@ export function decode ( mappings ) {
const lines = mappings.split( ';' );
const numLines = lines.length;
- const decoded = new Array( numLines );
+ const decoded = new Array<SourceMapLine>( numLines );
- let i;
- let j;
- let line;
- let generatedCodeColumn;
- let decodedLine;
- let segments;
- let segment;
- let result;
+ let i: number;
+ let j: number;
+ let line: string;
+ let generatedCodeColumn: number;
+ let decodedLine: SourceMapLine;
+ let segments: number[][];
+ let segment: number[];
+ let result: SourceMapSegment;
for ( i = 0; i < numLines; i += 1 ) {
line = lines[i];
@@ -70,7 +74,7 @@ export function decode ( mappings ) {
return decoded;
}
-export function encode ( decoded ) {
+export function encode ( decoded: SourceMapMappings ): string {
const offsets = {
generatedCodeColumn: 0,
sourceFileIndex: 0, // second field
@@ -84,12 +88,12 @@ export function encode ( decoded ) {
return line.map( encodeSegment ).join( ',' );
}).join( ';' );
- function encodeSegment ( segment ) {
+ function encodeSegment ( segment: SourceMapSegment ): string {
if ( !segment.length ) {
- return segment;
+ return '';
}
- const result = new Array( segment.length );
+ const result = new Array<number>( segment.length );
result[0] = segment[0] - offsets.generatedCodeColumn;
offsets.generatedCodeColumn = segment[0];
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..563a16f
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,18 @@
+{
+ "compilerOptions": {
+ "noImplicitAny": true,
+ "diagnostics": true,
+ "noImplicitThis": true,
+ "noEmitOnError": true,
+ "target": "es5",
+ "lib": ["es5", "es6"],
+ "declaration": true,
+ "outDir": "dist/types"
+ },
+ "include": [
+ "src"
+ ],
+ "exclude": [
+ "node_modules"
+ ]
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-sourcemap-codec.git
More information about the Pkg-javascript-commits
mailing list