Files
TanTan fa9c73363d
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
SnowLuma v2.4.2 source snapshot
2026-11-13 09:02:00 +08:00

25 lines
897 B
TypeScript

import ts from 'typescript';
import { ProtobufCompiler } from '../../src/compiler/compiler';
import { packageName } from '../../src/package';
export const imports = `import { protobuf_encode, protobuf_decode } from '${packageName}';`;
export function run(body: string): any {
const compiler = new ProtobufCompiler();
const source = imports + '\n' + body;
const transformed = compiler.compile(source, 'test-entry.ts') ?? source;
const js = ts.transpileModule(transformed, {
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS },
}).outputText;
const exports = {};
new Function('exports', 'require', js)(exports, () => ({
protobuf_encode() {
throw new Error('Uncompiled encode');
},
protobuf_decode() {
throw new Error('Uncompiled decode');
},
}));
return exports;
}