Skip to content

Commit 415850b

Browse files
committed
Watch Mode refactor
1 parent b35697f commit 415850b

File tree

8 files changed

+543
-513
lines changed

8 files changed

+543
-513
lines changed

CoffeeScript.py

+206-288
Large diffs are not rendered by default.

parse-base64vlq-mappings/base64-vlq.js

-108
This file was deleted.

parse-base64vlq-mappings/base64.js

-35
This file was deleted.

parse-base64vlq-mappings/index.js

-82
This file was deleted.

sourcemap/__init__.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
sourcemap
3+
~~~~~~~~~
4+
5+
:copyright: (c) 2013 by Matt Robenolt
6+
:license: BSD, see LICENSE for more details.
7+
"""
8+
from .exceptions import SourceMapDecodeError #NOQA
9+
from .decoder import SourceMapDecoder
10+
11+
__version__ = '0.1.7'
12+
13+
14+
def load(fp, cls=None):
15+
"Parse a sourcemap from a file-like object"
16+
return loads(fp.read(), cls)
17+
18+
19+
def loads(source, cls=None):
20+
"Parse a sourcemap from a string"
21+
cls = cls or SourceMapDecoder
22+
return cls().decode(source)
23+
24+
25+
def discover(source):
26+
"Given a JavaScript file, find the sourceMappingURL line"
27+
source = source.splitlines()
28+
# Source maps are only going to exist at either the top or bottom of the document.
29+
# Technically, there isn't anything indicating *where* it should exist, so we
30+
# are generous and assume it's somewhere either in the first or last 5 lines.
31+
# If it's somewhere else in the document, you're probably doing it wrong.
32+
if len(source) > 10:
33+
possibilities = source[:5] + source[-5:]
34+
else:
35+
possibilities = source
36+
37+
for line in set(possibilities):
38+
pragma = line[:21]
39+
if pragma == '//# sourceMappingURL=' or pragma == '//@ sourceMappingURL=':
40+
# We want everything AFTER the pragma, which is 21 chars long
41+
return line[21:].rstrip()
42+
# XXX: Return None or raise an exception?
43+
return None

0 commit comments

Comments
 (0)