mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-05 03:21:16 +08:00
roll_deps.py was upgraded to Python3 in https://crrev.com/c/3521887. This changed the paths that are passed to the natives generation script to be absolute and no longer relative. To account for this, we no longer prepend the working directory to calculated paths. R=jobay@chromium.org Bug: None Change-Id: Ia0a0f946e27d61fa64e7856daef0f709fb058365 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3607830 Reviewed-by: Johan Bay <jobay@chromium.org> Commit-Queue: Simon Zünd <szuend@chromium.org>
97 lines
2.9 KiB
JavaScript
97 lines
2.9 KiB
JavaScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import * as fs from 'fs';
|
|
import glob from 'glob';
|
|
import ts from 'typescript';
|
|
import * as WebIDL2 from 'webidl2';
|
|
|
|
import {parseTSFunction, postProcess, walkRoot} from './helpers.js';
|
|
|
|
if (process.argv.length !== 4) {
|
|
throw new Error('Please provide path to chromium/src and devtools-frontend');
|
|
}
|
|
|
|
const chromiumSource = process.argv[2];
|
|
const typescriptSource = process.argv[3] + 'node_modules/typescript/lib/lib.esnext.d.ts';
|
|
|
|
const program = ts.createProgram([typescriptSource], {noLib: false, types: []});
|
|
|
|
for (const file of program.getSourceFiles()) {
|
|
ts.forEachChild(file, node => {
|
|
if (node.kind === ts.SyntaxKind.InterfaceDeclaration) {
|
|
for (const member of node.members) {
|
|
if (member.kind === ts.SyntaxKind.MethodSignature) {
|
|
parseTSFunction(member, node);
|
|
}
|
|
}
|
|
}
|
|
if (node.kind === ts.SyntaxKind.FunctionDeclaration) {
|
|
parseTSFunction(node, {name: {text: 'Window'}});
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
// Assume the DevTools front-end repository is at
|
|
// `devtools/devtools-frontend`, where `devtools` is on the same level
|
|
// as `chromium`. This matches `scripts/npm_test.js`.
|
|
const files =
|
|
glob.sync(`${chromiumSource}/third_party/blink/renderer/+(core|modules)/**/*.idl`, {cwd: process.env.PWD});
|
|
|
|
for (const file of files) {
|
|
if (file.includes('testing')) {
|
|
continue;
|
|
}
|
|
const data = fs.readFileSync(file, 'utf8');
|
|
const lines = data.split('\n');
|
|
const newLines = [];
|
|
for (const line of lines) {
|
|
if (!line.includes(' attribute ')) {
|
|
newLines.push(line);
|
|
}
|
|
}
|
|
|
|
try {
|
|
WebIDL2.parse(newLines.join('\n')).forEach(walkRoot);
|
|
} catch (e) {
|
|
// console.error(file);
|
|
}
|
|
|
|
// Source for Console spec: https://console.spec.whatwg.org/#idl-index
|
|
WebIDL2
|
|
.parse(`
|
|
[Exposed=(Window,Worker,Worklet)]
|
|
namespace console { // but see namespace object requirements below
|
|
// Logging
|
|
undefined assert(optional boolean condition = false, any... data);
|
|
undefined clear();
|
|
undefined debug(any... data);
|
|
undefined error(any... data);
|
|
undefined info(any... data);
|
|
undefined log(any... data);
|
|
undefined table(optional any tabularData, optional sequence<DOMString> properties);
|
|
undefined trace(any... data);
|
|
undefined warn(any... data);
|
|
undefined dir(optional any item, optional object? options);
|
|
undefined dirxml(any... data);
|
|
|
|
// Counting
|
|
undefined count(optional DOMString label = "default");
|
|
undefined countReset(optional DOMString label = "default");
|
|
|
|
// Grouping
|
|
undefined group(any... data);
|
|
undefined groupCollapsed(any... data);
|
|
undefined groupEnd();
|
|
|
|
// Timing
|
|
undefined time(optional DOMString label = "default");
|
|
undefined timeLog(optional DOMString label = "default", any... data);
|
|
undefined timeEnd(optional DOMString label = "default");
|
|
};
|
|
`).forEach(walkRoot);
|
|
}
|
|
postProcess();
|