Comparing version 0.0.27 to 0.0.28
# code-red changelog | ||
## 0.0.28 | ||
* Add `toString` and `toUrl` methods on sourcemap objects ([#22](https://github.com/Rich-Harris/code-red/pull/22)) | ||
## 0.0.27 | ||
@@ -4,0 +8,0 @@ |
@@ -1325,2 +1325,18 @@ (function (global, factory) { | ||
let btoa = () => { | ||
throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.'); | ||
}; | ||
if (typeof window !== 'undefined' && typeof window.btoa === 'function') { | ||
btoa = (str) => window.btoa(unescape(encodeURIComponent(str))); | ||
} else if (typeof Buffer === 'function') { | ||
btoa = (str) => Buffer.from(str, 'utf-8').toString('base64'); | ||
} | ||
function print(node, opts = {}) { | ||
@@ -1393,11 +1409,28 @@ if (Array.isArray(node)) { | ||
const map = { | ||
version: 3, | ||
names: [] , | ||
sources: [opts.sourceMapSource || null], | ||
sourcesContent: [opts.sourceMapContent || null], | ||
mappings: sourcemapCodec.encode(mappings) | ||
}; | ||
Object.defineProperties(map, { | ||
toString: { | ||
enumerable: false, | ||
value: function toString() { | ||
return JSON.stringify(this); | ||
} | ||
}, | ||
toUrl: { | ||
enumerable: false, | ||
value: function toUrl() { | ||
return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString()); | ||
} | ||
} | ||
}); | ||
return { | ||
code, | ||
map: { | ||
version: 3, | ||
names: [], | ||
sources: [opts.sourceMapSource || null], | ||
sourcesContent: [opts.sourceMapContent || null], | ||
mappings: sourcemapCodec.encode(mappings) | ||
} | ||
map | ||
}; | ||
@@ -1404,0 +1437,0 @@ } |
{ | ||
"name": "code-red", | ||
"description": "code-red", | ||
"version": "0.0.27", | ||
"version": "0.0.28", | ||
"repository": "Rich-Harris/code-red", | ||
@@ -6,0 +6,0 @@ "main": "dist/code-red.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80704
2812