mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-28 21:24:26 +08:00
This silences a warning because our Node engine is newer then the package expects. There are newer versions of the plugin by now, but the transitive dependencies are younger than 1 week so the audit mirror blocks them. 46.10.1 seems like it was stable for a couple months so we use that. R=alexrudenko@chromium.org Bug: None Change-Id: Icf1c1276852e55dcad97d2ea2eeb6a8d7a9d82ae Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5660063 Commit-Queue: Simon Zünd <szuend@chromium.org> Auto-Submit: Simon Zünd <szuend@chromium.org> Commit-Queue: Alex Rudenko <alexrudenko@chromium.org> Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
110 lines
3.0 KiB
JavaScript
110 lines
3.0 KiB
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
const util_js_1 = require("../../util.cjs");
|
|
|
|
const isQuoted = s => s && s.startsWith('"') && s.endsWith('"');
|
|
/**
|
|
* Splits remaining `spec.lines[].tokens.description` into `name` and `descriptions` tokens,
|
|
* and populates the `spec.name`
|
|
*/
|
|
|
|
|
|
function nameTokenizer() {
|
|
const typeEnd = (num, {
|
|
tokens
|
|
}, i) => tokens.type === '' ? num : i;
|
|
|
|
return spec => {
|
|
// look for the name in the line where {type} ends
|
|
const {
|
|
tokens
|
|
} = spec.source[spec.source.reduce(typeEnd, 0)];
|
|
const source = tokens.description.trimLeft();
|
|
const quotedGroups = source.split('"'); // if it starts with quoted group, assume it is a literal
|
|
|
|
if (quotedGroups.length > 1 && quotedGroups[0] === '' && quotedGroups.length % 2 === 1) {
|
|
spec.name = quotedGroups[1];
|
|
tokens.name = `"${quotedGroups[1]}"`;
|
|
[tokens.postName, tokens.description] = (0, util_js_1.splitSpace)(source.slice(tokens.name.length));
|
|
return spec;
|
|
}
|
|
|
|
let brackets = 0;
|
|
let name = '';
|
|
let optional = false;
|
|
let defaultValue; // assume name is non-space string or anything wrapped into brackets
|
|
|
|
for (const ch of source) {
|
|
if (brackets === 0 && (0, util_js_1.isSpace)(ch)) break;
|
|
if (ch === '[') brackets++;
|
|
if (ch === ']') brackets--;
|
|
name += ch;
|
|
}
|
|
|
|
if (brackets !== 0) {
|
|
spec.problems.push({
|
|
code: 'spec:name:unpaired-brackets',
|
|
message: 'unpaired brackets',
|
|
line: spec.source[0].number,
|
|
critical: true
|
|
});
|
|
return spec;
|
|
}
|
|
|
|
const nameToken = name;
|
|
|
|
if (name[0] === '[' && name[name.length - 1] === ']') {
|
|
optional = true;
|
|
name = name.slice(1, -1);
|
|
const parts = name.split('=');
|
|
name = parts[0].trim();
|
|
if (parts[1] !== undefined) defaultValue = parts.slice(1).join('=').trim();
|
|
|
|
if (name === '') {
|
|
spec.problems.push({
|
|
code: 'spec:name:empty-name',
|
|
message: 'empty name',
|
|
line: spec.source[0].number,
|
|
critical: true
|
|
});
|
|
return spec;
|
|
}
|
|
|
|
if (defaultValue === '') {
|
|
spec.problems.push({
|
|
code: 'spec:name:empty-default',
|
|
message: 'empty default value',
|
|
line: spec.source[0].number,
|
|
critical: true
|
|
});
|
|
return spec;
|
|
} // has "=" and is not a string, except for "=>"
|
|
|
|
|
|
if (!isQuoted(defaultValue) && /=(?!>)/.test(defaultValue)) {
|
|
spec.problems.push({
|
|
code: 'spec:name:invalid-default',
|
|
message: 'invalid default value syntax',
|
|
line: spec.source[0].number,
|
|
critical: true
|
|
});
|
|
return spec;
|
|
}
|
|
}
|
|
|
|
spec.optional = optional;
|
|
spec.name = name;
|
|
tokens.name = nameToken;
|
|
if (defaultValue !== undefined) spec.default = defaultValue;
|
|
[tokens.postName, tokens.description] = (0, util_js_1.splitSpace)(source.slice(tokens.name.length));
|
|
return spec;
|
|
};
|
|
}
|
|
|
|
exports.default = nameTokenizer;
|
|
//# sourceMappingURL=name.cjs.map
|