Migrate Harbor state and traffic history to SQLite
This commit is contained in:
@@ -349,7 +349,7 @@ function bindCallParameters(callable, argumentsList, callerEnvironment, callerFi
|
||||
return environment;
|
||||
}
|
||||
|
||||
export function createStyleWitnesses(sources, { entry = 'App' } = {}) {
|
||||
export function createStyleWitnesses(sources, { entry = 'App', recursionLimits = {} } = {}) {
|
||||
const files = sources.map(({ file, source }) => ({ file, source, parsed: parseWitnessFile(file, source) }));
|
||||
const { definitions, definitionNodes } = componentDefinitions(files);
|
||||
const entryDefinition = definitions.get(entry);
|
||||
@@ -361,7 +361,11 @@ export function createStyleWitnesses(sources, { entry = 'App' } = {}) {
|
||||
const dynamicByFile = dynamicClassBindings(files);
|
||||
const witnesses = [];
|
||||
const expand = (definition, ancestors, ancestorUnknown, environment, stack) => {
|
||||
if (stack.includes(definition)) throw new TypeError(`Recursive JSX witness component: ${definition.node.id?.name || definition.file}`);
|
||||
if (stack.includes(definition)) {
|
||||
const limit = recursionLimits[definition.node.id?.name];
|
||||
if (!Number.isInteger(limit) || limit < 1) throw new TypeError(`Recursive JSX witness component: ${definition.node.id?.name || definition.file}`);
|
||||
if (stack.filter((item) => item === definition).length >= limit) return;
|
||||
}
|
||||
const nextStack = [...stack, definition];
|
||||
const entryEnvironment = withLocalJsxBindings(definition.node.body, environment, definitionNodes, definition.file);
|
||||
const visit = (
|
||||
@@ -474,7 +478,8 @@ export function readStyleWitnesses(root) {
|
||||
file,
|
||||
source: fs.readFileSync(file, 'utf8'),
|
||||
}));
|
||||
return createStyleWitnesses(files);
|
||||
// History has exactly service/domain/hostname/IP levels, not arbitrary JSX recursion.
|
||||
return createStyleWitnesses(files, { recursionLimits: { HistoryRows: 4, HistoryBranch: 3 } });
|
||||
}
|
||||
|
||||
const OBSERVED_PROPERTIES = new Set(`
|
||||
|
||||
Reference in New Issue
Block a user