fix: readSourceMap split error

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2020-07-26 21:33:58 +08:00
parent f62d198166
commit 8def6257df
2 changed files with 15 additions and 11 deletions

View File

@ -97,10 +97,11 @@ export class MiaoScriptConsole implements Console {
MiaoScriptConsole.sourceMaps[fileName] = null MiaoScriptConsole.sourceMaps[fileName] = null
let sourceLine = base.read(fileName).split('\n') let sourceLine = base.read(fileName).split('\n')
let lastLine = sourceLine[sourceLine.length - 1] let lastLine = sourceLine[sourceLine.length - 1]
// lastLine is similar //# sourceMappingURL=data:application/json;base64,
if (lastLine.startsWith('//# sourceMappingURL=')) { if (lastLine.startsWith('//# sourceMappingURL=')) {
let sourceContent = null let sourceContent = null
let sourceMappingURL = lastLine.split('sourceMappingURL=', 2)[1] let sourceMappingURL = lastLine.split('sourceMappingURL=', 2)[1]
if (sourceMappingURL.startsWith('data:application/jsonbase64,')) { if (sourceMappingURL.startsWith('data:application/json;base64,')) {
sourceContent = String.fromCharCode(...Array.from(base64.toByteArray(sourceMappingURL.split(',', 2)[1]))) sourceContent = String.fromCharCode(...Array.from(base64.toByteArray(sourceMappingURL.split(',', 2)[1])))
} else if (sourceMappingURL.startsWith('http')) { } else if (sourceMappingURL.startsWith('http')) {
// TODO // TODO
@ -122,6 +123,9 @@ export class MiaoScriptConsole implements Console {
} }
} catch (error) { } catch (error) {
console.debug('search source map', fileName, 'line', lineNumber, 'error:', error) console.debug('search source map', fileName, 'line', lineNumber, 'error:', error)
if (global.debug) {
console.ex(error)
}
} }
return { return {
fileName, fileName,

View File

@ -504,22 +504,22 @@ export enum QRErrorCorrectLevel {
// QRMaskPattern // QRMaskPattern
//--------------------------------------------------------------------- //---------------------------------------------------------------------
var QRMaskPattern = { export enum QRMaskPattern {
PATTERN000: 0, PATTERN000 = 0,
PATTERN001: 1, PATTERN001 = 1,
PATTERN010: 2, PATTERN010 = 2,
PATTERN011: 3, PATTERN011 = 3,
PATTERN100: 4, PATTERN100 = 4,
PATTERN101: 5, PATTERN101 = 5,
PATTERN110: 6, PATTERN110 = 6,
PATTERN111: 7 PATTERN111 = 7
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// QRUtil // QRUtil
//--------------------------------------------------------------------- //---------------------------------------------------------------------
var QRUtil = { export const QRUtil = {
PATTERN_POSITION_TABLE: [ PATTERN_POSITION_TABLE: [
[], [],