Files
jhonny-editor/bm/premiere-pro-mcp-main/scripts/generate-adobe-beta-transition-options-drift.mjs
T
João Henrique b541f502ba feat: initial commit - Jhonny Editor
- Adicionado estrutura completa do projeto
- Configurado MCP server para Premiere Pro
- Adicionado documentação e skills
- Configurado Gitignore para o projeto
2026-09-08 09:59:31 -04:00

34 lines
7.8 KiB
JavaScript
Executable File

import { createHash } from "node:crypto";
import { readFile, writeFile } from "node:fs/promises";
import { dirname, relative, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import ts from "typescript";
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const stablePath = process.env.PREMIERE_BETA_TRANSITION_OPTIONS_STABLE_DECLARATIONS_PATH ? resolve(process.env.PREMIERE_BETA_TRANSITION_OPTIONS_STABLE_DECLARATIONS_PATH) : resolve(root, "node_modules/@adobe/premierepro/src/premierepro.d.ts");
const betaPath = process.env.PREMIERE_BETA_TRANSITION_OPTIONS_BETA_DECLARATIONS_PATH ? resolve(process.env.PREMIERE_BETA_TRANSITION_OPTIONS_BETA_DECLARATIONS_PATH) : resolve(root, "node_modules/@adobe/premierepro-beta/src/premierepro.d.ts");
const outputPath = resolve(root, "src/resources/adobe-beta-transition-options-drift.json");
const normalize = (text) => text.replaceAll("\r\n", "\n").replace(/\s+/g, " ").trim();
const compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
const source = (text, path) => { const value = ts.createSourceFile(path, text, ts.ScriptTarget.Latest, true); if (value.parseDiagnostics.length) throw new Error(`Adobe AddTransitionOptions declaration parse failed: ${value.parseDiagnostics.map((item) => ts.flattenDiagnosticMessageText(item.messageText, " ")).join("; ")}`); return value; };
const type = (file, name) => { const value = file.statements.find((item) => ts.isTypeAliasDeclaration(item) && item.name.text === name); if (!value || !ts.isTypeLiteralNode(value.type)) throw new Error(`Adobe declarations must expose ${name} as a type literal.`); return value; };
const factories = (value, file, owner) => value.type.members.filter((item) => ts.isConstructSignatureDeclaration(item) || ts.isCallSignatureDeclaration(item)).map((item) => { if (!item.type) throw new Error(`Adobe ${owner} factory signature is missing a return type.`); return { symbol: `${owner}.${ts.isConstructSignatureDeclaration(item) ? "new" : "call"}`, kind: ts.isConstructSignatureDeclaration(item) ? "construct_signature" : "call_signature", signature: `(${item.parameters.map((parameter) => normalize(parameter.getText(file))).join(", ")}) => ${normalize(item.type.getText(file))}` }; }).sort((a, b) => compare(a.symbol, b.symbol));
const nonFactories = (value, file) => value.type.members.filter((item) => !ts.isConstructSignatureDeclaration(item) && !ts.isCallSignatureDeclaration(item)).map((item) => normalize(item.getText(file))).sort(compare);
const binding = (rootType, file) => { const member = rootType.type.members.find((item) => ts.isPropertySignature(item) && item.name && ts.isIdentifier(item.name) && item.name.text === "AddTransitionOptions"); if (!member?.type) throw new Error("Adobe declarations must expose premierepro.AddTransitionOptions as a typed property."); return { symbol: "premierepro.AddTransitionOptions", kind: "property", signature: normalize(member.type.getText(file)) }; };
const [stablePackageText, betaPackageText, stableText, betaText] = await Promise.all([readFile(resolve(root, "node_modules/@adobe/premierepro/package.json"), "utf8"), readFile(resolve(root, "node_modules/@adobe/premierepro-beta/package.json"), "utf8"), readFile(stablePath, "utf8"), readFile(betaPath, "utf8")]);
const stable = source(stableText, stablePath), beta = source(betaText, betaPath), stableRoot = type(stable, "premierepro"), betaRoot = type(beta, "premierepro"), stableOptions = type(stable, "AddTransitionOptions"), betaOptions = type(beta, "AddTransitionOptions"), betaStatic = type(beta, "AddTransitionOptionsStatic");
if (stable.statements.some((item) => ts.isTypeAliasDeclaration(item) && item.name.text === "AddTransitionOptionsStatic")) throw new Error("Pinned stable declarations unexpectedly expose AddTransitionOptionsStatic.");
const stableBinding = binding(stableRoot, stable), betaBinding = binding(betaRoot, beta);
if (stableBinding.signature !== "AddTransitionOptions") throw new Error("Pinned stable declarations must expose premierepro.AddTransitionOptions as AddTransitionOptions.");
if (betaBinding.signature !== "AddTransitionOptionsStatic") throw new Error("Adobe beta declarations must expose premierepro.AddTransitionOptions as AddTransitionOptionsStatic.");
const stableFactories = factories(stableOptions, stable, "AddTransitionOptions"), betaFactories = factories(betaStatic, beta, "AddTransitionOptionsStatic"), stableShapes = stableFactories.map(({ kind, signature }) => ({ kind, signature })), betaShapes = betaFactories.map(({ kind, signature }) => ({ kind, signature }));
if (stableFactories.length !== 2 || betaFactories.length !== 2 || JSON.stringify(stableShapes) !== JSON.stringify(betaShapes)) throw new Error("Adobe beta AddTransitionOptionsStatic factory signatures must match the pinned stable declaration.");
if (JSON.stringify(nonFactories(stableOptions, stable)) !== JSON.stringify(nonFactories(betaOptions, beta))) throw new Error("Adobe beta AddTransitionOptions non-factory members must match the pinned stable declaration.");
if (factories(betaOptions, beta, "AddTransitionOptions").length) throw new Error("Adobe beta AddTransitionOptions must not retain factory signatures after the static-type migration.");
const hash = (value, file) => createHash("sha256").update(normalize(value.getText(file))).digest("hex");
const inventory = { schemaVersion: 1, scope: { declarations: ["premierepro.AddTransitionOptions", "AddTransitionOptions", "AddTransitionOptionsStatic"], semantics: "This records the beta AddTransitionOptions factory-type migration against the pinned stable package. It is static declaration-drift accounting, not beta API support or a complete package diff.", mutationBoundary: "AddTransitionOptions configures transition application. This receipt intentionally does not construct options, create a transition action, or expose an MCP transition operation.", doesNotEstablish: "It does not prove a beta host exposes the static factory, that transition timing or alignment is accepted, that a transition is applied, or that any MCP action is supported or licensed-host validated." }, sources: { stable: { package: "@adobe/premierepro", version: JSON.parse(stablePackageText).version, declarations: relative(root, stablePath).replaceAll("\\", "/"), optionsDeclarationSha256: hash(stableOptions, stable), staticFactoryPresent: false }, beta: { package: "@adobe/premierepro-beta", version: JSON.parse(betaPackageText).version, declarations: relative(root, betaPath).replaceAll("\\", "/"), optionsDeclarationSha256: hash(betaOptions, beta), staticDeclarationSha256: hash(betaStatic, beta), staticFactoryPresent: true } }, diff: { betaOnly: [{ symbol: "AddTransitionOptionsStatic", kind: "type", signature: normalize(betaStatic.type.getText(beta)) }, ...betaFactories].sort((a, b) => compare(a.symbol, b.symbol)), stableOnly: [], changed: [{ symbol: "premierepro.AddTransitionOptions", stable: stableBinding, beta: betaBinding }, { symbol: "AddTransitionOptions.factorySignatures", stable: { owner: "AddTransitionOptions", entries: stableShapes }, beta: { owner: "AddTransitionOptionsStatic", entries: betaShapes } }] } };
const rendered = `${JSON.stringify(inventory, null, 2)}\n`;
if (process.argv.includes("--validate-only")) console.log("Validated Adobe beta AddTransitionOptions declaration drift.");
else if (process.argv.includes("--check")) { let current = ""; try { current = await readFile(outputPath, "utf8"); } catch {} if (current.replaceAll("\r\n", "\n") !== rendered) { console.error("Adobe beta AddTransitionOptions declaration drift inventory is stale. Run npm run adobe:beta-transition-options-drift."); process.exitCode = 1; } else console.log("Adobe beta AddTransitionOptions declaration drift inventory is current: 3 beta-only and 2 changed symbols."); }
else { await writeFile(outputPath, rendered); console.log("Wrote Adobe beta AddTransitionOptions declaration drift inventory: 3 beta-only and 2 changed symbols."); }