Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
perf(webv2): prime the whole tree in the architecture artifact generators
joshistoastc01544f05d3f
diff --git a/invokeai/frontend/webv2/scripts/write-canvas-import-matrix.mjs b/invokeai/frontend/webv2/scripts/write-canvas-import-matrix.mjsindex 03d5666cf5..34da7c4a98 100644--- a/invokeai/frontend/webv2/scripts/write-canvas-import-matrix.mjs+++ b/invokeai/frontend/webv2/scripts/write-canvas-import-matrix.mjs@@ -7,7 +7,7 @@ import {isStringLiteralLikeNode,} from 'typescript/unstable/ast';-import { parseSource } from './parse-source.mjs';+import { parseSource, primeSources } from './parse-source.mjs';const packageRoot = process.cwd();const sourceRoot = resolve(packageRoot, 'src');@@ -104,12 +104,16 @@ const importedSymbols = (clause) => {return symbols.sort();};+const scanned = new Map(+ paths+ .filter((path) => isProduction(path) && !isCanvasOwned(path))+ .map((path) => [path, readFileSync(resolve(sourceRoot, path), 'utf8')])+);+// Load the whole tree in one snapshot; parsing file by file costs a round trip each.+primeSources(scanned);+const imports = [];-for (const source of paths.filter(isProduction)) {- if (isCanvasOwned(source)) {- continue;- }- const text = readFileSync(resolve(sourceRoot, source), 'utf8');+for (const [source, text] of scanned) {const file = parseSource(source, text);for (const statement of file.statements) {if (!isImportDeclaration(statement) || !isStringLiteralLikeNode(statement.moduleSpecifier)) {diff --git a/invokeai/frontend/webv2/scripts/write-contract-caller-matrix.mjs b/invokeai/frontend/webv2/scripts/write-contract-caller-matrix.mjsindex b98b71aab9..7870b63771 100644--- a/invokeai/frontend/webv2/scripts/write-contract-caller-matrix.mjs+++ b/invokeai/frontend/webv2/scripts/write-contract-caller-matrix.mjs@@ -11,7 +11,7 @@ import {ModifierFlags,} from 'typescript/unstable/ast';-import { parseSource } from './parse-source.mjs';+import { parseSource, primeSources } from './parse-source.mjs';const packageRoot = process.cwd();const sourceRoot = resolve(packageRoot, 'src');@@ -25,6 +25,8 @@ const paths = readdirSync(sourceRoot, { recursive: true, withFileTypes: true }).filter(isTypeScript).sort();const sources = new Map(paths.map((path) => [path, readFileSync(resolve(sourceRoot, path), 'utf8')]));+// Load the whole tree in one snapshot; parsing file by file costs a round trip each.+primeSources(sources);const pathByStem = new Map(paths.map((path) => [stripExtension(path), path]));const aliases = [['@app', 'app'],diff --git a/invokeai/frontend/webv2/scripts/write-workbench-ownership-inventory.mjs b/invokeai/frontend/webv2/scripts/write-workbench-ownership-inventory.mjsindex 3c8cbdf088..2137b75207 100644--- a/invokeai/frontend/webv2/scripts/write-workbench-ownership-inventory.mjs+++ b/invokeai/frontend/webv2/scripts/write-workbench-ownership-inventory.mjs@@ -18,7 +18,7 @@ import {SyntaxKind,} from 'typescript/unstable/ast';-import { parseSource } from './parse-source.mjs';+import { parseSource, primeSources } from './parse-source.mjs';const packageRoot = process.cwd();const sourceRoot = resolve(packageRoot, 'src');@@ -34,6 +34,8 @@ const paths = readdirSync(sourceRoot, { recursive: true, withFileTypes: true }).sort();const productionPaths = paths.filter((path) => !isTest(path));const sources = new Map(productionPaths.map((path) => [path, readFileSync(resolve(sourceRoot, path), 'utf8')]));+// Load the whole tree in one snapshot; parsing file by file costs a round trip each.+primeSources(sources, { jsx: true });const pathByStem = new Map(productionPaths.map((path) => [stripExtension(path), path]));const aliases = [