parent
be43bf3f23
commit
b692cf9608
|
@ -78,17 +78,17 @@ const updateMan = (() => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {{
|
* @param {{
|
||||||
id?: number
|
id?: number,
|
||||||
style?: StyleObj
|
style?: StyleObj,
|
||||||
port?: chrome.runtime.Port
|
port?: chrome.runtime.Port,
|
||||||
save?: boolean = true
|
save?: boolean,
|
||||||
ignoreDigest?: boolean
|
ignoreDigest?: boolean,
|
||||||
}} opts
|
}} opts
|
||||||
* @returns {{
|
* @returns {{
|
||||||
style: StyleObj
|
style: StyleObj,
|
||||||
updated?: boolean
|
updated?: boolean,
|
||||||
error?: any
|
error?: any,
|
||||||
STATES: UpdaterStates
|
STATES: UpdaterStates,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
Original style digests are calculated in these cases:
|
Original style digests are calculated in these cases:
|
||||||
|
@ -127,7 +127,7 @@ const updateMan = (() => {
|
||||||
err && err.message ||
|
err && err.message ||
|
||||||
err;
|
err;
|
||||||
res = {error, style, STATES};
|
res = {error, style, STATES};
|
||||||
state = `${STATES.SKIPPED} (${error})`;
|
state = `${STATES.SKIPPED} (${Array.isArray(err) ? err[0].message : error})`;
|
||||||
}
|
}
|
||||||
log(`${state} #${id} ${style.customName || style.name}`);
|
log(`${state} #${id} ${style.customName || style.name}`);
|
||||||
if (port) port.postMessage(res);
|
if (port) port.postMessage(res);
|
||||||
|
|
|
@ -2047,6 +2047,7 @@ self.parserlib = (() => {
|
||||||
this.name = this.constructor.name;
|
this.name = this.constructor.name;
|
||||||
this.col = pos.col;
|
this.col = pos.col;
|
||||||
this.line = pos.line;
|
this.line = pos.line;
|
||||||
|
this.offset = pos.offset;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2056,6 +2057,7 @@ self.parserlib = (() => {
|
||||||
super();
|
super();
|
||||||
this.col = pos.col;
|
this.col = pos.col;
|
||||||
this.line = pos.line;
|
this.line = pos.line;
|
||||||
|
this.offset = pos.offset;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3462,7 +3464,7 @@ self.parserlib = (() => {
|
||||||
* @param {string|Object} event
|
* @param {string|Object} event
|
||||||
* @param {parserlib.Token|SyntaxUnit} [token=this._tokenStream._token] - sets the position
|
* @param {parserlib.Token|SyntaxUnit} [token=this._tokenStream._token] - sets the position
|
||||||
*/
|
*/
|
||||||
fire(event, token = this._tokenStream._token) {
|
fire(event, token = event.offset != null ? event : this._tokenStream._token) {
|
||||||
if (typeof event === 'string') {
|
if (typeof event === 'string') {
|
||||||
event = {type: event};
|
event = {type: event};
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,12 @@ function extractSections({code, styleId, fast = true}) {
|
||||||
|
|
||||||
parser.addListener('error', e => {
|
parser.addListener('error', e => {
|
||||||
errors.push(e);
|
errors.push(e);
|
||||||
|
const min = 5; // characters to show
|
||||||
|
const max = 100;
|
||||||
|
const i = e.offset;
|
||||||
|
const a = Math.max(mozStyle.lastIndexOf('\n', i - min) + 1, i - max);
|
||||||
|
const b = Math.min(mozStyle.indexOf('\n', i - a > min ? i : i + min) + 1 || 1e9, i + max);
|
||||||
|
e.context = mozStyle.slice(a, b);
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -137,7 +137,6 @@ function reportUpdateState({updated, style, error, STATES}) {
|
||||||
error === STATES.SAME_VERSION
|
error === STATES.SAME_VERSION
|
||||||
);
|
);
|
||||||
const edited = error === STATES.EDITED || error === STATES.MAYBE_EDITED;
|
const edited = error === STATES.EDITED || error === STATES.MAYBE_EDITED;
|
||||||
entry.dataset.error = error;
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
error = t('updateCheckFailServerUnreachable') + '\n' + style.updateUrl;
|
error = t('updateCheckFailServerUnreachable') + '\n' + style.updateUrl;
|
||||||
} else if (typeof error === 'number') {
|
} else if (typeof error === 'number') {
|
||||||
|
@ -149,7 +148,13 @@ function reportUpdateState({updated, style, error, STATES}) {
|
||||||
} else if (typeof error === 'object' && error.message) {
|
} else if (typeof error === 'object' && error.message) {
|
||||||
// UserCSS meta errors provide an object
|
// UserCSS meta errors provide an object
|
||||||
error = error.message;
|
error = error.message;
|
||||||
|
} else if (Array.isArray(error)) {
|
||||||
|
// UserCSS build error
|
||||||
|
error = error.map(e => `${e.message || e}${
|
||||||
|
e.context ? '\n' + e.context.replace(/^/gm, '\t') : '' // indenting source text
|
||||||
|
}`).join('\n');
|
||||||
}
|
}
|
||||||
|
entry.dataset.error = error;
|
||||||
const message = same ? t('updateCheckSucceededNoUpdate') : error;
|
const message = same ? t('updateCheckSucceededNoUpdate') : error;
|
||||||
newClasses.set('no-update', true);
|
newClasses.set('no-update', true);
|
||||||
newClasses.set('update-problem', !same);
|
newClasses.set('update-problem', !same);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user