@bitfab/sdk 0.76.5 → 0.76.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{autoTrace-pZKu5Nk2.cjs → autoTrace-BtiEpHTN.cjs} +76 -4
- package/dist/autoTrace-BtiEpHTN.cjs.map +1 -0
- package/dist/{autoTrace-BgN0zCQf.js → autoTrace-RWUOk1WF.js} +47 -5
- package/dist/autoTrace-RWUOk1WF.js.map +1 -0
- package/dist/autoTrace.cjs +1 -1
- package/dist/autoTrace.js +1 -1
- package/dist/{babelPlugin-tupc_WZS.js → babelPlugin-398AO0eD.js} +6 -2
- package/dist/babelPlugin-398AO0eD.js.map +1 -0
- package/dist/{babelPlugin-C4ERQ8DW.cjs → babelPlugin-Btzkfl62.cjs} +6 -2
- package/dist/babelPlugin-Btzkfl62.cjs.map +1 -0
- package/dist/{http-BXQZC6_Y.cjs → http-7FhAoWen.cjs} +3 -3
- package/dist/{http-BXQZC6_Y.cjs.map → http-7FhAoWen.cjs.map} +1 -1
- package/dist/{http-BLyaXOOY.js → http-DoS4PUm6.js} +3 -3
- package/dist/{http-BLyaXOOY.js.map → http-DoS4PUm6.js.map} +1 -1
- package/dist/{index-QVRAlE4o.d.cts → index-C-3LPlPg.d.cts} +58 -2
- package/dist/{index-QVRAlE4o.d.ts → index-C-3LPlPg.d.ts} +58 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/node.cjs +3 -3
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +3 -3
- package/dist/{registryCommand-M1u4H9PI.js → registryCommand-D9EkYtKh.js} +34 -3
- package/dist/registryCommand-D9EkYtKh.js.map +1 -0
- package/dist/replayCli.js +1 -1
- package/dist/seedCli.js +1 -1
- package/dist/{src-CWmTGb52.cjs → src-C0Mz9eoA.cjs} +119 -62
- package/dist/src-C0Mz9eoA.cjs.map +1 -0
- package/dist/{src-B_e7xNzm.js → src-Cm9Jdgfh.js} +119 -62
- package/dist/src-Cm9Jdgfh.js.map +1 -0
- package/dist/transform/babel.cjs +1 -1
- package/dist/transform/babel.js +1 -1
- package/dist/transform/loaderRuntime.cjs +2 -2
- package/dist/transform/loaderRuntime.js +2 -2
- package/dist/transform/nodeLoader.js +5 -1
- package/dist/transform/nodeLoader.js.map +1 -1
- package/dist/transform/swc.cjs +1 -1
- package/dist/transform/swc.js +1 -1
- package/dist/transform/unplugin.cjs +2 -2
- package/dist/transform/unplugin.js +2 -2
- package/dist/{transform-mb6EwHsJ.js → transform-BBlyY-tA.js} +2 -2
- package/dist/{transform-mb6EwHsJ.js.map → transform-BBlyY-tA.js.map} +1 -1
- package/dist/{transform-CcNCVr8A.cjs → transform-CclhVghC.cjs} +2 -2
- package/dist/{transform-CcNCVr8A.cjs.map → transform-CclhVghC.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/autoTrace-BgN0zCQf.js.map +0 -1
- package/dist/autoTrace-pZKu5Nk2.cjs.map +0 -1
- package/dist/babelPlugin-C4ERQ8DW.cjs.map +0 -1
- package/dist/babelPlugin-tupc_WZS.js.map +0 -1
- package/dist/registryCommand-M1u4H9PI.js.map +0 -1
- package/dist/src-B_e7xNzm.js.map +0 -1
- package/dist/src-CWmTGb52.cjs.map +0 -1
package/dist/transform/babel.cjs
CHANGED
|
@@ -2,5 +2,5 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_babelPlugin = require("../babelPlugin-
|
|
5
|
+
const require_babelPlugin = require("../babelPlugin-Btzkfl62.cjs");
|
|
6
6
|
exports.default = require_babelPlugin.bitfabBabelPlugin;
|
package/dist/transform/babel.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "../babelPlugin-
|
|
1
|
+
export { t as default } from "../babelPlugin-398AO0eD.js";
|
|
@@ -24,8 +24,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
enumerable: true
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
//#endregion
|
|
27
|
-
const require_babelPlugin = require("../babelPlugin-
|
|
28
|
-
const require_transform = require("../transform-
|
|
27
|
+
const require_babelPlugin = require("../babelPlugin-Btzkfl62.cjs");
|
|
28
|
+
const require_transform = require("../transform-CclhVghC.cjs");
|
|
29
29
|
let path = require("path");
|
|
30
30
|
let _babel_core = require("@babel/core");
|
|
31
31
|
let _babel_plugin_proposal_decorators = require("@babel/plugin-proposal-decorators");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as sourceFilename, r as shouldTransformBitfabFile, t as bitfabBabelPlugin } from "../babelPlugin-
|
|
2
|
-
import { t as parserPlugins } from "../transform-
|
|
1
|
+
import { i as sourceFilename, r as shouldTransformBitfabFile, t as bitfabBabelPlugin } from "../babelPlugin-398AO0eD.js";
|
|
2
|
+
import { t as parserPlugins } from "../transform-BBlyY-tA.js";
|
|
3
3
|
import { dirname } from "path";
|
|
4
4
|
import { transformFromAstSync, transformSync } from "@babel/core";
|
|
5
5
|
import decoratorsPlugin from "@babel/plugin-proposal-decorators";
|
|
@@ -283,7 +283,11 @@ const RECORDED_CLIENT_CALLS = [
|
|
|
283
283
|
{
|
|
284
284
|
...CLIENT_CALL_RUNTIME,
|
|
285
285
|
endpoint: "models",
|
|
286
|
-
methods: [
|
|
286
|
+
methods: [
|
|
287
|
+
"generateContent",
|
|
288
|
+
"generateContentStream",
|
|
289
|
+
"embedContent"
|
|
290
|
+
],
|
|
287
291
|
matchesReceiver: isModelsReceiver
|
|
288
292
|
}
|
|
289
293
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeLoader.js","names":["resolvePath"],"sources":["../../../bitfab-typescript-transform/src/transformOptions.ts","../../../bitfab-typescript-transform/src/babelPlugin.ts","../../../bitfab-typescript-transform/src/transform.ts","../../../bitfab-typescript-transform/src/loaderRuntime.ts","../../../bitfab-typescript-transform/src/nodeLoader.ts"],"sourcesContent":["export interface BitfabTransformOptions {\n /** Module that exports the automatic span runtime. */\n runtimeModule?: string\n /** Module imported at the top of BAML's generated client files so the SDK can use the `@boundaryml/baml` the bundler loads. Pass `false` to import nothing. Defaults to `\"@bitfab/sdk/baml\"`, added only when it resolves from the file's folder. */\n bamlRegistrationModule?: string | false\n /** Working directory removed from generated function IDs. */\n cwd?: string\n /** Return false to leave a file unchanged. */\n include?: (filename: string) => boolean\n}\n\nconst AUTO_TRACE_FUNCTION_ID_VERSION = \"ts-auto-v1\"\nexport const AUTO_TRACE_TRANSFORM_MARKER =\n \"__bitfab_auto_trace_transformed_v1__\"\n\nexport function autoTraceFunctionId(file: string, name: string): string {\n return `${AUTO_TRACE_FUNCTION_ID_VERSION}:${file}#${name}`\n}\n\nexport function sourceFilename(filename: string): string {\n return filename.replace(/\\\\/g, \"/\").split(/[?#]/, 1)[0] ?? \"\"\n}\n\nexport function autoTraceFilename(filename: string, cwd: string): string {\n const normalized = sourceFilename(filename)\n const normalizedCwd = cwd.replace(/\\\\/g, \"/\").replace(/\\/$/, \"\")\n return normalized.startsWith(`${normalizedCwd}/`)\n ? normalized.slice(normalizedCwd.length + 1)\n : normalized\n}\n\nexport function shouldTransformBitfabFile(\n filename: string,\n options: BitfabTransformOptions,\n): boolean {\n if (!filename) {\n return false\n }\n if (options.include && !options.include(filename)) {\n return false\n }\n\n const normalized = sourceFilename(filename)\n const normalizedCwd = options.cwd?.replace(/\\\\/g, \"/\").replace(/\\/$/, \"\")\n const isAbsolute =\n normalized.startsWith(\"/\") || /^[A-Za-z]:\\//.test(normalized)\n if (\n normalizedCwd &&\n isAbsolute &&\n normalized !== normalizedCwd &&\n !normalized.startsWith(`${normalizedCwd}/`)\n ) {\n return false\n }\n return (\n !normalized.includes(\"/node_modules/\") &&\n !normalized.endsWith(\".d.ts\") &&\n /\\.[cm]?[jt]sx?$/.test(normalized)\n )\n}\n","import { readFileSync } from \"node:fs\"\nimport { dirname, isAbsolute, join } from \"node:path\"\nimport type { NodePath, PluginObject, PluginPass } from \"@babel/core\"\nimport type * as BabelTypes from \"@babel/types\"\nimport type { BitfabTransformOptions } from \"./transformOptions.js\"\nimport {\n AUTO_TRACE_TRANSFORM_MARKER,\n autoTraceFilename,\n autoTraceFunctionId,\n shouldTransformBitfabFile,\n sourceFilename,\n} from \"./transformOptions.js\"\n\ntype BabelTypesApi = typeof BabelTypes\n\ntype BitfabPluginOptions = BitfabTransformOptions\n\ninterface BitfabPluginState extends PluginPass {\n opts: BitfabPluginOptions\n runtimeIdentifier?: ReturnType<BabelTypesApi[\"identifier\"]>\n activeIdentifier?: ReturnType<BabelTypesApi[\"identifier\"]>\n wrapperIdentifier?: ReturnType<BabelTypesApi[\"identifier\"]>\n recordedCallIdentifiers?: Map<string, ReturnType<BabelTypesApi[\"identifier\"]>>\n definitions?: Array<ReturnType<BabelTypesApi[\"variableDeclaration\"]>>\n skipFile?: boolean\n bamlGenerated?: boolean\n usedRuntime?: boolean\n usedWrapper?: boolean\n usedRecordedCalls?: Set<string>\n}\n\ninterface InstrumentedFunction {\n _bitfabInstrumented?: boolean\n}\n\nfunction propertyName(\n node: BabelTypes.Node | null | undefined,\n types: BabelTypesApi,\n): string | null {\n if (types.isIdentifier(node)) {\n return node.name\n }\n if (types.isStringLiteral(node)) {\n return node.value\n }\n return null\n}\n\nfunction functionName(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): string {\n const node = path.node\n if (types.isFunctionDeclaration(node) || types.isFunctionExpression(node)) {\n if (node.id) {\n return node.id.name\n }\n }\n\n if (\n (types.isClassMethod(node) || types.isObjectMethod(node)) &&\n !node.computed &&\n types.isIdentifier(node.key)\n ) {\n return node.key.name\n }\n\n const parent = path.parentPath?.node\n if (types.isVariableDeclarator(parent)) {\n return propertyName(parent.id, types) ?? \"anonymous\"\n }\n if (types.isObjectProperty(parent) && !parent.computed) {\n return propertyName(parent.key, types) ?? \"anonymous\"\n }\n if (types.isClassProperty(parent) && !parent.computed) {\n const name = propertyName(parent.key, types)\n if (name) {\n return name\n }\n }\n\n const { line, column } = sourcePosition(path)\n return `anonymous-${line}-${column}`\n}\n\nconst JEV_METHOD = \"systemOne\"\n\nfunction isJevMethodDefinition(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): boolean {\n const parent = path.parentPath?.node\n const isMethod =\n types.isClassMethod(path.node) ||\n types.isObjectMethod(path.node) ||\n types.isObjectProperty(parent) ||\n types.isClassProperty(parent)\n return isMethod && functionName(path, types) === JEV_METHOD\n}\n\nfunction isInstrumentableFunction(\n node: BabelTypes.Function,\n types: BabelTypesApi,\n): boolean {\n if (node.generator || types.isClassPrivateMethod(node)) {\n return false\n }\n return (\n !(types.isClassMethod(node) || types.isObjectMethod(node)) ||\n node.kind === \"method\"\n )\n}\n\nfunction sourcePosition(path: NodePath<BabelTypes.Function>): {\n line: number\n column: number\n} {\n const exportDeclaration = path.parentPath?.isExportDeclaration()\n ? path.parentPath.node\n : undefined\n const start = (exportDeclaration ?? path.node).loc?.start\n return { line: start?.line ?? 0, column: start?.column ?? 0 }\n}\n\nfunction qualifiedFunctionName(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): string {\n const ownName = functionName(path, types)\n if (ownName.startsWith(\"anonymous-\")) {\n return ownName\n }\n const scopes: string[] = []\n let ancestor: NodePath | null = path.parentPath\n while (ancestor) {\n if (ancestor.isFunction()) {\n if (!isInstrumentableFunction(ancestor.node, types)) {\n ancestor = ancestor.parentPath\n continue\n }\n const name = functionName(\n ancestor as NodePath<BabelTypes.Function>,\n types,\n )\n if (!name.startsWith(\"anonymous-\")) {\n scopes.unshift(name)\n }\n } else if (\n (ancestor.isClassDeclaration() || ancestor.isClassExpression()) &&\n ancestor.node.id\n ) {\n scopes.unshift(ancestor.node.id.name)\n } else if (ancestor.isObjectExpression()) {\n const parent = ancestor.parentPath?.node\n if (types.isVariableDeclarator(parent)) {\n const name = propertyName(parent.id, types)\n if (name) {\n scopes.unshift(name)\n }\n } else if (types.isObjectProperty(parent) && !parent.computed) {\n const name = propertyName(parent.key, types)\n if (name) {\n scopes.unshift(name)\n }\n }\n }\n ancestor = ancestor.parentPath\n }\n return [...scopes, ownName].join(\".\")\n}\n\nfunction isTraceDecoratorRoot(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): boolean {\n const node = path.node\n const parent = path.parentPath?.node\n const decorated =\n types.isClassMethod(node) || types.isClassPrivateMethod(node)\n ? node\n : types.isClassProperty(parent) && parent.value === node\n ? parent\n : null\n if (!decorated) {\n return false\n }\n\n return (\n decorated.decorators?.some((decorator) => {\n const expression = decorator.expression\n if (!types.isCallExpression(expression)) {\n return false\n }\n const callee = expression.callee\n return (\n types.isMemberExpression(callee) &&\n !callee.computed &&\n types.isIdentifier(callee.property, { name: \"trace\" })\n )\n }) ?? false\n )\n}\n\nfunction withNodeFunctionName(\n path: NodePath<BabelTypes.CallExpression>,\n types: BabelTypesApi,\n): string | null {\n if (path.node.arguments.length > 2) {\n return null\n }\n const callee = path.node.callee\n if (\n !types.isMemberExpression(callee) ||\n callee.computed ||\n !types.isIdentifier(callee.property, { name: \"withNode\" })\n ) {\n return null\n }\n const fn = path.node.arguments[path.node.arguments.length - 1]\n if (types.isIdentifier(fn)) {\n return fn.name\n }\n if (types.isMemberExpression(fn) && !fn.computed) {\n return propertyName(fn.property, types)\n }\n if (types.isFunctionExpression(fn) && fn.id) {\n return fn.id.name\n }\n return null\n}\n\nconst BAML_GENERATED_HEADER = \"This file was generated by BAML\"\nconst BAML_CLIENT_CLASSES = new Set([\"BamlAsyncClient\", \"BamlSyncClient\"])\nconst BAML_OPTIONS_PARAMETER = \"__baml_options__\"\n\nconst BAML_PACKAGE = \"@boundaryml/baml\"\nconst DEFAULT_BAML_REGISTRATION_MODULE = \"@bitfab/sdk/baml\"\n\nfunction importsBamlAtRuntime(\n program: BabelTypes.Program,\n types: BabelTypesApi,\n): boolean {\n return program.body.some(\n (statement) =>\n types.isImportDeclaration(statement) &&\n statement.source.value === BAML_PACKAGE &&\n statement.importKind !== \"type\" &&\n statement.specifiers.some(\n (specifier) =>\n !types.isImportSpecifier(specifier) ||\n specifier.importKind !== \"type\",\n ),\n )\n}\n\nconst SDK_PACKAGE_PATH = [\"node_modules\", \"@bitfab\", \"sdk\", \"package.json\"]\nconst BAML_REGISTRATION_EXPORT = \"./baml\"\nconst sdkExportsBamlRegistrationByDirectory = new Map<string, boolean>()\n\nfunction readPackageJson(path: string): unknown {\n try {\n return JSON.parse(readFileSync(path, \"utf8\"))\n } catch {\n return undefined\n }\n}\n\nfunction exportsBamlRegistration(packageJson: unknown): boolean {\n if (typeof packageJson !== \"object\" || packageJson === null) {\n return false\n }\n const exports = (packageJson as { exports?: unknown }).exports\n return (\n typeof exports === \"object\" &&\n exports !== null &&\n BAML_REGISTRATION_EXPORT in exports\n )\n}\n\nfunction nearestSdkExportsBamlRegistration(directory: string): boolean {\n const cached = sdkExportsBamlRegistrationByDirectory.get(directory)\n if (cached !== undefined) {\n return cached\n }\n const packageJson = readPackageJson(join(directory, ...SDK_PACKAGE_PATH))\n const parent = dirname(directory)\n const exported =\n packageJson !== undefined\n ? exportsBamlRegistration(packageJson)\n : parent !== directory && nearestSdkExportsBamlRegistration(parent)\n sdkExportsBamlRegistrationByDirectory.set(directory, exported)\n return exported\n}\n\nfunction defaultRegistrationResolves(filename: string): boolean {\n return (\n isAbsolute(filename) && nearestSdkExportsBamlRegistration(dirname(filename))\n )\n}\n\nfunction bamlRegistrationModuleFor(\n filename: string,\n configured: string | false | undefined,\n): string | null {\n if (configured === false) {\n return null\n }\n if (configured !== undefined) {\n return configured\n }\n return defaultRegistrationResolves(filename)\n ? DEFAULT_BAML_REGISTRATION_MODULE\n : null\n}\n\nfunction isBamlGeneratedSource(code: string): boolean {\n return code.slice(0, 4096).includes(BAML_GENERATED_HEADER)\n}\n\nfunction isBamlClientMethod(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): boolean {\n const node = path.node\n if (!types.isClassMethod(node) || node.kind !== \"method\" || node.static) {\n return false\n }\n const classPath = path.parentPath?.parentPath\n if (\n !classPath ||\n !(classPath.isClassDeclaration() || classPath.isClassExpression()) ||\n !classPath.node.id ||\n !BAML_CLIENT_CLASSES.has(classPath.node.id.name)\n ) {\n return false\n }\n const parameters = runtimeParameters(node, types)\n const last = parameters[parameters.length - 1]\n return types.isIdentifier(last, { name: BAML_OPTIONS_PARAMETER })\n}\n\nfunction bamlOptionsDeclaration(\n callerOptions: BabelTypes.Identifier,\n withCollector: BabelTypes.Identifier,\n types: BabelTypesApi,\n): BabelTypes.VariableDeclaration {\n return types.variableDeclaration(\"const\", [\n types.variableDeclarator(\n types.identifier(BAML_OPTIONS_PARAMETER),\n types.conditionalExpression(\n types.binaryExpression(\n \"===\",\n types.cloneNode(withCollector),\n types.identifier(\"undefined\"),\n ),\n types.cloneNode(callerOptions),\n types.callExpression(types.cloneNode(withCollector), [\n types.cloneNode(callerOptions),\n types.memberExpression(\n types.thisExpression(),\n types.identifier(\"bamlOptions\"),\n ),\n ]),\n ),\n ),\n ])\n}\n\nfunction runtimeParameters(\n node: BabelTypes.Function,\n types: BabelTypesApi,\n): BabelTypes.Function[\"params\"] {\n return node.params.filter(\n (parameter) => !types.isIdentifier(parameter, { name: \"this\" }),\n )\n}\n\nfunction parameterInputs(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): ReturnType<BabelTypesApi[\"arrayExpression\"]> {\n const elements: Array<BabelTypes.Expression | BabelTypes.SpreadElement> = []\n\n for (const [index, parameter] of runtimeParameters(\n path.node,\n types,\n ).entries()) {\n if (!types.isArrowFunctionExpression(path.node)) {\n if (types.isRestElement(parameter)) {\n elements.push(\n types.spreadElement(\n types.callExpression(\n types.memberExpression(\n types.arrayExpression([\n types.spreadElement(types.identifier(\"arguments\")),\n ]),\n types.identifier(\"slice\"),\n ),\n [types.numericLiteral(index)],\n ),\n ),\n )\n } else {\n elements.push(\n types.memberExpression(\n types.identifier(\"arguments\"),\n types.numericLiteral(index),\n true,\n ),\n )\n }\n continue\n }\n\n if (types.isIdentifier(parameter)) {\n elements.push(types.identifier(parameter.name))\n } else if (\n types.isRestElement(parameter) &&\n types.isIdentifier(parameter.argument)\n ) {\n elements.push(\n types.spreadElement(types.identifier(parameter.argument.name)),\n )\n }\n }\n\n return types.arrayExpression(elements)\n}\n\nfunction needsArgumentWrapper(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): boolean {\n return (\n types.isArrowFunctionExpression(path.node) &&\n path.node.params.some(\n (parameter) =>\n !types.isIdentifier(parameter) &&\n !(\n types.isRestElement(parameter) &&\n types.isIdentifier(parameter.argument)\n ),\n )\n )\n}\n\nfunction isRestWrapper(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): boolean {\n const parameters = runtimeParameters(path.node, types)\n return parameters.length === 1 && types.isRestElement(parameters[0])\n}\n\ntype RecordedCallNode =\n | BabelTypes.CallExpression\n | BabelTypes.OptionalCallExpression\n\ninterface RecordedClientCall {\n methods: readonly string[]\n endpoint?: string\n runtimeExport: string\n identifierHint: string\n receiverHint: string\n matchesReceiver: (\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n ) => boolean\n}\n\nfunction isNamedMember(\n node: BabelTypes.Node,\n name: string,\n types: BabelTypesApi,\n): node is BabelTypes.MemberExpression | BabelTypes.OptionalMemberExpression {\n return (\n (types.isMemberExpression(node) ||\n types.isOptionalMemberExpression(node)) &&\n !node.computed &&\n types.isIdentifier(node.property, { name })\n )\n}\n\nfunction isChatCompletionsReceiver(\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n): boolean {\n return (\n isNamedMember(receiver, \"completions\", types) &&\n isNamedMember(receiver.object, \"chat\", types)\n )\n}\n\nfunction isMessagesReceiver(\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n): boolean {\n return (\n isNamedMember(receiver, \"messages\", types) &&\n !isNamedMember(receiver.object, \"beta\", types)\n )\n}\n\nfunction isResponsesReceiver(\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n): boolean {\n return isNamedMember(receiver, \"responses\", types)\n}\n\nfunction isEmbeddingsReceiver(\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n): boolean {\n return isNamedMember(receiver, \"embeddings\", types)\n}\n\nfunction isTranscriptionsReceiver(\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n): boolean {\n return (\n isNamedMember(receiver, \"transcriptions\", types) &&\n isNamedMember(receiver.object, \"audio\", types)\n )\n}\n\nfunction isModelsReceiver(\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n): boolean {\n return isNamedMember(receiver, \"models\", types)\n}\n\nconst CLIENT_CALL_RUNTIME = {\n runtimeExport: \"__bitfabAutoClientCall\",\n identifierHint: \"bitfabAutoClientCall\",\n receiverHint: \"bitfabClientCallReceiver\",\n}\n\nconst RECORDED_CLIENT_CALLS: readonly RecordedClientCall[] = [\n {\n methods: [JEV_METHOD],\n runtimeExport: \"__bitfabAutoJev\",\n identifierHint: \"bitfabAutoJev\",\n receiverHint: \"bitfabJevReceiver\",\n matchesReceiver: () => true,\n },\n {\n ...CLIENT_CALL_RUNTIME,\n endpoint: \"chat.completions\",\n methods: [\"create\", \"parse\", \"stream\"],\n matchesReceiver: isChatCompletionsReceiver,\n },\n {\n ...CLIENT_CALL_RUNTIME,\n endpoint: \"embeddings\",\n methods: [\"create\"],\n matchesReceiver: isEmbeddingsReceiver,\n },\n {\n ...CLIENT_CALL_RUNTIME,\n endpoint: \"audio.transcriptions\",\n methods: [\"create\"],\n matchesReceiver: isTranscriptionsReceiver,\n },\n {\n ...CLIENT_CALL_RUNTIME,\n endpoint: \"messages\",\n methods: [\"create\", \"parse\", \"stream\"],\n matchesReceiver: isMessagesReceiver,\n },\n {\n ...CLIENT_CALL_RUNTIME,\n endpoint: \"responses\",\n methods: [\"create\", \"parse\", \"stream\"],\n matchesReceiver: isResponsesReceiver,\n },\n {\n ...CLIENT_CALL_RUNTIME,\n endpoint: \"models\",\n methods: [\"generateContent\", \"generateContentStream\"],\n matchesReceiver: isModelsReceiver,\n },\n]\n\nconst RECORDED_CALL_RUNTIMES = [\n ...new Map(\n RECORDED_CLIENT_CALLS.map((call) => [call.runtimeExport, call]),\n ).values(),\n]\n\nfunction recordedCallTarget(\n node: RecordedCallNode,\n types: BabelTypesApi,\n): {\n call: RecordedClientCall\n receiver: BabelTypes.Expression\n method: string\n} | null {\n const callee = node.callee\n if (\n !(\n types.isMemberExpression(callee) ||\n types.isOptionalMemberExpression(callee)\n ) ||\n callee.computed ||\n !types.isIdentifier(callee.property) ||\n types.isSuper(callee.object)\n ) {\n return null\n }\n const method = callee.property.name\n const receiver = callee.object\n const call = RECORDED_CLIENT_CALLS.find(\n (candidate) =>\n candidate.methods.includes(method) &&\n candidate.matchesReceiver(receiver, types),\n )\n return call === undefined ? null : { call, receiver, method }\n}\n\nfunction isOptionalChain(node: BabelTypes.Node, types: BabelTypesApi): boolean {\n return (\n types.isOptionalMemberExpression(node) ||\n types.isOptionalCallExpression(node)\n )\n}\n\nfunction continuesOptionalChain(\n path: NodePath<BabelTypes.OptionalCallExpression>,\n types: BabelTypesApi,\n): boolean {\n const parent = path.parent\n return (\n (types.isOptionalMemberExpression(parent) && parent.object === path.node) ||\n (types.isOptionalCallExpression(parent) && parent.callee === path.node)\n )\n}\n\nfunction rewriteRecordedClientCall(\n path: NodePath<RecordedCallNode>,\n state: BitfabPluginState,\n types: BabelTypesApi,\n): void {\n if (state.skipFile || state.bamlGenerated) {\n return\n }\n const node = path.node\n const target = recordedCallTarget(node, types)\n const identifier =\n target === null\n ? undefined\n : state.recordedCallIdentifiers?.get(target.call.runtimeExport)\n if (target === null || identifier === undefined) {\n return\n }\n const { call: recordedCall, receiver, method } = target\n const optionalReceiver =\n types.isOptionalMemberExpression(node.callee) && node.callee.optional\n const optionalMethod = types.isOptionalCallExpression(node) && node.optional\n if (types.isOptionalCallExpression(node)) {\n if (\n continuesOptionalChain(\n path as NodePath<BabelTypes.OptionalCallExpression>,\n types,\n ) ||\n (!optionalReceiver && isOptionalChain(receiver, types))\n ) {\n return\n }\n }\n const guarded = optionalReceiver || optionalMethod\n const receiverReference =\n guarded && !path.scope.isStatic(receiver)\n ? path.scope.generateDeclaredUidIdentifier(recordedCall.receiverHint)\n : null\n const receiverValue = (): BabelTypes.Expression =>\n receiverReference === null\n ? types.cloneNode(receiver)\n : types.cloneNode(receiverReference)\n const call = types.callExpression(\n types.cloneNode(identifier),\n recordedCall.endpoint === undefined\n ? [receiverValue(), ...node.arguments]\n : [\n types.stringLiteral(recordedCall.endpoint),\n receiverValue(),\n types.stringLiteral(method),\n ...node.arguments,\n ],\n )\n state.usedRuntime = true\n state.usedRecordedCalls?.add(recordedCall.runtimeExport)\n if (!guarded) {\n path.replaceWith(call)\n return\n }\n const firstReceiver =\n receiverReference === null\n ? types.cloneNode(receiver)\n : types.assignmentExpression(\n \"=\",\n types.cloneNode(receiverReference),\n receiver,\n )\n const missing = (value: BabelTypes.Expression): BabelTypes.BinaryExpression =>\n types.binaryExpression(\"==\", value, types.nullLiteral())\n const methodOf = (value: BabelTypes.Expression): BabelTypes.Expression =>\n types.memberExpression(value, types.identifier(method))\n const test = optionalReceiver\n ? optionalMethod\n ? types.logicalExpression(\n \"||\",\n missing(firstReceiver),\n missing(methodOf(receiverValue())),\n )\n : missing(firstReceiver)\n : missing(methodOf(firstReceiver))\n path.replaceWith(\n types.conditionalExpression(\n test,\n types.unaryExpression(\"void\", types.numericLiteral(0)),\n call,\n ),\n )\n}\n\n/**\n * Babel adapter for Bitfab's experimental automatic call-span runtime.\n *\n * @experimental The transform protocol and generated function identities may\n * change before the feature is stable.\n */\nexport default function bitfabBabelPlugin(api: {\n types: BabelTypesApi\n}): PluginObject<BitfabPluginState> {\n const { types } = api\n\n return {\n name: \"bitfab-auto-trace\",\n visitor: {\n Program: {\n enter(path: NodePath<BabelTypes.Program>, state: BitfabPluginState) {\n const filename = state.file.opts.filename ?? \"unknown\"\n state.skipFile =\n !shouldTransformBitfabFile(filename, state.opts) ||\n path.scope.hasBinding(AUTO_TRACE_TRANSFORM_MARKER) ||\n path.node.directives.some(\n (directive) => directive.value.value === \"use client\",\n )\n state.runtimeIdentifier =\n path.scope.generateUidIdentifier(\"bitfabAutoSpan\")\n state.activeIdentifier = path.scope.generateUidIdentifier(\n \"bitfabAutoTraceActive\",\n )\n state.wrapperIdentifier =\n path.scope.generateUidIdentifier(\"bitfabAutoWrap\")\n state.recordedCallIdentifiers = new Map(\n RECORDED_CALL_RUNTIMES.map((call) => [\n call.runtimeExport,\n path.scope.generateUidIdentifier(call.identifierHint),\n ]),\n )\n state.bamlGenerated = isBamlGeneratedSource(state.file.code ?? \"\")\n state.definitions = []\n state.usedRuntime = false\n state.usedWrapper = false\n state.usedRecordedCalls = new Set()\n },\n exit(path: NodePath<BabelTypes.Program>, state: BitfabPluginState) {\n const bamlRegistrationModule =\n !state.skipFile &&\n state.bamlGenerated &&\n importsBamlAtRuntime(path.node, types)\n ? bamlRegistrationModuleFor(\n sourceFilename(state.file.opts.filename ?? \"\"),\n state.opts.bamlRegistrationModule,\n )\n : null\n if (bamlRegistrationModule !== null) {\n path.unshiftContainer(\n \"body\",\n types.importDeclaration(\n [],\n types.stringLiteral(bamlRegistrationModule),\n ),\n )\n state.file.metadata[AUTO_TRACE_TRANSFORM_MARKER] = true\n }\n if (\n state.skipFile ||\n !state.usedRuntime ||\n !state.runtimeIdentifier ||\n !state.activeIdentifier ||\n !state.wrapperIdentifier\n ) {\n return\n }\n\n state.file.metadata[AUTO_TRACE_TRANSFORM_MARKER] = true\n path.unshiftContainer(\"body\", [\n types.importDeclaration(\n [\n types.importSpecifier(\n state.runtimeIdentifier,\n types.identifier(\"__bitfabAutoSpan\"),\n ),\n types.importSpecifier(\n state.activeIdentifier,\n types.identifier(\"__bitfabAutoTraceActive\"),\n ),\n ...(state.usedWrapper\n ? [\n types.importSpecifier(\n state.wrapperIdentifier,\n types.identifier(\"__bitfabAutoWrap\"),\n ),\n ]\n : []),\n ...RECORDED_CALL_RUNTIMES.flatMap((call) => {\n const identifier = state.recordedCallIdentifiers?.get(\n call.runtimeExport,\n )\n return state.usedRecordedCalls?.has(call.runtimeExport) &&\n identifier\n ? [\n types.importSpecifier(\n identifier,\n types.identifier(call.runtimeExport),\n ),\n ]\n : []\n }),\n ],\n types.stringLiteral(\n state.opts.runtimeModule ?? \"@bitfab/sdk/auto\",\n ),\n ),\n types.variableDeclaration(\"const\", [\n types.variableDeclarator(\n types.identifier(AUTO_TRACE_TRANSFORM_MARKER),\n types.assignmentExpression(\n \"=\",\n types.memberExpression(\n types.identifier(\"globalThis\"),\n types.identifier(AUTO_TRACE_TRANSFORM_MARKER),\n ),\n types.booleanLiteral(true),\n ),\n ),\n ]),\n ...(state.definitions ?? []),\n ])\n },\n },\n CallExpression: {\n exit(\n path: NodePath<BabelTypes.CallExpression>,\n state: BitfabPluginState,\n ) {\n if (state.skipFile) {\n return\n }\n if (recordedCallTarget(path.node, types) !== null) {\n rewriteRecordedClientCall(path, state, types)\n return\n }\n const configuredName = withNodeFunctionName(path, types)\n if (configuredName === null) {\n return\n }\n if (path.node.arguments.length === 1) {\n path.node.arguments.push(types.identifier(\"undefined\"))\n }\n path.node.arguments.push(types.stringLiteral(configuredName))\n },\n },\n OptionalCallExpression: {\n exit(\n path: NodePath<BabelTypes.OptionalCallExpression>,\n state: BitfabPluginState,\n ) {\n rewriteRecordedClientCall(path, state, types)\n },\n },\n Function: {\n exit(path: NodePath<BabelTypes.Function>, state: BitfabPluginState) {\n const node = path.node as typeof path.node & InstrumentedFunction\n if (\n state.skipFile ||\n node._bitfabInstrumented ||\n !isInstrumentableFunction(node, types) ||\n isTraceDecoratorRoot(path, types) ||\n !state.runtimeIdentifier ||\n !state.activeIdentifier ||\n !state.wrapperIdentifier\n ) {\n return\n }\n const bamlMethod =\n state.bamlGenerated === true && isBamlClientMethod(path, types)\n if (state.bamlGenerated && !bamlMethod) {\n return\n }\n if (isJevMethodDefinition(path, types)) {\n return\n }\n const name = qualifiedFunctionName(path, types)\n if (name.startsWith(\"anonymous-\")) {\n return\n }\n const normalizedFilename = autoTraceFilename(\n state.file.opts.filename ?? \"unknown\",\n state.opts.cwd ?? state.file.opts.cwd ?? process.cwd(),\n )\n const { line, column } = sourcePosition(path)\n const definition = types.objectExpression([\n types.objectProperty(\n types.identifier(\"id\"),\n types.stringLiteral(\n autoTraceFunctionId(normalizedFilename, name),\n ),\n ),\n types.objectProperty(\n types.identifier(\"name\"),\n types.stringLiteral(name),\n ),\n types.objectProperty(\n types.identifier(\"file\"),\n types.stringLiteral(normalizedFilename),\n ),\n types.objectProperty(\n types.identifier(\"line\"),\n types.numericLiteral(line),\n ),\n types.objectProperty(\n types.identifier(\"column\"),\n types.numericLiteral(column),\n ),\n ...(node.async\n ? [\n types.objectProperty(\n types.identifier(\"async\"),\n types.booleanLiteral(true),\n ),\n ]\n : []),\n ...(bamlMethod\n ? [\n types.objectProperty(\n types.identifier(\"baml\"),\n types.booleanLiteral(true),\n ),\n ]\n : []),\n ...(isRestWrapper(path, types)\n ? [\n types.objectProperty(\n types.identifier(\"wrapper\"),\n types.booleanLiteral(true),\n ),\n ]\n : []),\n ])\n const definitionIdentifier = path.scope\n .getProgramParent()\n .generateUidIdentifier(\"bitfabAutoDefinition\")\n state.definitions?.push(\n types.variableDeclaration(\"const\", [\n types.variableDeclarator(definitionIdentifier, definition),\n ]),\n )\n\n if (needsArgumentWrapper(path, types)) {\n node._bitfabInstrumented = true\n path.replaceWith(\n types.callExpression(types.cloneNode(state.wrapperIdentifier), [\n types.cloneNode(definitionIdentifier),\n node as BabelTypes.ArrowFunctionExpression,\n ]),\n )\n state.usedRuntime = true\n state.usedWrapper = true\n return\n }\n\n const originalBody = types.isBlockStatement(node.body)\n ? node.body\n : types.blockStatement([types.returnStatement(node.body)])\n const directives = originalBody.directives\n originalBody.directives = []\n\n const callerOptions = bamlMethod\n ? path.scope.generateUidIdentifier(\"bitfabBamlOptions\")\n : undefined\n const withCollector = bamlMethod\n ? path.scope.generateUidIdentifier(\"bitfabBamlWithCollector\")\n : undefined\n const tracedBody =\n callerOptions && withCollector\n ? types.blockStatement(\n [\n bamlOptionsDeclaration(callerOptions, withCollector, types),\n ...types.cloneNode(originalBody, true).body,\n ],\n [],\n )\n : types.cloneNode(originalBody, true)\n const body = types.blockStatement(\n [\n types.ifStatement(\n types.callExpression(\n types.cloneNode(state.activeIdentifier),\n [],\n ),\n types.blockStatement([\n ...(callerOptions\n ? [\n types.variableDeclaration(\"const\", [\n types.variableDeclarator(\n callerOptions,\n types.identifier(BAML_OPTIONS_PARAMETER),\n ),\n ]),\n ]\n : []),\n types.returnStatement(\n types.callExpression(\n types.cloneNode(state.runtimeIdentifier),\n [\n types.cloneNode(definitionIdentifier),\n parameterInputs(path, types),\n types.arrowFunctionExpression(\n withCollector ? [types.cloneNode(withCollector)] : [],\n tracedBody,\n node.async ?? false,\n ),\n ],\n ),\n ),\n ]),\n ),\n ...originalBody.body,\n ],\n directives,\n )\n node.body = body\n node._bitfabInstrumented = true\n state.usedRuntime = true\n },\n },\n },\n }\n}\n","import { type InputOptions, transformSync } from \"@babel/core\"\nimport bitfabBabelPlugin from \"./babelPlugin.js\"\nimport type { BitfabTransformOptions } from \"./transformOptions.js\"\nimport {\n AUTO_TRACE_TRANSFORM_MARKER,\n shouldTransformBitfabFile,\n sourceFilename,\n} from \"./transformOptions.js\"\n\nexport type { BitfabTransformOptions } from \"./transformOptions.js\"\n\ntype ParserPlugin = NonNullable<\n NonNullable<InputOptions[\"parserOpts\"]>[\"plugins\"]\n>[number]\n\nexport interface BitfabSourceMap {\n version: number\n sources: string[]\n names: string[]\n mappings: string\n file?: string\n sourceRoot?: string\n sourcesContent?: Array<string | null>\n}\n\nexport interface BitfabTransformResult {\n code: string\n map?: BitfabSourceMap\n}\n\nexport function parserPlugins(filename: string): ParserPlugin[] {\n const path = sourceFilename(filename)\n const typescript = /\\.[cm]?tsx?$/.test(path)\n const jsx = /\\.tsx$/.test(path) || /\\.[cm]?jsx?$/.test(path)\n return [\n ...(typescript ? ([\"typescript\"] as const) : []),\n ...(jsx ? ([\"jsx\"] as const) : []),\n \"decorators\",\n ]\n}\n\nexport function transformBitfabSource(\n source: string,\n filename: string,\n options: BitfabTransformOptions = {},\n): BitfabTransformResult {\n if (!shouldTransformBitfabFile(filename, options)) {\n return { code: source }\n }\n const result = transformSync(source, {\n babelrc: false,\n configFile: false,\n filename: sourceFilename(filename),\n parserOpts: { plugins: parserPlugins(filename), sourceType: \"module\" },\n plugins: [[bitfabBabelPlugin, options]],\n sourceMaps: true,\n })\n if (!result?.code || !result.metadata?.[AUTO_TRACE_TRANSFORM_MARKER]) {\n return { code: source }\n }\n return {\n code: result.code,\n ...(result.map ? { map: result.map as BitfabSourceMap } : {}),\n }\n}\n","import { dirname } from \"node:path\"\nimport {\n type PluginItem,\n transformFromAstSync,\n transformSync,\n} from \"@babel/core\"\nimport decoratorsPlugin from \"@babel/plugin-proposal-decorators\"\nimport commonJsPlugin from \"@babel/plugin-transform-modules-commonjs\"\nimport reactJsxPlugin from \"@babel/plugin-transform-react-jsx\"\nimport typeScriptPlugin from \"@babel/plugin-transform-typescript\"\nimport { getTsconfig, parseTsconfig, type TsConfigJson } from \"get-tsconfig\"\nimport bitfabBabelPlugin from \"./babelPlugin.js\"\nimport { parserPlugins } from \"./transform.js\"\nimport type { BitfabTransformOptions } from \"./transformOptions.js\"\nimport {\n shouldTransformBitfabFile,\n sourceFilename,\n} from \"./transformOptions.js\"\n\nexport interface BitfabLoaderOptions\n extends Omit<BitfabTransformOptions, \"include\"> {\n tsconfig?: string\n}\n\nexport interface BitfabJavaScriptTransformResult {\n code: string\n map?: string\n}\n\ntype CompilerOptions = NonNullable<TsConfigJson[\"compilerOptions\"]>\n\nfunction readCompilerOptions(\n filename: string,\n configuredPath: string | undefined,\n): CompilerOptions {\n const config = configuredPath\n ? parseTsconfig(configuredPath)\n : getTsconfig(dirname(filename))?.config\n return config?.compilerOptions ?? {}\n}\n\nfunction reactJsxOptions(compilerOptions: CompilerOptions): PluginItem {\n if (compilerOptions.jsx === \"react\") {\n return [\n reactJsxPlugin,\n {\n runtime: \"classic\",\n ...(compilerOptions.jsxFactory && {\n pragma: compilerOptions.jsxFactory,\n }),\n ...(compilerOptions.jsxFragmentFactory && {\n pragmaFrag: compilerOptions.jsxFragmentFactory,\n }),\n },\n ]\n }\n return [\n reactJsxPlugin,\n {\n runtime: \"automatic\",\n importSource: compilerOptions.jsxImportSource ?? \"react\",\n },\n ]\n}\n\nfunction compilePlugins(\n filename: string,\n compilerOptions: CompilerOptions,\n format: \"commonjs\" | \"module\" | undefined,\n): PluginItem[] {\n const path = sourceFilename(filename)\n const isTypeScript = /\\.[cm]?tsx?$/.test(path)\n const hasJsx = /\\.[jt]sx$/.test(path)\n const isCommonJs = format === \"commonjs\" || path.endsWith(\".cts\")\n return [\n ...(isTypeScript\n ? [\n [\n typeScriptPlugin,\n {\n onlyRemoveTypeImports:\n compilerOptions.verbatimModuleSyntax === true,\n },\n ] satisfies PluginItem,\n ]\n : []),\n [\n decoratorsPlugin,\n {\n version: compilerOptions.experimentalDecorators ? \"legacy\" : \"2023-11\",\n },\n ],\n ...(hasJsx ? [reactJsxOptions(compilerOptions)] : []),\n ...(isCommonJs ? [commonJsPlugin] : []),\n ]\n}\n\nexport function transformBitfabModuleToJavaScript(\n source: string,\n filename: string,\n options: BitfabLoaderOptions = {},\n format?: \"commonjs\" | \"module\",\n sourceMapMode: \"external\" | \"inline\" = \"external\",\n): BitfabJavaScriptTransformResult {\n const { tsconfig, ...transformOptions } = options\n if (!shouldTransformBitfabFile(filename, transformOptions)) {\n return { code: source }\n }\n const sourceFile = sourceFilename(filename)\n const instrumented = transformSync(source, {\n ast: true,\n babelrc: false,\n code: false,\n configFile: false,\n filename: sourceFile,\n parserOpts: { plugins: parserPlugins(filename), sourceType: \"module\" },\n plugins: [[bitfabBabelPlugin, transformOptions]],\n })\n if (!instrumented?.ast) {\n throw new Error(`Bitfab could not parse ${sourceFile}`)\n }\n const compiled = transformFromAstSync(instrumented.ast, source, {\n babelrc: false,\n cloneInputAst: false,\n configFile: false,\n filename: sourceFile,\n plugins: compilePlugins(\n filename,\n readCompilerOptions(filename, tsconfig),\n format,\n ),\n sourceMaps: sourceMapMode === \"inline\" ? \"inline\" : true,\n })\n if (compiled?.code === undefined || compiled.code === null) {\n throw new Error(`Bitfab could not compile ${sourceFile}`)\n }\n return {\n code: compiled.code,\n ...(compiled.map ? { map: JSON.stringify(compiled.map) } : {}),\n }\n}\n","import { readFile } from \"node:fs/promises\"\nimport { createRequire } from \"node:module\"\nimport { isAbsolute, relative, resolve as resolvePath } from \"node:path\"\nimport { fileURLToPath, pathToFileURL } from \"node:url\"\nimport { transformBitfabModuleToJavaScript } from \"./loaderRuntime.js\"\nimport { shouldTransformBitfabFile } from \"./transformOptions.js\"\n\nconst runtimeParentURL =\n process.env.BITFAB_SDK_RESOLVE_FROM === undefined\n ? import.meta.url\n : pathToFileURL(resolvePath(process.env.BITFAB_SDK_RESOLVE_FROM)).href\n\ninterface NodeResolveContext {\n parentURL?: string\n conditions?: string[]\n importAttributes?: Record<string, string>\n}\n\nexport async function resolve(\n specifier: string,\n context: NodeResolveContext,\n nextResolve: (\n specifier: string,\n context: NodeResolveContext,\n ) => Promise<{ url: string }>,\n): Promise<{ url: string }> {\n return specifier === \"bitfab:runtime/auto\"\n ? nextResolve(\"@bitfab/sdk/auto\", {\n ...context,\n parentURL: runtimeParentURL,\n })\n : nextResolve(specifier, context)\n}\n\ninterface NodeLoadContext {\n format?: string\n}\n\ninterface NodeLoadResult {\n format?: string\n shortCircuit?: boolean\n source?: string | ArrayBuffer | Uint8Array\n}\n\ntype NextLoad = (\n url: string,\n context: NodeLoadContext,\n) => Promise<NodeLoadResult>\n\nfunction runtimeFormat(\n format: string | undefined,\n filename: string,\n): \"commonjs\" | \"module\" {\n return format?.startsWith(\"commonjs\") || /\\.c(?:js|ts)$/.test(filename)\n ? \"commonjs\"\n : \"module\"\n}\n\nfunction isInsideWorkingDirectory(filename: string): boolean {\n const path = relative(process.cwd(), filename)\n return (\n path !== \"..\" &&\n !path.startsWith(`..${process.platform === \"win32\" ? \"\\\\\" : \"/\"}`) &&\n !isAbsolute(path)\n )\n}\n\nexport async function load(\n url: string,\n context: NodeLoadContext,\n nextLoad: NextLoad,\n): Promise<NodeLoadResult> {\n if (!url.startsWith(\"file:\")) {\n return nextLoad(url, context)\n }\n\n const filename = fileURLToPath(url)\n if (\n !isInsideWorkingDirectory(filename) ||\n !shouldTransformBitfabFile(filename, {})\n ) {\n return nextLoad(url, context)\n }\n\n const source = await readFile(filename, \"utf8\")\n const format = runtimeFormat(context.format, filename)\n const transformed = transformBitfabModuleToJavaScript(\n source,\n filename,\n format === \"commonjs\"\n ? {\n runtimeModule:\n createRequire(runtimeParentURL).resolve(\"@bitfab/sdk/auto\"),\n bamlRegistrationModule: false,\n }\n : { runtimeModule: \"bitfab:runtime/auto\", bamlRegistrationModule: false },\n format,\n \"inline\",\n )\n return {\n format,\n shortCircuit: true,\n source: transformed.code,\n }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAM,iCAAiC;AACvC,MAAa,8BACX;AAEF,SAAgB,oBAAoB,MAAc,MAAsB;CACtE,OAAO,GAAG,+BAA+B,GAAG,KAAK,GAAG;AACtD;AAEA,SAAgB,eAAe,UAA0B;CACvD,OAAO,SAAS,QAAQ,OAAO,GAAG,CAAC,CAAC,MAAM,QAAQ,CAAC,CAAC,CAAC,MAAM;AAC7D;AAEA,SAAgB,kBAAkB,UAAkB,KAAqB;CACvE,MAAM,aAAa,eAAe,QAAQ;CAC1C,MAAM,gBAAgB,IAAI,QAAQ,OAAO,GAAG,CAAC,CAAC,QAAQ,OAAO,EAAE;CAC/D,OAAO,WAAW,WAAW,GAAG,cAAc,E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,WAAW;CACb,CAAC,IACD,YAAY,WAAW,OAAO;AACpC;AAiBA,SAAS,cACP,QACA,UACuB;CACvB,OAAO,QAAQ,WAAW,UAAU,KAAK,gBAAgB,KAAK,QAAQ,IAClE,aACA;AACN;AAEA,SAAS,yBAAyB,UAA2B;CAC3D,MAAM,OAAO,SAAS,QAAQ,IAAI,GAAG,QAAQ;CAC7C,OACE,SAAS,QACT,CAAC,KAAK,WAAW,KAAK,QAAQ,aAAa,UAAU,OAAO,KAAK,KACjE,CAAC,WAAW,IAAI;AAEpB;AAEA,eAAsB,KACpB,KACA,SACA,UACyB;CACzB,IAAI,CAAC,IAAI,WAAW,OAAO,GACzB,OAAO,SAAS,KAAK,OAAO;CAG9B,MAAM,WAAW,cAAc,GAAG;CAClC,IACE,CAAC,yBAAyB,QAAQ,KAClC,CAAC,0BAA0B,UAAU,CAAC,CAAC,GAEvC,OAAO,SAAS,KAAK,OAAO;CAG9B,MAAM,SAAS,MAAM,SAAS,UAAU,MAAM;CAC9C,MAAM,SAAS,cAAc,QAAQ,QAAQ,QAAQ;CAcrD,OAAO;EACL;EACA,cAAc;EACd,QAhBkB,kCAClB,QACA,UACA,WAAW,aACP;GACE,eACE,cAAc,gBAAgB,CAAC,CAAC,QAAQ,kBAAkB;GAC5D,wBAAwB;EAC1B,IACA;GAAE,eAAe;GAAuB,wBAAwB;EAAM,GAC1E,QACA,QAKkB,CAAC,CAAC;CACtB;AACF"}
|
|
1
|
+
{"version":3,"file":"nodeLoader.js","names":["resolvePath"],"sources":["../../../bitfab-typescript-transform/src/transformOptions.ts","../../../bitfab-typescript-transform/src/babelPlugin.ts","../../../bitfab-typescript-transform/src/transform.ts","../../../bitfab-typescript-transform/src/loaderRuntime.ts","../../../bitfab-typescript-transform/src/nodeLoader.ts"],"sourcesContent":["export interface BitfabTransformOptions {\n /** Module that exports the automatic span runtime. */\n runtimeModule?: string\n /** Module imported at the top of BAML's generated client files so the SDK can use the `@boundaryml/baml` the bundler loads. Pass `false` to import nothing. Defaults to `\"@bitfab/sdk/baml\"`, added only when it resolves from the file's folder. */\n bamlRegistrationModule?: string | false\n /** Working directory removed from generated function IDs. */\n cwd?: string\n /** Return false to leave a file unchanged. */\n include?: (filename: string) => boolean\n}\n\nconst AUTO_TRACE_FUNCTION_ID_VERSION = \"ts-auto-v1\"\nexport const AUTO_TRACE_TRANSFORM_MARKER =\n \"__bitfab_auto_trace_transformed_v1__\"\n\nexport function autoTraceFunctionId(file: string, name: string): string {\n return `${AUTO_TRACE_FUNCTION_ID_VERSION}:${file}#${name}`\n}\n\nexport function sourceFilename(filename: string): string {\n return filename.replace(/\\\\/g, \"/\").split(/[?#]/, 1)[0] ?? \"\"\n}\n\nexport function autoTraceFilename(filename: string, cwd: string): string {\n const normalized = sourceFilename(filename)\n const normalizedCwd = cwd.replace(/\\\\/g, \"/\").replace(/\\/$/, \"\")\n return normalized.startsWith(`${normalizedCwd}/`)\n ? normalized.slice(normalizedCwd.length + 1)\n : normalized\n}\n\nexport function shouldTransformBitfabFile(\n filename: string,\n options: BitfabTransformOptions,\n): boolean {\n if (!filename) {\n return false\n }\n if (options.include && !options.include(filename)) {\n return false\n }\n\n const normalized = sourceFilename(filename)\n const normalizedCwd = options.cwd?.replace(/\\\\/g, \"/\").replace(/\\/$/, \"\")\n const isAbsolute =\n normalized.startsWith(\"/\") || /^[A-Za-z]:\\//.test(normalized)\n if (\n normalizedCwd &&\n isAbsolute &&\n normalized !== normalizedCwd &&\n !normalized.startsWith(`${normalizedCwd}/`)\n ) {\n return false\n }\n return (\n !normalized.includes(\"/node_modules/\") &&\n !normalized.endsWith(\".d.ts\") &&\n /\\.[cm]?[jt]sx?$/.test(normalized)\n )\n}\n","import { readFileSync } from \"node:fs\"\nimport { dirname, isAbsolute, join } from \"node:path\"\nimport type { NodePath, PluginObject, PluginPass } from \"@babel/core\"\nimport type * as BabelTypes from \"@babel/types\"\nimport type { BitfabTransformOptions } from \"./transformOptions.js\"\nimport {\n AUTO_TRACE_TRANSFORM_MARKER,\n autoTraceFilename,\n autoTraceFunctionId,\n shouldTransformBitfabFile,\n sourceFilename,\n} from \"./transformOptions.js\"\n\ntype BabelTypesApi = typeof BabelTypes\n\ntype BitfabPluginOptions = BitfabTransformOptions\n\ninterface BitfabPluginState extends PluginPass {\n opts: BitfabPluginOptions\n runtimeIdentifier?: ReturnType<BabelTypesApi[\"identifier\"]>\n activeIdentifier?: ReturnType<BabelTypesApi[\"identifier\"]>\n wrapperIdentifier?: ReturnType<BabelTypesApi[\"identifier\"]>\n recordedCallIdentifiers?: Map<string, ReturnType<BabelTypesApi[\"identifier\"]>>\n definitions?: Array<ReturnType<BabelTypesApi[\"variableDeclaration\"]>>\n skipFile?: boolean\n bamlGenerated?: boolean\n usedRuntime?: boolean\n usedWrapper?: boolean\n usedRecordedCalls?: Set<string>\n}\n\ninterface InstrumentedFunction {\n _bitfabInstrumented?: boolean\n}\n\nfunction propertyName(\n node: BabelTypes.Node | null | undefined,\n types: BabelTypesApi,\n): string | null {\n if (types.isIdentifier(node)) {\n return node.name\n }\n if (types.isStringLiteral(node)) {\n return node.value\n }\n return null\n}\n\nfunction functionName(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): string {\n const node = path.node\n if (types.isFunctionDeclaration(node) || types.isFunctionExpression(node)) {\n if (node.id) {\n return node.id.name\n }\n }\n\n if (\n (types.isClassMethod(node) || types.isObjectMethod(node)) &&\n !node.computed &&\n types.isIdentifier(node.key)\n ) {\n return node.key.name\n }\n\n const parent = path.parentPath?.node\n if (types.isVariableDeclarator(parent)) {\n return propertyName(parent.id, types) ?? \"anonymous\"\n }\n if (types.isObjectProperty(parent) && !parent.computed) {\n return propertyName(parent.key, types) ?? \"anonymous\"\n }\n if (types.isClassProperty(parent) && !parent.computed) {\n const name = propertyName(parent.key, types)\n if (name) {\n return name\n }\n }\n\n const { line, column } = sourcePosition(path)\n return `anonymous-${line}-${column}`\n}\n\nconst JEV_METHOD = \"systemOne\"\n\nfunction isJevMethodDefinition(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): boolean {\n const parent = path.parentPath?.node\n const isMethod =\n types.isClassMethod(path.node) ||\n types.isObjectMethod(path.node) ||\n types.isObjectProperty(parent) ||\n types.isClassProperty(parent)\n return isMethod && functionName(path, types) === JEV_METHOD\n}\n\nfunction isInstrumentableFunction(\n node: BabelTypes.Function,\n types: BabelTypesApi,\n): boolean {\n if (node.generator || types.isClassPrivateMethod(node)) {\n return false\n }\n return (\n !(types.isClassMethod(node) || types.isObjectMethod(node)) ||\n node.kind === \"method\"\n )\n}\n\nfunction sourcePosition(path: NodePath<BabelTypes.Function>): {\n line: number\n column: number\n} {\n const exportDeclaration = path.parentPath?.isExportDeclaration()\n ? path.parentPath.node\n : undefined\n const start = (exportDeclaration ?? path.node).loc?.start\n return { line: start?.line ?? 0, column: start?.column ?? 0 }\n}\n\nfunction qualifiedFunctionName(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): string {\n const ownName = functionName(path, types)\n if (ownName.startsWith(\"anonymous-\")) {\n return ownName\n }\n const scopes: string[] = []\n let ancestor: NodePath | null = path.parentPath\n while (ancestor) {\n if (ancestor.isFunction()) {\n if (!isInstrumentableFunction(ancestor.node, types)) {\n ancestor = ancestor.parentPath\n continue\n }\n const name = functionName(\n ancestor as NodePath<BabelTypes.Function>,\n types,\n )\n if (!name.startsWith(\"anonymous-\")) {\n scopes.unshift(name)\n }\n } else if (\n (ancestor.isClassDeclaration() || ancestor.isClassExpression()) &&\n ancestor.node.id\n ) {\n scopes.unshift(ancestor.node.id.name)\n } else if (ancestor.isObjectExpression()) {\n const parent = ancestor.parentPath?.node\n if (types.isVariableDeclarator(parent)) {\n const name = propertyName(parent.id, types)\n if (name) {\n scopes.unshift(name)\n }\n } else if (types.isObjectProperty(parent) && !parent.computed) {\n const name = propertyName(parent.key, types)\n if (name) {\n scopes.unshift(name)\n }\n }\n }\n ancestor = ancestor.parentPath\n }\n return [...scopes, ownName].join(\".\")\n}\n\nfunction isTraceDecoratorRoot(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): boolean {\n const node = path.node\n const parent = path.parentPath?.node\n const decorated =\n types.isClassMethod(node) || types.isClassPrivateMethod(node)\n ? node\n : types.isClassProperty(parent) && parent.value === node\n ? parent\n : null\n if (!decorated) {\n return false\n }\n\n return (\n decorated.decorators?.some((decorator) => {\n const expression = decorator.expression\n if (!types.isCallExpression(expression)) {\n return false\n }\n const callee = expression.callee\n return (\n types.isMemberExpression(callee) &&\n !callee.computed &&\n types.isIdentifier(callee.property, { name: \"trace\" })\n )\n }) ?? false\n )\n}\n\nfunction withNodeFunctionName(\n path: NodePath<BabelTypes.CallExpression>,\n types: BabelTypesApi,\n): string | null {\n if (path.node.arguments.length > 2) {\n return null\n }\n const callee = path.node.callee\n if (\n !types.isMemberExpression(callee) ||\n callee.computed ||\n !types.isIdentifier(callee.property, { name: \"withNode\" })\n ) {\n return null\n }\n const fn = path.node.arguments[path.node.arguments.length - 1]\n if (types.isIdentifier(fn)) {\n return fn.name\n }\n if (types.isMemberExpression(fn) && !fn.computed) {\n return propertyName(fn.property, types)\n }\n if (types.isFunctionExpression(fn) && fn.id) {\n return fn.id.name\n }\n return null\n}\n\nconst BAML_GENERATED_HEADER = \"This file was generated by BAML\"\nconst BAML_CLIENT_CLASSES = new Set([\"BamlAsyncClient\", \"BamlSyncClient\"])\nconst BAML_OPTIONS_PARAMETER = \"__baml_options__\"\n\nconst BAML_PACKAGE = \"@boundaryml/baml\"\nconst DEFAULT_BAML_REGISTRATION_MODULE = \"@bitfab/sdk/baml\"\n\nfunction importsBamlAtRuntime(\n program: BabelTypes.Program,\n types: BabelTypesApi,\n): boolean {\n return program.body.some(\n (statement) =>\n types.isImportDeclaration(statement) &&\n statement.source.value === BAML_PACKAGE &&\n statement.importKind !== \"type\" &&\n statement.specifiers.some(\n (specifier) =>\n !types.isImportSpecifier(specifier) ||\n specifier.importKind !== \"type\",\n ),\n )\n}\n\nconst SDK_PACKAGE_PATH = [\"node_modules\", \"@bitfab\", \"sdk\", \"package.json\"]\nconst BAML_REGISTRATION_EXPORT = \"./baml\"\nconst sdkExportsBamlRegistrationByDirectory = new Map<string, boolean>()\n\nfunction readPackageJson(path: string): unknown {\n try {\n return JSON.parse(readFileSync(path, \"utf8\"))\n } catch {\n return undefined\n }\n}\n\nfunction exportsBamlRegistration(packageJson: unknown): boolean {\n if (typeof packageJson !== \"object\" || packageJson === null) {\n return false\n }\n const exports = (packageJson as { exports?: unknown }).exports\n return (\n typeof exports === \"object\" &&\n exports !== null &&\n BAML_REGISTRATION_EXPORT in exports\n )\n}\n\nfunction nearestSdkExportsBamlRegistration(directory: string): boolean {\n const cached = sdkExportsBamlRegistrationByDirectory.get(directory)\n if (cached !== undefined) {\n return cached\n }\n const packageJson = readPackageJson(join(directory, ...SDK_PACKAGE_PATH))\n const parent = dirname(directory)\n const exported =\n packageJson !== undefined\n ? exportsBamlRegistration(packageJson)\n : parent !== directory && nearestSdkExportsBamlRegistration(parent)\n sdkExportsBamlRegistrationByDirectory.set(directory, exported)\n return exported\n}\n\nfunction defaultRegistrationResolves(filename: string): boolean {\n return (\n isAbsolute(filename) && nearestSdkExportsBamlRegistration(dirname(filename))\n )\n}\n\nfunction bamlRegistrationModuleFor(\n filename: string,\n configured: string | false | undefined,\n): string | null {\n if (configured === false) {\n return null\n }\n if (configured !== undefined) {\n return configured\n }\n return defaultRegistrationResolves(filename)\n ? DEFAULT_BAML_REGISTRATION_MODULE\n : null\n}\n\nfunction isBamlGeneratedSource(code: string): boolean {\n return code.slice(0, 4096).includes(BAML_GENERATED_HEADER)\n}\n\nfunction isBamlClientMethod(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): boolean {\n const node = path.node\n if (!types.isClassMethod(node) || node.kind !== \"method\" || node.static) {\n return false\n }\n const classPath = path.parentPath?.parentPath\n if (\n !classPath ||\n !(classPath.isClassDeclaration() || classPath.isClassExpression()) ||\n !classPath.node.id ||\n !BAML_CLIENT_CLASSES.has(classPath.node.id.name)\n ) {\n return false\n }\n const parameters = runtimeParameters(node, types)\n const last = parameters[parameters.length - 1]\n return types.isIdentifier(last, { name: BAML_OPTIONS_PARAMETER })\n}\n\nfunction bamlOptionsDeclaration(\n callerOptions: BabelTypes.Identifier,\n withCollector: BabelTypes.Identifier,\n types: BabelTypesApi,\n): BabelTypes.VariableDeclaration {\n return types.variableDeclaration(\"const\", [\n types.variableDeclarator(\n types.identifier(BAML_OPTIONS_PARAMETER),\n types.conditionalExpression(\n types.binaryExpression(\n \"===\",\n types.cloneNode(withCollector),\n types.identifier(\"undefined\"),\n ),\n types.cloneNode(callerOptions),\n types.callExpression(types.cloneNode(withCollector), [\n types.cloneNode(callerOptions),\n types.memberExpression(\n types.thisExpression(),\n types.identifier(\"bamlOptions\"),\n ),\n ]),\n ),\n ),\n ])\n}\n\nfunction runtimeParameters(\n node: BabelTypes.Function,\n types: BabelTypesApi,\n): BabelTypes.Function[\"params\"] {\n return node.params.filter(\n (parameter) => !types.isIdentifier(parameter, { name: \"this\" }),\n )\n}\n\nfunction parameterInputs(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): ReturnType<BabelTypesApi[\"arrayExpression\"]> {\n const elements: Array<BabelTypes.Expression | BabelTypes.SpreadElement> = []\n\n for (const [index, parameter] of runtimeParameters(\n path.node,\n types,\n ).entries()) {\n if (!types.isArrowFunctionExpression(path.node)) {\n if (types.isRestElement(parameter)) {\n elements.push(\n types.spreadElement(\n types.callExpression(\n types.memberExpression(\n types.arrayExpression([\n types.spreadElement(types.identifier(\"arguments\")),\n ]),\n types.identifier(\"slice\"),\n ),\n [types.numericLiteral(index)],\n ),\n ),\n )\n } else {\n elements.push(\n types.memberExpression(\n types.identifier(\"arguments\"),\n types.numericLiteral(index),\n true,\n ),\n )\n }\n continue\n }\n\n if (types.isIdentifier(parameter)) {\n elements.push(types.identifier(parameter.name))\n } else if (\n types.isRestElement(parameter) &&\n types.isIdentifier(parameter.argument)\n ) {\n elements.push(\n types.spreadElement(types.identifier(parameter.argument.name)),\n )\n }\n }\n\n return types.arrayExpression(elements)\n}\n\nfunction needsArgumentWrapper(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): boolean {\n return (\n types.isArrowFunctionExpression(path.node) &&\n path.node.params.some(\n (parameter) =>\n !types.isIdentifier(parameter) &&\n !(\n types.isRestElement(parameter) &&\n types.isIdentifier(parameter.argument)\n ),\n )\n )\n}\n\nfunction isRestWrapper(\n path: NodePath<BabelTypes.Function>,\n types: BabelTypesApi,\n): boolean {\n const parameters = runtimeParameters(path.node, types)\n return parameters.length === 1 && types.isRestElement(parameters[0])\n}\n\ntype RecordedCallNode =\n | BabelTypes.CallExpression\n | BabelTypes.OptionalCallExpression\n\ninterface RecordedClientCall {\n methods: readonly string[]\n endpoint?: string\n runtimeExport: string\n identifierHint: string\n receiverHint: string\n matchesReceiver: (\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n ) => boolean\n}\n\nfunction isNamedMember(\n node: BabelTypes.Node,\n name: string,\n types: BabelTypesApi,\n): node is BabelTypes.MemberExpression | BabelTypes.OptionalMemberExpression {\n return (\n (types.isMemberExpression(node) ||\n types.isOptionalMemberExpression(node)) &&\n !node.computed &&\n types.isIdentifier(node.property, { name })\n )\n}\n\nfunction isChatCompletionsReceiver(\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n): boolean {\n return (\n isNamedMember(receiver, \"completions\", types) &&\n isNamedMember(receiver.object, \"chat\", types)\n )\n}\n\nfunction isMessagesReceiver(\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n): boolean {\n return (\n isNamedMember(receiver, \"messages\", types) &&\n !isNamedMember(receiver.object, \"beta\", types)\n )\n}\n\nfunction isResponsesReceiver(\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n): boolean {\n return isNamedMember(receiver, \"responses\", types)\n}\n\nfunction isEmbeddingsReceiver(\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n): boolean {\n return isNamedMember(receiver, \"embeddings\", types)\n}\n\nfunction isTranscriptionsReceiver(\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n): boolean {\n return (\n isNamedMember(receiver, \"transcriptions\", types) &&\n isNamedMember(receiver.object, \"audio\", types)\n )\n}\n\nfunction isModelsReceiver(\n receiver: BabelTypes.Expression,\n types: BabelTypesApi,\n): boolean {\n return isNamedMember(receiver, \"models\", types)\n}\n\nconst CLIENT_CALL_RUNTIME = {\n runtimeExport: \"__bitfabAutoClientCall\",\n identifierHint: \"bitfabAutoClientCall\",\n receiverHint: \"bitfabClientCallReceiver\",\n}\n\nconst RECORDED_CLIENT_CALLS: readonly RecordedClientCall[] = [\n {\n methods: [JEV_METHOD],\n runtimeExport: \"__bitfabAutoJev\",\n identifierHint: \"bitfabAutoJev\",\n receiverHint: \"bitfabJevReceiver\",\n matchesReceiver: () => true,\n },\n {\n ...CLIENT_CALL_RUNTIME,\n endpoint: \"chat.completions\",\n methods: [\"create\", \"parse\", \"stream\"],\n matchesReceiver: isChatCompletionsReceiver,\n },\n {\n ...CLIENT_CALL_RUNTIME,\n endpoint: \"embeddings\",\n methods: [\"create\"],\n matchesReceiver: isEmbeddingsReceiver,\n },\n {\n ...CLIENT_CALL_RUNTIME,\n endpoint: \"audio.transcriptions\",\n methods: [\"create\"],\n matchesReceiver: isTranscriptionsReceiver,\n },\n {\n ...CLIENT_CALL_RUNTIME,\n endpoint: \"messages\",\n methods: [\"create\", \"parse\", \"stream\"],\n matchesReceiver: isMessagesReceiver,\n },\n {\n ...CLIENT_CALL_RUNTIME,\n endpoint: \"responses\",\n methods: [\"create\", \"parse\", \"stream\"],\n matchesReceiver: isResponsesReceiver,\n },\n {\n ...CLIENT_CALL_RUNTIME,\n endpoint: \"models\",\n methods: [\"generateContent\", \"generateContentStream\", \"embedContent\"],\n matchesReceiver: isModelsReceiver,\n },\n]\n\nconst RECORDED_CALL_RUNTIMES = [\n ...new Map(\n RECORDED_CLIENT_CALLS.map((call) => [call.runtimeExport, call]),\n ).values(),\n]\n\nfunction recordedCallTarget(\n node: RecordedCallNode,\n types: BabelTypesApi,\n): {\n call: RecordedClientCall\n receiver: BabelTypes.Expression\n method: string\n} | null {\n const callee = node.callee\n if (\n !(\n types.isMemberExpression(callee) ||\n types.isOptionalMemberExpression(callee)\n ) ||\n callee.computed ||\n !types.isIdentifier(callee.property) ||\n types.isSuper(callee.object)\n ) {\n return null\n }\n const method = callee.property.name\n const receiver = callee.object\n const call = RECORDED_CLIENT_CALLS.find(\n (candidate) =>\n candidate.methods.includes(method) &&\n candidate.matchesReceiver(receiver, types),\n )\n return call === undefined ? null : { call, receiver, method }\n}\n\nfunction isOptionalChain(node: BabelTypes.Node, types: BabelTypesApi): boolean {\n return (\n types.isOptionalMemberExpression(node) ||\n types.isOptionalCallExpression(node)\n )\n}\n\nfunction continuesOptionalChain(\n path: NodePath<BabelTypes.OptionalCallExpression>,\n types: BabelTypesApi,\n): boolean {\n const parent = path.parent\n return (\n (types.isOptionalMemberExpression(parent) && parent.object === path.node) ||\n (types.isOptionalCallExpression(parent) && parent.callee === path.node)\n )\n}\n\nfunction rewriteRecordedClientCall(\n path: NodePath<RecordedCallNode>,\n state: BitfabPluginState,\n types: BabelTypesApi,\n): void {\n if (state.skipFile || state.bamlGenerated) {\n return\n }\n const node = path.node\n const target = recordedCallTarget(node, types)\n const identifier =\n target === null\n ? undefined\n : state.recordedCallIdentifiers?.get(target.call.runtimeExport)\n if (target === null || identifier === undefined) {\n return\n }\n const { call: recordedCall, receiver, method } = target\n const optionalReceiver =\n types.isOptionalMemberExpression(node.callee) && node.callee.optional\n const optionalMethod = types.isOptionalCallExpression(node) && node.optional\n if (types.isOptionalCallExpression(node)) {\n if (\n continuesOptionalChain(\n path as NodePath<BabelTypes.OptionalCallExpression>,\n types,\n ) ||\n (!optionalReceiver && isOptionalChain(receiver, types))\n ) {\n return\n }\n }\n const guarded = optionalReceiver || optionalMethod\n const receiverReference =\n guarded && !path.scope.isStatic(receiver)\n ? path.scope.generateDeclaredUidIdentifier(recordedCall.receiverHint)\n : null\n const receiverValue = (): BabelTypes.Expression =>\n receiverReference === null\n ? types.cloneNode(receiver)\n : types.cloneNode(receiverReference)\n const call = types.callExpression(\n types.cloneNode(identifier),\n recordedCall.endpoint === undefined\n ? [receiverValue(), ...node.arguments]\n : [\n types.stringLiteral(recordedCall.endpoint),\n receiverValue(),\n types.stringLiteral(method),\n ...node.arguments,\n ],\n )\n state.usedRuntime = true\n state.usedRecordedCalls?.add(recordedCall.runtimeExport)\n if (!guarded) {\n path.replaceWith(call)\n return\n }\n const firstReceiver =\n receiverReference === null\n ? types.cloneNode(receiver)\n : types.assignmentExpression(\n \"=\",\n types.cloneNode(receiverReference),\n receiver,\n )\n const missing = (value: BabelTypes.Expression): BabelTypes.BinaryExpression =>\n types.binaryExpression(\"==\", value, types.nullLiteral())\n const methodOf = (value: BabelTypes.Expression): BabelTypes.Expression =>\n types.memberExpression(value, types.identifier(method))\n const test = optionalReceiver\n ? optionalMethod\n ? types.logicalExpression(\n \"||\",\n missing(firstReceiver),\n missing(methodOf(receiverValue())),\n )\n : missing(firstReceiver)\n : missing(methodOf(firstReceiver))\n path.replaceWith(\n types.conditionalExpression(\n test,\n types.unaryExpression(\"void\", types.numericLiteral(0)),\n call,\n ),\n )\n}\n\n/**\n * Babel adapter for Bitfab's experimental automatic call-span runtime.\n *\n * @experimental The transform protocol and generated function identities may\n * change before the feature is stable.\n */\nexport default function bitfabBabelPlugin(api: {\n types: BabelTypesApi\n}): PluginObject<BitfabPluginState> {\n const { types } = api\n\n return {\n name: \"bitfab-auto-trace\",\n visitor: {\n Program: {\n enter(path: NodePath<BabelTypes.Program>, state: BitfabPluginState) {\n const filename = state.file.opts.filename ?? \"unknown\"\n state.skipFile =\n !shouldTransformBitfabFile(filename, state.opts) ||\n path.scope.hasBinding(AUTO_TRACE_TRANSFORM_MARKER) ||\n path.node.directives.some(\n (directive) => directive.value.value === \"use client\",\n )\n state.runtimeIdentifier =\n path.scope.generateUidIdentifier(\"bitfabAutoSpan\")\n state.activeIdentifier = path.scope.generateUidIdentifier(\n \"bitfabAutoTraceActive\",\n )\n state.wrapperIdentifier =\n path.scope.generateUidIdentifier(\"bitfabAutoWrap\")\n state.recordedCallIdentifiers = new Map(\n RECORDED_CALL_RUNTIMES.map((call) => [\n call.runtimeExport,\n path.scope.generateUidIdentifier(call.identifierHint),\n ]),\n )\n state.bamlGenerated = isBamlGeneratedSource(state.file.code ?? \"\")\n state.definitions = []\n state.usedRuntime = false\n state.usedWrapper = false\n state.usedRecordedCalls = new Set()\n },\n exit(path: NodePath<BabelTypes.Program>, state: BitfabPluginState) {\n const bamlRegistrationModule =\n !state.skipFile &&\n state.bamlGenerated &&\n importsBamlAtRuntime(path.node, types)\n ? bamlRegistrationModuleFor(\n sourceFilename(state.file.opts.filename ?? \"\"),\n state.opts.bamlRegistrationModule,\n )\n : null\n if (bamlRegistrationModule !== null) {\n path.unshiftContainer(\n \"body\",\n types.importDeclaration(\n [],\n types.stringLiteral(bamlRegistrationModule),\n ),\n )\n state.file.metadata[AUTO_TRACE_TRANSFORM_MARKER] = true\n }\n if (\n state.skipFile ||\n !state.usedRuntime ||\n !state.runtimeIdentifier ||\n !state.activeIdentifier ||\n !state.wrapperIdentifier\n ) {\n return\n }\n\n state.file.metadata[AUTO_TRACE_TRANSFORM_MARKER] = true\n path.unshiftContainer(\"body\", [\n types.importDeclaration(\n [\n types.importSpecifier(\n state.runtimeIdentifier,\n types.identifier(\"__bitfabAutoSpan\"),\n ),\n types.importSpecifier(\n state.activeIdentifier,\n types.identifier(\"__bitfabAutoTraceActive\"),\n ),\n ...(state.usedWrapper\n ? [\n types.importSpecifier(\n state.wrapperIdentifier,\n types.identifier(\"__bitfabAutoWrap\"),\n ),\n ]\n : []),\n ...RECORDED_CALL_RUNTIMES.flatMap((call) => {\n const identifier = state.recordedCallIdentifiers?.get(\n call.runtimeExport,\n )\n return state.usedRecordedCalls?.has(call.runtimeExport) &&\n identifier\n ? [\n types.importSpecifier(\n identifier,\n types.identifier(call.runtimeExport),\n ),\n ]\n : []\n }),\n ],\n types.stringLiteral(\n state.opts.runtimeModule ?? \"@bitfab/sdk/auto\",\n ),\n ),\n types.variableDeclaration(\"const\", [\n types.variableDeclarator(\n types.identifier(AUTO_TRACE_TRANSFORM_MARKER),\n types.assignmentExpression(\n \"=\",\n types.memberExpression(\n types.identifier(\"globalThis\"),\n types.identifier(AUTO_TRACE_TRANSFORM_MARKER),\n ),\n types.booleanLiteral(true),\n ),\n ),\n ]),\n ...(state.definitions ?? []),\n ])\n },\n },\n CallExpression: {\n exit(\n path: NodePath<BabelTypes.CallExpression>,\n state: BitfabPluginState,\n ) {\n if (state.skipFile) {\n return\n }\n if (recordedCallTarget(path.node, types) !== null) {\n rewriteRecordedClientCall(path, state, types)\n return\n }\n const configuredName = withNodeFunctionName(path, types)\n if (configuredName === null) {\n return\n }\n if (path.node.arguments.length === 1) {\n path.node.arguments.push(types.identifier(\"undefined\"))\n }\n path.node.arguments.push(types.stringLiteral(configuredName))\n },\n },\n OptionalCallExpression: {\n exit(\n path: NodePath<BabelTypes.OptionalCallExpression>,\n state: BitfabPluginState,\n ) {\n rewriteRecordedClientCall(path, state, types)\n },\n },\n Function: {\n exit(path: NodePath<BabelTypes.Function>, state: BitfabPluginState) {\n const node = path.node as typeof path.node & InstrumentedFunction\n if (\n state.skipFile ||\n node._bitfabInstrumented ||\n !isInstrumentableFunction(node, types) ||\n isTraceDecoratorRoot(path, types) ||\n !state.runtimeIdentifier ||\n !state.activeIdentifier ||\n !state.wrapperIdentifier\n ) {\n return\n }\n const bamlMethod =\n state.bamlGenerated === true && isBamlClientMethod(path, types)\n if (state.bamlGenerated && !bamlMethod) {\n return\n }\n if (isJevMethodDefinition(path, types)) {\n return\n }\n const name = qualifiedFunctionName(path, types)\n if (name.startsWith(\"anonymous-\")) {\n return\n }\n const normalizedFilename = autoTraceFilename(\n state.file.opts.filename ?? \"unknown\",\n state.opts.cwd ?? state.file.opts.cwd ?? process.cwd(),\n )\n const { line, column } = sourcePosition(path)\n const definition = types.objectExpression([\n types.objectProperty(\n types.identifier(\"id\"),\n types.stringLiteral(\n autoTraceFunctionId(normalizedFilename, name),\n ),\n ),\n types.objectProperty(\n types.identifier(\"name\"),\n types.stringLiteral(name),\n ),\n types.objectProperty(\n types.identifier(\"file\"),\n types.stringLiteral(normalizedFilename),\n ),\n types.objectProperty(\n types.identifier(\"line\"),\n types.numericLiteral(line),\n ),\n types.objectProperty(\n types.identifier(\"column\"),\n types.numericLiteral(column),\n ),\n ...(node.async\n ? [\n types.objectProperty(\n types.identifier(\"async\"),\n types.booleanLiteral(true),\n ),\n ]\n : []),\n ...(bamlMethod\n ? [\n types.objectProperty(\n types.identifier(\"baml\"),\n types.booleanLiteral(true),\n ),\n ]\n : []),\n ...(isRestWrapper(path, types)\n ? [\n types.objectProperty(\n types.identifier(\"wrapper\"),\n types.booleanLiteral(true),\n ),\n ]\n : []),\n ])\n const definitionIdentifier = path.scope\n .getProgramParent()\n .generateUidIdentifier(\"bitfabAutoDefinition\")\n state.definitions?.push(\n types.variableDeclaration(\"const\", [\n types.variableDeclarator(definitionIdentifier, definition),\n ]),\n )\n\n if (needsArgumentWrapper(path, types)) {\n node._bitfabInstrumented = true\n path.replaceWith(\n types.callExpression(types.cloneNode(state.wrapperIdentifier), [\n types.cloneNode(definitionIdentifier),\n node as BabelTypes.ArrowFunctionExpression,\n ]),\n )\n state.usedRuntime = true\n state.usedWrapper = true\n return\n }\n\n const originalBody = types.isBlockStatement(node.body)\n ? node.body\n : types.blockStatement([types.returnStatement(node.body)])\n const directives = originalBody.directives\n originalBody.directives = []\n\n const callerOptions = bamlMethod\n ? path.scope.generateUidIdentifier(\"bitfabBamlOptions\")\n : undefined\n const withCollector = bamlMethod\n ? path.scope.generateUidIdentifier(\"bitfabBamlWithCollector\")\n : undefined\n const tracedBody =\n callerOptions && withCollector\n ? types.blockStatement(\n [\n bamlOptionsDeclaration(callerOptions, withCollector, types),\n ...types.cloneNode(originalBody, true).body,\n ],\n [],\n )\n : types.cloneNode(originalBody, true)\n const body = types.blockStatement(\n [\n types.ifStatement(\n types.callExpression(\n types.cloneNode(state.activeIdentifier),\n [],\n ),\n types.blockStatement([\n ...(callerOptions\n ? [\n types.variableDeclaration(\"const\", [\n types.variableDeclarator(\n callerOptions,\n types.identifier(BAML_OPTIONS_PARAMETER),\n ),\n ]),\n ]\n : []),\n types.returnStatement(\n types.callExpression(\n types.cloneNode(state.runtimeIdentifier),\n [\n types.cloneNode(definitionIdentifier),\n parameterInputs(path, types),\n types.arrowFunctionExpression(\n withCollector ? [types.cloneNode(withCollector)] : [],\n tracedBody,\n node.async ?? false,\n ),\n ],\n ),\n ),\n ]),\n ),\n ...originalBody.body,\n ],\n directives,\n )\n node.body = body\n node._bitfabInstrumented = true\n state.usedRuntime = true\n },\n },\n },\n }\n}\n","import { type InputOptions, transformSync } from \"@babel/core\"\nimport bitfabBabelPlugin from \"./babelPlugin.js\"\nimport type { BitfabTransformOptions } from \"./transformOptions.js\"\nimport {\n AUTO_TRACE_TRANSFORM_MARKER,\n shouldTransformBitfabFile,\n sourceFilename,\n} from \"./transformOptions.js\"\n\nexport type { BitfabTransformOptions } from \"./transformOptions.js\"\n\ntype ParserPlugin = NonNullable<\n NonNullable<InputOptions[\"parserOpts\"]>[\"plugins\"]\n>[number]\n\nexport interface BitfabSourceMap {\n version: number\n sources: string[]\n names: string[]\n mappings: string\n file?: string\n sourceRoot?: string\n sourcesContent?: Array<string | null>\n}\n\nexport interface BitfabTransformResult {\n code: string\n map?: BitfabSourceMap\n}\n\nexport function parserPlugins(filename: string): ParserPlugin[] {\n const path = sourceFilename(filename)\n const typescript = /\\.[cm]?tsx?$/.test(path)\n const jsx = /\\.tsx$/.test(path) || /\\.[cm]?jsx?$/.test(path)\n return [\n ...(typescript ? ([\"typescript\"] as const) : []),\n ...(jsx ? ([\"jsx\"] as const) : []),\n \"decorators\",\n ]\n}\n\nexport function transformBitfabSource(\n source: string,\n filename: string,\n options: BitfabTransformOptions = {},\n): BitfabTransformResult {\n if (!shouldTransformBitfabFile(filename, options)) {\n return { code: source }\n }\n const result = transformSync(source, {\n babelrc: false,\n configFile: false,\n filename: sourceFilename(filename),\n parserOpts: { plugins: parserPlugins(filename), sourceType: \"module\" },\n plugins: [[bitfabBabelPlugin, options]],\n sourceMaps: true,\n })\n if (!result?.code || !result.metadata?.[AUTO_TRACE_TRANSFORM_MARKER]) {\n return { code: source }\n }\n return {\n code: result.code,\n ...(result.map ? { map: result.map as BitfabSourceMap } : {}),\n }\n}\n","import { dirname } from \"node:path\"\nimport {\n type PluginItem,\n transformFromAstSync,\n transformSync,\n} from \"@babel/core\"\nimport decoratorsPlugin from \"@babel/plugin-proposal-decorators\"\nimport commonJsPlugin from \"@babel/plugin-transform-modules-commonjs\"\nimport reactJsxPlugin from \"@babel/plugin-transform-react-jsx\"\nimport typeScriptPlugin from \"@babel/plugin-transform-typescript\"\nimport { getTsconfig, parseTsconfig, type TsConfigJson } from \"get-tsconfig\"\nimport bitfabBabelPlugin from \"./babelPlugin.js\"\nimport { parserPlugins } from \"./transform.js\"\nimport type { BitfabTransformOptions } from \"./transformOptions.js\"\nimport {\n shouldTransformBitfabFile,\n sourceFilename,\n} from \"./transformOptions.js\"\n\nexport interface BitfabLoaderOptions\n extends Omit<BitfabTransformOptions, \"include\"> {\n tsconfig?: string\n}\n\nexport interface BitfabJavaScriptTransformResult {\n code: string\n map?: string\n}\n\ntype CompilerOptions = NonNullable<TsConfigJson[\"compilerOptions\"]>\n\nfunction readCompilerOptions(\n filename: string,\n configuredPath: string | undefined,\n): CompilerOptions {\n const config = configuredPath\n ? parseTsconfig(configuredPath)\n : getTsconfig(dirname(filename))?.config\n return config?.compilerOptions ?? {}\n}\n\nfunction reactJsxOptions(compilerOptions: CompilerOptions): PluginItem {\n if (compilerOptions.jsx === \"react\") {\n return [\n reactJsxPlugin,\n {\n runtime: \"classic\",\n ...(compilerOptions.jsxFactory && {\n pragma: compilerOptions.jsxFactory,\n }),\n ...(compilerOptions.jsxFragmentFactory && {\n pragmaFrag: compilerOptions.jsxFragmentFactory,\n }),\n },\n ]\n }\n return [\n reactJsxPlugin,\n {\n runtime: \"automatic\",\n importSource: compilerOptions.jsxImportSource ?? \"react\",\n },\n ]\n}\n\nfunction compilePlugins(\n filename: string,\n compilerOptions: CompilerOptions,\n format: \"commonjs\" | \"module\" | undefined,\n): PluginItem[] {\n const path = sourceFilename(filename)\n const isTypeScript = /\\.[cm]?tsx?$/.test(path)\n const hasJsx = /\\.[jt]sx$/.test(path)\n const isCommonJs = format === \"commonjs\" || path.endsWith(\".cts\")\n return [\n ...(isTypeScript\n ? [\n [\n typeScriptPlugin,\n {\n onlyRemoveTypeImports:\n compilerOptions.verbatimModuleSyntax === true,\n },\n ] satisfies PluginItem,\n ]\n : []),\n [\n decoratorsPlugin,\n {\n version: compilerOptions.experimentalDecorators ? \"legacy\" : \"2023-11\",\n },\n ],\n ...(hasJsx ? [reactJsxOptions(compilerOptions)] : []),\n ...(isCommonJs ? [commonJsPlugin] : []),\n ]\n}\n\nexport function transformBitfabModuleToJavaScript(\n source: string,\n filename: string,\n options: BitfabLoaderOptions = {},\n format?: \"commonjs\" | \"module\",\n sourceMapMode: \"external\" | \"inline\" = \"external\",\n): BitfabJavaScriptTransformResult {\n const { tsconfig, ...transformOptions } = options\n if (!shouldTransformBitfabFile(filename, transformOptions)) {\n return { code: source }\n }\n const sourceFile = sourceFilename(filename)\n const instrumented = transformSync(source, {\n ast: true,\n babelrc: false,\n code: false,\n configFile: false,\n filename: sourceFile,\n parserOpts: { plugins: parserPlugins(filename), sourceType: \"module\" },\n plugins: [[bitfabBabelPlugin, transformOptions]],\n })\n if (!instrumented?.ast) {\n throw new Error(`Bitfab could not parse ${sourceFile}`)\n }\n const compiled = transformFromAstSync(instrumented.ast, source, {\n babelrc: false,\n cloneInputAst: false,\n configFile: false,\n filename: sourceFile,\n plugins: compilePlugins(\n filename,\n readCompilerOptions(filename, tsconfig),\n format,\n ),\n sourceMaps: sourceMapMode === \"inline\" ? \"inline\" : true,\n })\n if (compiled?.code === undefined || compiled.code === null) {\n throw new Error(`Bitfab could not compile ${sourceFile}`)\n }\n return {\n code: compiled.code,\n ...(compiled.map ? { map: JSON.stringify(compiled.map) } : {}),\n }\n}\n","import { readFile } from \"node:fs/promises\"\nimport { createRequire } from \"node:module\"\nimport { isAbsolute, relative, resolve as resolvePath } from \"node:path\"\nimport { fileURLToPath, pathToFileURL } from \"node:url\"\nimport { transformBitfabModuleToJavaScript } from \"./loaderRuntime.js\"\nimport { shouldTransformBitfabFile } from \"./transformOptions.js\"\n\nconst runtimeParentURL =\n process.env.BITFAB_SDK_RESOLVE_FROM === undefined\n ? import.meta.url\n : pathToFileURL(resolvePath(process.env.BITFAB_SDK_RESOLVE_FROM)).href\n\ninterface NodeResolveContext {\n parentURL?: string\n conditions?: string[]\n importAttributes?: Record<string, string>\n}\n\nexport async function resolve(\n specifier: string,\n context: NodeResolveContext,\n nextResolve: (\n specifier: string,\n context: NodeResolveContext,\n ) => Promise<{ url: string }>,\n): Promise<{ url: string }> {\n return specifier === \"bitfab:runtime/auto\"\n ? nextResolve(\"@bitfab/sdk/auto\", {\n ...context,\n parentURL: runtimeParentURL,\n })\n : nextResolve(specifier, context)\n}\n\ninterface NodeLoadContext {\n format?: string\n}\n\ninterface NodeLoadResult {\n format?: string\n shortCircuit?: boolean\n source?: string | ArrayBuffer | Uint8Array\n}\n\ntype NextLoad = (\n url: string,\n context: NodeLoadContext,\n) => Promise<NodeLoadResult>\n\nfunction runtimeFormat(\n format: string | undefined,\n filename: string,\n): \"commonjs\" | \"module\" {\n return format?.startsWith(\"commonjs\") || /\\.c(?:js|ts)$/.test(filename)\n ? \"commonjs\"\n : \"module\"\n}\n\nfunction isInsideWorkingDirectory(filename: string): boolean {\n const path = relative(process.cwd(), filename)\n return (\n path !== \"..\" &&\n !path.startsWith(`..${process.platform === \"win32\" ? \"\\\\\" : \"/\"}`) &&\n !isAbsolute(path)\n )\n}\n\nexport async function load(\n url: string,\n context: NodeLoadContext,\n nextLoad: NextLoad,\n): Promise<NodeLoadResult> {\n if (!url.startsWith(\"file:\")) {\n return nextLoad(url, context)\n }\n\n const filename = fileURLToPath(url)\n if (\n !isInsideWorkingDirectory(filename) ||\n !shouldTransformBitfabFile(filename, {})\n ) {\n return nextLoad(url, context)\n }\n\n const source = await readFile(filename, \"utf8\")\n const format = runtimeFormat(context.format, filename)\n const transformed = transformBitfabModuleToJavaScript(\n source,\n filename,\n format === \"commonjs\"\n ? {\n runtimeModule:\n createRequire(runtimeParentURL).resolve(\"@bitfab/sdk/auto\"),\n bamlRegistrationModule: false,\n }\n : { runtimeModule: \"bitfab:runtime/auto\", bamlRegistrationModule: false },\n format,\n \"inline\",\n )\n return {\n format,\n shortCircuit: true,\n source: transformed.code,\n }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAM,iCAAiC;AACvC,MAAa,8BACX;AAEF,SAAgB,oBAAoB,MAAc,MAAsB;CACtE,OAAO,GAAG,+BAA+B,GAAG,KAAK,GAAG;AACtD;AAEA,SAAgB,eAAe,UAA0B;CACvD,OAAO,SAAS,QAAQ,OAAO,GAAG,CAAC,CAAC,MAAM,QAAQ,CAAC,CAAC,CAAC,MAAM;AAC7D;AAEA,SAAgB,kBAAkB,UAAkB,KAAqB;CACvE,MAAM,aAAa,eAAe,QAAQ;CAC1C,MAAM,gBAAgB,IAAI,QAAQ,OAAO,GAAG,CAAC,CAAC,QAAQ,OAAO,EAAE;CAC/D,OAAO,WAAW,WAAW,GAAG,cAAc,EAAE,IAC5C,WAAW,MAAM,cAAc,SAAS,CAAC,IACzC;AACN;AAEA,SAAgB,0BACd,UACA,SACS;CACT,IAAI,CAAC,UACH,OAAO;CAET,IAAI,QAAQ,WAAW,CAAC,QAAQ,QAAQ,QAAQ,GAC9C,OAAO;CAGT,MAAM,aAAa,eAAe,QAAQ;CAC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AQ,IAAI,GAAG,QAAQ;CAC7C,OACE,SAAS,QACT,CAAC,KAAK,WAAW,KAAK,QAAQ,aAAa,UAAU,OAAO,KAAK,KACjE,CAAC,WAAW,IAAI;AAEpB;AAEA,eAAsB,KACpB,KACA,SACA,UACyB;CACzB,IAAI,CAAC,IAAI,WAAW,OAAO,GACzB,OAAO,SAAS,KAAK,OAAO;CAG9B,MAAM,WAAW,cAAc,GAAG;CAClC,IACE,CAAC,yBAAyB,QAAQ,KAClC,CAAC,0BAA0B,UAAU,CAAC,CAAC,GAEvC,OAAO,SAAS,KAAK,OAAO;CAG9B,MAAM,SAAS,MAAM,SAAS,UAAU,MAAM;CAC9C,MAAM,SAAS,cAAc,QAAQ,QAAQ,QAAQ;CAcrD,OAAO;EACL;EACA,cAAc;EACd,QAhBkB,kCAClB,QACA,UACA,WAAW,aACP;GACE,eACE,cAAc,gBAAgB,CAAC,CAAC,QAAQ,kBAAkB;GAC5D,wBAAwB;EAC1B,IACA;GAAE,eAAe;GAAuB,wBAAwB;EAAM,GAC1E,QACA,QAKkB,CAAC,CAAC;CACtB;AACF"}
|
package/dist/transform/swc.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_transform = require("../transform-
|
|
5
|
+
const require_transform = require("../transform-CclhVghC.cjs");
|
|
6
6
|
//#region ../bitfab-typescript-transform/src/swcAdapter.ts
|
|
7
7
|
function swcOptions(transformed, options) {
|
|
8
8
|
return {
|
package/dist/transform/swc.js
CHANGED
|
@@ -2,8 +2,8 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_babelPlugin = require("../babelPlugin-
|
|
6
|
-
const require_transform = require("../transform-
|
|
5
|
+
const require_babelPlugin = require("../babelPlugin-Btzkfl62.cjs");
|
|
6
|
+
const require_transform = require("../transform-CclhVghC.cjs");
|
|
7
7
|
//#region ../bitfab-typescript-transform/src/unplugin.ts
|
|
8
8
|
const bitfabTraceUnplugin = (0, require("unplugin").createUnplugin)((options) => {
|
|
9
9
|
const resolvedOptions = options ?? {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as shouldTransformBitfabFile } from "../babelPlugin-
|
|
2
|
-
import { n as transformBitfabSource } from "../transform-
|
|
1
|
+
import { r as shouldTransformBitfabFile } from "../babelPlugin-398AO0eD.js";
|
|
2
|
+
import { n as transformBitfabSource } from "../transform-BBlyY-tA.js";
|
|
3
3
|
import { createUnplugin } from "unplugin";
|
|
4
4
|
//#region ../bitfab-typescript-transform/src/unplugin.ts
|
|
5
5
|
const bitfabTraceUnplugin = createUnplugin((options) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as sourceFilename, r as shouldTransformBitfabFile, t as bitfabBabelPlugin } from "./babelPlugin-
|
|
1
|
+
import { i as sourceFilename, r as shouldTransformBitfabFile, t as bitfabBabelPlugin } from "./babelPlugin-398AO0eD.js";
|
|
2
2
|
import { transformSync } from "@babel/core";
|
|
3
3
|
//#region ../bitfab-typescript-transform/src/transform.ts
|
|
4
4
|
function parserPlugins(filename) {
|
|
@@ -33,4 +33,4 @@ function transformBitfabSource(source, filename, options = {}) {
|
|
|
33
33
|
//#endregion
|
|
34
34
|
export { transformBitfabSource as n, parserPlugins as t };
|
|
35
35
|
|
|
36
|
-
//# sourceMappingURL=transform-
|
|
36
|
+
//# sourceMappingURL=transform-BBlyY-tA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-
|
|
1
|
+
{"version":3,"file":"transform-BBlyY-tA.js","names":[],"sources":["../../bitfab-typescript-transform/src/transform.ts"],"sourcesContent":["import { type InputOptions, transformSync } from \"@babel/core\"\nimport bitfabBabelPlugin from \"./babelPlugin.js\"\nimport type { BitfabTransformOptions } from \"./transformOptions.js\"\nimport {\n AUTO_TRACE_TRANSFORM_MARKER,\n shouldTransformBitfabFile,\n sourceFilename,\n} from \"./transformOptions.js\"\n\nexport type { BitfabTransformOptions } from \"./transformOptions.js\"\n\ntype ParserPlugin = NonNullable<\n NonNullable<InputOptions[\"parserOpts\"]>[\"plugins\"]\n>[number]\n\nexport interface BitfabSourceMap {\n version: number\n sources: string[]\n names: string[]\n mappings: string\n file?: string\n sourceRoot?: string\n sourcesContent?: Array<string | null>\n}\n\nexport interface BitfabTransformResult {\n code: string\n map?: BitfabSourceMap\n}\n\nexport function parserPlugins(filename: string): ParserPlugin[] {\n const path = sourceFilename(filename)\n const typescript = /\\.[cm]?tsx?$/.test(path)\n const jsx = /\\.tsx$/.test(path) || /\\.[cm]?jsx?$/.test(path)\n return [\n ...(typescript ? ([\"typescript\"] as const) : []),\n ...(jsx ? ([\"jsx\"] as const) : []),\n \"decorators\",\n ]\n}\n\nexport function transformBitfabSource(\n source: string,\n filename: string,\n options: BitfabTransformOptions = {},\n): BitfabTransformResult {\n if (!shouldTransformBitfabFile(filename, options)) {\n return { code: source }\n }\n const result = transformSync(source, {\n babelrc: false,\n configFile: false,\n filename: sourceFilename(filename),\n parserOpts: { plugins: parserPlugins(filename), sourceType: \"module\" },\n plugins: [[bitfabBabelPlugin, options]],\n sourceMaps: true,\n })\n if (!result?.code || !result.metadata?.[AUTO_TRACE_TRANSFORM_MARKER]) {\n return { code: source }\n }\n return {\n code: result.code,\n ...(result.map ? { map: result.map as BitfabSourceMap } : {}),\n }\n}\n"],"mappings":";;;AA8BA,SAAgB,cAAc,UAAkC;CAC9D,MAAM,OAAO,eAAe,QAAQ;CACpC,MAAM,aAAa,eAAe,KAAK,IAAI;CAC3C,MAAM,MAAM,SAAS,KAAK,IAAI,KAAK,eAAe,KAAK,IAAI;CAC3D,OAAO;EACL,GAAI,aAAc,CAAC,YAAY,IAAc,CAAC;EAC9C,GAAI,MAAO,CAAC,KAAK,IAAc,CAAC;EAChC;CACF;AACF;AAEA,SAAgB,sBACd,QACA,UACA,UAAkC,CAAC,GACZ;CACvB,IAAI,CAAC,0BAA0B,UAAU,OAAO,GAC9C,OAAO,EAAE,MAAM,OAAO;CAExB,MAAM,SAAS,cAAc,QAAQ;EACnC,SAAS;EACT,YAAY;EACZ,UAAU,eAAe,QAAQ;EACjC,YAAY;GAAE,SAAS,cAAc,QAAQ;GAAG,YAAY;EAAS;EACrE,SAAS,CAAC,CAAC,mBAAmB,OAAO,CAAC;EACtC,YAAY;CACd,CAAC;CACD,IAAI,CAAC,QAAQ,QAAQ,CAAC,OAAO,WAAA,yCAC3B,OAAO,EAAE,MAAM,OAAO;CAExB,OAAO;EACL,MAAM,OAAO;EACb,GAAI,OAAO,MAAM,EAAE,KAAK,OAAO,IAAuB,IAAI,CAAC;CAC7D;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_babelPlugin = require("./babelPlugin-
|
|
1
|
+
const require_babelPlugin = require("./babelPlugin-Btzkfl62.cjs");
|
|
2
2
|
let _babel_core = require("@babel/core");
|
|
3
3
|
//#region ../bitfab-typescript-transform/src/transform.ts
|
|
4
4
|
function parserPlugins(filename) {
|
|
@@ -44,4 +44,4 @@ Object.defineProperty(exports, "transformBitfabSource", {
|
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
//# sourceMappingURL=transform-
|
|
47
|
+
//# sourceMappingURL=transform-CclhVghC.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-
|
|
1
|
+
{"version":3,"file":"transform-CclhVghC.cjs","names":["sourceFilename","shouldTransformBitfabFile","transformSync","bitfabBabelPlugin"],"sources":["../../bitfab-typescript-transform/src/transform.ts"],"sourcesContent":["import { type InputOptions, transformSync } from \"@babel/core\"\nimport bitfabBabelPlugin from \"./babelPlugin.js\"\nimport type { BitfabTransformOptions } from \"./transformOptions.js\"\nimport {\n AUTO_TRACE_TRANSFORM_MARKER,\n shouldTransformBitfabFile,\n sourceFilename,\n} from \"./transformOptions.js\"\n\nexport type { BitfabTransformOptions } from \"./transformOptions.js\"\n\ntype ParserPlugin = NonNullable<\n NonNullable<InputOptions[\"parserOpts\"]>[\"plugins\"]\n>[number]\n\nexport interface BitfabSourceMap {\n version: number\n sources: string[]\n names: string[]\n mappings: string\n file?: string\n sourceRoot?: string\n sourcesContent?: Array<string | null>\n}\n\nexport interface BitfabTransformResult {\n code: string\n map?: BitfabSourceMap\n}\n\nexport function parserPlugins(filename: string): ParserPlugin[] {\n const path = sourceFilename(filename)\n const typescript = /\\.[cm]?tsx?$/.test(path)\n const jsx = /\\.tsx$/.test(path) || /\\.[cm]?jsx?$/.test(path)\n return [\n ...(typescript ? ([\"typescript\"] as const) : []),\n ...(jsx ? ([\"jsx\"] as const) : []),\n \"decorators\",\n ]\n}\n\nexport function transformBitfabSource(\n source: string,\n filename: string,\n options: BitfabTransformOptions = {},\n): BitfabTransformResult {\n if (!shouldTransformBitfabFile(filename, options)) {\n return { code: source }\n }\n const result = transformSync(source, {\n babelrc: false,\n configFile: false,\n filename: sourceFilename(filename),\n parserOpts: { plugins: parserPlugins(filename), sourceType: \"module\" },\n plugins: [[bitfabBabelPlugin, options]],\n sourceMaps: true,\n })\n if (!result?.code || !result.metadata?.[AUTO_TRACE_TRANSFORM_MARKER]) {\n return { code: source }\n }\n return {\n code: result.code,\n ...(result.map ? { map: result.map as BitfabSourceMap } : {}),\n }\n}\n"],"mappings":";;;AA8BA,SAAgB,cAAc,UAAkC;CAC9D,MAAM,OAAOA,oBAAAA,eAAe,QAAQ;CACpC,MAAM,aAAa,eAAe,KAAK,IAAI;CAC3C,MAAM,MAAM,SAAS,KAAK,IAAI,KAAK,eAAe,KAAK,IAAI;CAC3D,OAAO;EACL,GAAI,aAAc,CAAC,YAAY,IAAc,CAAC;EAC9C,GAAI,MAAO,CAAC,KAAK,IAAc,CAAC;EAChC;CACF;AACF;AAEA,SAAgB,sBACd,QACA,UACA,UAAkC,CAAC,GACZ;CACvB,IAAI,CAACC,oBAAAA,0BAA0B,UAAU,OAAO,GAC9C,OAAO,EAAE,MAAM,OAAO;CAExB,MAAM,UAAA,GAASC,YAAAA,cAAAA,CAAc,QAAQ;EACnC,SAAS;EACT,YAAY;EACZ,UAAUF,oBAAAA,eAAe,QAAQ;EACjC,YAAY;GAAE,SAAS,cAAc,QAAQ;GAAG,YAAY;EAAS;EACrE,SAAS,CAAC,CAACG,oBAAAA,mBAAmB,OAAO,CAAC;EACtC,YAAY;CACd,CAAC;CACD,IAAI,CAAC,QAAQ,QAAQ,CAAC,OAAO,WAAA,yCAC3B,OAAO,EAAE,MAAM,OAAO;CAExB,OAAO;EACL,MAAM,OAAO;EACb,GAAI,OAAO,MAAM,EAAE,KAAK,OAAO,IAAuB,IAAI,CAAC;CAC7D;AACF"}
|