@bitfab/sdk 0.65.4 → 0.65.5
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-CZu0BXhG.js +270 -0
- package/dist/autoTrace-CZu0BXhG.js.map +1 -0
- package/dist/autoTrace-KM9pYqk9.cjs +395 -0
- package/dist/autoTrace-KM9pYqk9.cjs.map +1 -0
- package/dist/autoTrace.cjs +15 -353
- package/dist/autoTrace.d.cts +44 -44
- package/dist/autoTrace.d.ts +44 -44
- package/dist/autoTrace.js +1 -28
- package/dist/babelPlugin-C70OxrqA.js +209 -0
- package/dist/babelPlugin-C70OxrqA.js.map +1 -0
- package/dist/babelPlugin-Nta4-VcL.cjs +232 -0
- package/dist/babelPlugin-Nta4-VcL.cjs.map +1 -0
- package/dist/http-CG1Irqxx.js +2154 -0
- package/dist/http-CG1Irqxx.js.map +1 -0
- package/dist/index-BFkAwvuc.d.cts +4410 -0
- package/dist/index-BFkAwvuc.d.ts +4410 -0
- package/dist/index.cjs +48 -12504
- package/dist/index.d.cts +2 -4443
- package/dist/index.d.ts +2 -4443
- package/dist/index.js +3 -96
- package/dist/loaderRuntime-0huddOOP.d.ts +12 -0
- package/dist/loaderRuntime-CslfDFO7.d.cts +12 -0
- package/dist/node.cjs +56 -12520
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +2 -1
- package/dist/node.d.ts +2 -1
- package/dist/node.js +10 -105
- package/dist/node.js.map +1 -1
- package/dist/registryCommand-Di8x0YoJ.js +1111 -0
- package/dist/registryCommand-Di8x0YoJ.js.map +1 -0
- package/dist/replayCli.js +49 -87
- package/dist/replayCli.js.map +1 -1
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/seedCli.js +10 -24
- package/dist/seedCli.js.map +1 -1
- package/dist/src-BRKm0P_S.cjs +8434 -0
- package/dist/src-BRKm0P_S.cjs.map +1 -0
- package/dist/src-CfFkki5l.js +6011 -0
- package/dist/src-CfFkki5l.js.map +1 -0
- package/dist/transform/babel.cjs +5 -422
- package/dist/transform/babel.d.cts +16 -16
- package/dist/transform/babel.d.ts +16 -16
- package/dist/transform/babel.js +1 -7
- package/dist/transform/bun.cjs +9 -478
- package/dist/transform/bun.cjs.map +1 -1
- package/dist/transform/bun.d.cts +5 -7
- package/dist/transform/bun.d.ts +5 -7
- package/dist/transform/bun.js +6 -11
- package/dist/transform/bun.js.map +1 -1
- package/dist/transform/esbuild.cjs +9 -478
- package/dist/transform/esbuild.cjs.map +1 -1
- package/dist/transform/esbuild.d.cts +5 -7
- package/dist/transform/esbuild.d.ts +5 -7
- package/dist/transform/esbuild.js +6 -11
- package/dist/transform/esbuild.js.map +1 -1
- package/dist/transform/loaderRuntime.cjs +85 -532
- package/dist/transform/loaderRuntime.cjs.map +1 -1
- package/dist/transform/loaderRuntime.d.cts +2 -12
- package/dist/transform/loaderRuntime.d.ts +2 -12
- package/dist/transform/loaderRuntime.js +56 -98
- package/dist/transform/loaderRuntime.js.map +1 -1
- package/dist/transform/nest.cjs +12 -481
- package/dist/transform/nest.cjs.map +1 -1
- package/dist/transform/nest.d.cts +8 -9
- package/dist/transform/nest.d.ts +8 -9
- package/dist/transform/nest.js +9 -14
- package/dist/transform/nest.js.map +1 -1
- package/dist/transform/next.cjs +56 -528
- package/dist/transform/next.cjs.map +1 -1
- package/dist/transform/next.d.cts +25 -25
- package/dist/transform/next.d.ts +24 -24
- package/dist/transform/next.js +52 -60
- package/dist/transform/next.js.map +1 -1
- package/dist/transform/nodeLoader.js +260 -506
- package/dist/transform/nodeLoader.js.map +1 -1
- package/dist/transform/register.js +4 -1
- package/dist/transform/register.js.map +1 -1
- package/dist/transform/rolldown.cjs +9 -478
- package/dist/transform/rolldown.cjs.map +1 -1
- package/dist/transform/rolldown.d.cts +5 -7
- package/dist/transform/rolldown.d.ts +5 -7
- package/dist/transform/rolldown.js +6 -11
- package/dist/transform/rolldown.js.map +1 -1
- package/dist/transform/rollup.cjs +9 -478
- package/dist/transform/rollup.cjs.map +1 -1
- package/dist/transform/rollup.d.cts +5 -7
- package/dist/transform/rollup.d.ts +5 -7
- package/dist/transform/rollup.js +6 -11
- package/dist/transform/rollup.js.map +1 -1
- package/dist/transform/rsbuild.cjs +9 -478
- package/dist/transform/rsbuild.cjs.map +1 -1
- package/dist/transform/rsbuild.d.cts +5 -7
- package/dist/transform/rsbuild.d.ts +5 -7
- package/dist/transform/rsbuild.js +6 -11
- package/dist/transform/rsbuild.js.map +1 -1
- package/dist/transform/rspack.cjs +9 -478
- package/dist/transform/rspack.cjs.map +1 -1
- package/dist/transform/rspack.d.cts +5 -7
- package/dist/transform/rspack.d.ts +5 -7
- package/dist/transform/rspack.js +6 -11
- package/dist/transform/rspack.js.map +1 -1
- package/dist/transform/swc.cjs +18 -486
- package/dist/transform/swc.cjs.map +1 -1
- package/dist/transform/swc.d.cts +15 -14
- package/dist/transform/swc.d.ts +15 -14
- package/dist/transform/swc.js +14 -32
- package/dist/transform/swc.js.map +1 -1
- package/dist/transform/unplugin.cjs +20 -476
- package/dist/transform/unplugin.cjs.map +1 -1
- package/dist/transform/unplugin.d.cts +4 -6
- package/dist/transform/unplugin.d.ts +4 -6
- package/dist/transform/unplugin.js +19 -8
- package/dist/transform/unplugin.js.map +1 -1
- package/dist/transform/vite.cjs +9 -478
- package/dist/transform/vite.cjs.map +1 -1
- package/dist/transform/vite.d.cts +5 -7
- package/dist/transform/vite.d.ts +5 -7
- package/dist/transform/vite.js +6 -11
- package/dist/transform/vite.js.map +1 -1
- package/dist/transform/webpack.cjs +9 -478
- package/dist/transform/webpack.cjs.map +1 -1
- package/dist/transform/webpack.d.cts +5 -7
- package/dist/transform/webpack.d.ts +5 -7
- package/dist/transform/webpack.js +6 -11
- package/dist/transform/webpack.js.map +1 -1
- package/dist/transform-BcyUocwm.js +36 -0
- package/dist/transform-BcyUocwm.js.map +1 -0
- package/dist/transform-BjxHGGKc.cjs +47 -0
- package/dist/transform-BjxHGGKc.cjs.map +1 -0
- package/dist/transformOptions-BsjCELkh.d.cts +11 -0
- package/dist/transformOptions-BsjCELkh.d.ts +11 -0
- package/package.json +5 -5
- package/dist/autoTrace.cjs.map +0 -1
- package/dist/autoTrace.js.map +0 -1
- package/dist/chunk-27B3UBSS.js +0 -2547
- package/dist/chunk-27B3UBSS.js.map +0 -1
- package/dist/chunk-B2M4KELA.js +0 -1912
- package/dist/chunk-B2M4KELA.js.map +0 -1
- package/dist/chunk-I233ERUH.js +0 -2979
- package/dist/chunk-I233ERUH.js.map +0 -1
- package/dist/chunk-ISU6FQKY.js +0 -6877
- package/dist/chunk-ISU6FQKY.js.map +0 -1
- package/dist/chunk-MT36GJMW.js +0 -106
- package/dist/chunk-MT36GJMW.js.map +0 -1
- package/dist/chunk-PTCLRG4E.js +0 -28
- package/dist/chunk-PTCLRG4E.js.map +0 -1
- package/dist/chunk-QRNHRY7F.js +0 -270
- package/dist/chunk-QRNHRY7F.js.map +0 -1
- package/dist/chunk-R6M54SPO.js +0 -1176
- package/dist/chunk-R6M54SPO.js.map +0 -1
- package/dist/chunk-SOP5AFMH.js +0 -2060
- package/dist/chunk-SOP5AFMH.js.map +0 -1
- package/dist/chunk-YVJAOGHE.js +0 -45
- package/dist/chunk-YVJAOGHE.js.map +0 -1
- package/dist/chunk-ZG6SHKEF.js +0 -404
- package/dist/chunk-ZG6SHKEF.js.map +0 -1
- package/dist/http-LL3JD2JE.js +0 -24
- package/dist/http-LL3JD2JE.js.map +0 -1
- package/dist/http-QZDTQC3C.js +0 -23
- package/dist/http-QZDTQC3C.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/replay-636XZIS2.js +0 -29
- package/dist/replay-636XZIS2.js.map +0 -1
- package/dist/replay-S4DNF4VR.js +0 -28
- package/dist/replay-S4DNF4VR.js.map +0 -1
- package/dist/transform/babel.cjs.map +0 -1
- package/dist/transform/babel.js.map +0 -1
- package/dist/transformOptions-Df2_Chtc.d.cts +0 -10
- package/dist/transformOptions-Df2_Chtc.d.ts +0 -10
package/dist/transform/swc.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { t as BitfabTransformOptions } from "../transformOptions-BsjCELkh.js";
|
|
2
|
+
import "@babel/core";
|
|
3
|
+
//#region ../bitfab-typescript-transform/src/swcAdapter.d.ts
|
|
3
4
|
interface SwcTransformOutput {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
code: string;
|
|
6
|
+
map?: string;
|
|
6
7
|
}
|
|
7
8
|
interface SwcCompilerLike {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
transform(source: string, options: Record<string, unknown>): Promise<SwcTransformOutput>;
|
|
10
|
+
transformSync(source: string, options: Record<string, unknown>): SwcTransformOutput;
|
|
10
11
|
}
|
|
11
|
-
interface BitfabSwcTransformOptions {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export interface BitfabSwcTransformOptions {
|
|
13
|
+
filename: string;
|
|
14
|
+
bitfab?: BitfabTransformOptions;
|
|
15
|
+
swc?: Record<string, unknown>;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Transform a module with Bitfab before compiling it with SWC.
|
|
@@ -21,12 +22,12 @@ interface BitfabSwcTransformOptions {
|
|
|
21
22
|
*
|
|
22
23
|
* @experimental The generated function identity protocol may change.
|
|
23
24
|
*/
|
|
24
|
-
declare function transformWithBitfabSwc(compiler: SwcCompilerLike, source: string, options: BitfabSwcTransformOptions): Promise<SwcTransformOutput>;
|
|
25
|
+
export declare function transformWithBitfabSwc(compiler: SwcCompilerLike, source: string, options: BitfabSwcTransformOptions): Promise<SwcTransformOutput>;
|
|
25
26
|
/**
|
|
26
27
|
* Synchronous form of {@link transformWithBitfabSwc}.
|
|
27
28
|
*
|
|
28
29
|
* @experimental The generated function identity protocol may change.
|
|
29
30
|
*/
|
|
30
|
-
declare function transformWithBitfabSwcSync(compiler: SwcCompilerLike, source: string, options: BitfabSwcTransformOptions): SwcTransformOutput;
|
|
31
|
-
|
|
32
|
-
export {
|
|
31
|
+
export declare function transformWithBitfabSwcSync(compiler: SwcCompilerLike, source: string, options: BitfabSwcTransformOptions): SwcTransformOutput;
|
|
32
|
+
//#endregion
|
|
33
|
+
export {};
|
package/dist/transform/swc.js
CHANGED
|
@@ -1,39 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "../chunk-YVJAOGHE.js";
|
|
4
|
-
import "../chunk-ZG6SHKEF.js";
|
|
5
|
-
|
|
6
|
-
// ../bitfab-typescript-transform/src/swcAdapter.ts
|
|
1
|
+
import { n as transformBitfabSource } from "../transform-BcyUocwm.js";
|
|
2
|
+
//#region ../bitfab-typescript-transform/src/swcAdapter.ts
|
|
7
3
|
function swcOptions(transformed, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
...options.swc
|
|
14
|
-
};
|
|
4
|
+
return {
|
|
5
|
+
filename: options.filename,
|
|
6
|
+
...transformed.map && { inputSourceMap: JSON.stringify(transformed.map) },
|
|
7
|
+
...options.swc
|
|
8
|
+
};
|
|
15
9
|
}
|
|
16
10
|
async function transformWithBitfabSwc(compiler, source, options) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
options.filename,
|
|
20
|
-
options.bitfab
|
|
21
|
-
);
|
|
22
|
-
return compiler.transform(transformed.code, swcOptions(transformed, options));
|
|
11
|
+
const transformed = transformBitfabSource(source, options.filename, options.bitfab);
|
|
12
|
+
return compiler.transform(transformed.code, swcOptions(transformed, options));
|
|
23
13
|
}
|
|
24
14
|
function transformWithBitfabSwcSync(compiler, source, options) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
options.filename,
|
|
28
|
-
options.bitfab
|
|
29
|
-
);
|
|
30
|
-
return compiler.transformSync(
|
|
31
|
-
transformed.code,
|
|
32
|
-
swcOptions(transformed, options)
|
|
33
|
-
);
|
|
15
|
+
const transformed = transformBitfabSource(source, options.filename, options.bitfab);
|
|
16
|
+
return compiler.transformSync(transformed.code, swcOptions(transformed, options));
|
|
34
17
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { transformWithBitfabSwc, transformWithBitfabSwcSync };
|
|
20
|
+
|
|
39
21
|
//# sourceMappingURL=swc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../bitfab-typescript-transform/src/swcAdapter.ts"],"sourcesContent":["import {\n type BitfabTransformOptions,\n type BitfabTransformResult,\n transformBitfabSource,\n} from \"./transform.js\"\n\ninterface SwcTransformOutput {\n code: string\n map?: string\n}\n\ninterface SwcCompilerLike {\n transform(\n source: string,\n options: Record<string, unknown>,\n ): Promise<SwcTransformOutput>\n transformSync(\n source: string,\n options: Record<string, unknown>,\n ): SwcTransformOutput\n}\n\nexport interface BitfabSwcTransformOptions {\n filename: string\n bitfab?: BitfabTransformOptions\n swc?: Record<string, unknown>\n}\n\nfunction swcOptions(\n transformed: BitfabTransformResult,\n options: BitfabSwcTransformOptions,\n): Record<string, unknown> {\n return {\n filename: options.filename,\n ...(transformed.map && {\n inputSourceMap: JSON.stringify(transformed.map),\n }),\n ...options.swc,\n }\n}\n\n/**\n * Transform a module with Bitfab before compiling it with SWC.\n *\n * This programmatic adapter runs before SWC's decorator lowering, which lets\n * normal `@bitfab.trace()` decorators remain the only root marker.\n *\n * @experimental The generated function identity protocol may change.\n */\nexport async function transformWithBitfabSwc(\n compiler: SwcCompilerLike,\n source: string,\n options: BitfabSwcTransformOptions,\n): Promise<SwcTransformOutput> {\n const transformed = transformBitfabSource(\n source,\n options.filename,\n options.bitfab,\n )\n return compiler.transform(transformed.code, swcOptions(transformed, options))\n}\n\n/**\n * Synchronous form of {@link transformWithBitfabSwc}.\n *\n * @experimental The generated function identity protocol may change.\n */\nexport function transformWithBitfabSwcSync(\n compiler: SwcCompilerLike,\n source: string,\n options: BitfabSwcTransformOptions,\n): SwcTransformOutput {\n const transformed = transformBitfabSource(\n source,\n options.filename,\n options.bitfab,\n )\n return compiler.transformSync(\n transformed.code,\n swcOptions(transformed, options),\n )\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"swc.js","names":[],"sources":["../../../bitfab-typescript-transform/src/swcAdapter.ts"],"sourcesContent":["import {\n type BitfabTransformOptions,\n type BitfabTransformResult,\n transformBitfabSource,\n} from \"./transform.js\"\n\ninterface SwcTransformOutput {\n code: string\n map?: string\n}\n\ninterface SwcCompilerLike {\n transform(\n source: string,\n options: Record<string, unknown>,\n ): Promise<SwcTransformOutput>\n transformSync(\n source: string,\n options: Record<string, unknown>,\n ): SwcTransformOutput\n}\n\nexport interface BitfabSwcTransformOptions {\n filename: string\n bitfab?: BitfabTransformOptions\n swc?: Record<string, unknown>\n}\n\nfunction swcOptions(\n transformed: BitfabTransformResult,\n options: BitfabSwcTransformOptions,\n): Record<string, unknown> {\n return {\n filename: options.filename,\n ...(transformed.map && {\n inputSourceMap: JSON.stringify(transformed.map),\n }),\n ...options.swc,\n }\n}\n\n/**\n * Transform a module with Bitfab before compiling it with SWC.\n *\n * This programmatic adapter runs before SWC's decorator lowering, which lets\n * normal `@bitfab.trace()` decorators remain the only root marker.\n *\n * @experimental The generated function identity protocol may change.\n */\nexport async function transformWithBitfabSwc(\n compiler: SwcCompilerLike,\n source: string,\n options: BitfabSwcTransformOptions,\n): Promise<SwcTransformOutput> {\n const transformed = transformBitfabSource(\n source,\n options.filename,\n options.bitfab,\n )\n return compiler.transform(transformed.code, swcOptions(transformed, options))\n}\n\n/**\n * Synchronous form of {@link transformWithBitfabSwc}.\n *\n * @experimental The generated function identity protocol may change.\n */\nexport function transformWithBitfabSwcSync(\n compiler: SwcCompilerLike,\n source: string,\n options: BitfabSwcTransformOptions,\n): SwcTransformOutput {\n const transformed = transformBitfabSource(\n source,\n options.filename,\n options.bitfab,\n )\n return compiler.transformSync(\n transformed.code,\n swcOptions(transformed, options),\n )\n}\n"],"mappings":";;AA4BA,SAAS,WACP,aACA,SACyB;CACzB,OAAO;EACL,UAAU,QAAQ;EAClB,GAAI,YAAY,OAAO,EACrB,gBAAgB,KAAK,UAAU,YAAY,GAAG,EAChD;EACA,GAAG,QAAQ;CACb;AACF;AAUA,eAAsB,uBACpB,UACA,QACA,SAC6B;CAC7B,MAAM,cAAc,sBAClB,QACA,QAAQ,UACR,QAAQ,MACV;CACA,OAAO,SAAS,UAAU,YAAY,MAAM,WAAW,aAAa,OAAO,CAAC;AAC9E;AAOA,SAAgB,2BACd,UACA,QACA,SACoB;CACpB,MAAM,cAAc,sBAClB,QACA,QAAQ,UACR,QAAQ,MACV;CACA,OAAO,SAAS,cACd,YAAY,MACZ,WAAW,aAAa,OAAO,CACjC;AACF"}
|
|
@@ -1,479 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// ../bitfab-typescript-transform/src/unplugin.ts
|
|
21
|
-
var unplugin_exports = {};
|
|
22
|
-
__export(unplugin_exports, {
|
|
23
|
-
bitfabTraceUnplugin: () => bitfabTraceUnplugin
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(unplugin_exports);
|
|
26
|
-
var import_unplugin = require("unplugin");
|
|
27
|
-
|
|
28
|
-
// ../bitfab-typescript-transform/src/transform.ts
|
|
29
|
-
var import_core = require("@babel/core");
|
|
30
|
-
|
|
31
|
-
// ../bitfab-typescript-transform/src/transformOptions.ts
|
|
32
|
-
var AUTO_TRACE_FUNCTION_ID_VERSION = "ts-auto-v1";
|
|
33
|
-
var AUTO_TRACE_TRANSFORM_MARKER = "__bitfab_auto_trace_transformed_v1__";
|
|
34
|
-
function autoTraceFunctionId(file, name) {
|
|
35
|
-
return `${AUTO_TRACE_FUNCTION_ID_VERSION}:${file}#${name}`;
|
|
36
|
-
}
|
|
37
|
-
function sourceFilename(filename) {
|
|
38
|
-
return filename.replace(/\\/g, "/").split(/[?#]/, 1)[0] ?? "";
|
|
39
|
-
}
|
|
40
|
-
function autoTraceFilename(filename, cwd) {
|
|
41
|
-
const normalized = sourceFilename(filename);
|
|
42
|
-
const normalizedCwd = cwd.replace(/\\/g, "/").replace(/\/$/, "");
|
|
43
|
-
return normalized.startsWith(`${normalizedCwd}/`) ? normalized.slice(normalizedCwd.length + 1) : normalized;
|
|
44
|
-
}
|
|
45
|
-
function shouldTransformBitfabFile(filename, options) {
|
|
46
|
-
if (!filename) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
if (options.include && !options.include(filename)) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
const normalized = sourceFilename(filename);
|
|
53
|
-
const normalizedCwd = options.cwd?.replace(/\\/g, "/").replace(/\/$/, "");
|
|
54
|
-
const isAbsolute = normalized.startsWith("/") || /^[A-Za-z]:\//.test(normalized);
|
|
55
|
-
if (normalizedCwd && isAbsolute && normalized !== normalizedCwd && !normalized.startsWith(`${normalizedCwd}/`)) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
return !normalized.includes("/node_modules/") && !normalized.endsWith(".d.ts") && /\.[cm]?[jt]sx?$/.test(normalized);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// ../bitfab-typescript-transform/src/babelPlugin.ts
|
|
62
|
-
function propertyName(node, types) {
|
|
63
|
-
if (types.isIdentifier(node)) {
|
|
64
|
-
return node.name;
|
|
65
|
-
}
|
|
66
|
-
if (types.isStringLiteral(node)) {
|
|
67
|
-
return node.value;
|
|
68
|
-
}
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
function functionName(path, types) {
|
|
72
|
-
const node = path.node;
|
|
73
|
-
if (types.isFunctionDeclaration(node) || types.isFunctionExpression(node)) {
|
|
74
|
-
if (node.id) {
|
|
75
|
-
return node.id.name;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if ((types.isClassMethod(node) || types.isObjectMethod(node)) && !node.computed && types.isIdentifier(node.key)) {
|
|
79
|
-
return node.key.name;
|
|
80
|
-
}
|
|
81
|
-
const parent = path.parentPath?.node;
|
|
82
|
-
if (types.isVariableDeclarator(parent)) {
|
|
83
|
-
return propertyName(parent.id, types) ?? "anonymous";
|
|
84
|
-
}
|
|
85
|
-
if (types.isObjectProperty(parent) && !parent.computed) {
|
|
86
|
-
return propertyName(parent.key, types) ?? "anonymous";
|
|
87
|
-
}
|
|
88
|
-
if (types.isClassProperty(parent) && !parent.computed) {
|
|
89
|
-
const name = propertyName(parent.key, types);
|
|
90
|
-
if (name) {
|
|
91
|
-
return name;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
const { line, column } = sourcePosition(path);
|
|
95
|
-
return `anonymous-${line}-${column}`;
|
|
96
|
-
}
|
|
97
|
-
function isInstrumentableFunction(node, types) {
|
|
98
|
-
if (node.generator || types.isClassPrivateMethod(node)) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
return !(types.isClassMethod(node) || types.isObjectMethod(node)) || node.kind === "method";
|
|
102
|
-
}
|
|
103
|
-
function sourcePosition(path) {
|
|
104
|
-
const exportDeclaration = path.parentPath?.isExportDeclaration() ? path.parentPath.node : void 0;
|
|
105
|
-
const start = (exportDeclaration ?? path.node).loc?.start;
|
|
106
|
-
return { line: start?.line ?? 0, column: start?.column ?? 0 };
|
|
107
|
-
}
|
|
108
|
-
function qualifiedFunctionName(path, types) {
|
|
109
|
-
const ownName = functionName(path, types);
|
|
110
|
-
if (ownName.startsWith("anonymous-")) {
|
|
111
|
-
return ownName;
|
|
112
|
-
}
|
|
113
|
-
const scopes = [];
|
|
114
|
-
let ancestor = path.parentPath;
|
|
115
|
-
while (ancestor) {
|
|
116
|
-
if (ancestor.isFunction()) {
|
|
117
|
-
if (!isInstrumentableFunction(ancestor.node, types)) {
|
|
118
|
-
ancestor = ancestor.parentPath;
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
const name = functionName(
|
|
122
|
-
ancestor,
|
|
123
|
-
types
|
|
124
|
-
);
|
|
125
|
-
if (!name.startsWith("anonymous-")) {
|
|
126
|
-
scopes.unshift(name);
|
|
127
|
-
}
|
|
128
|
-
} else if ((ancestor.isClassDeclaration() || ancestor.isClassExpression()) && ancestor.node.id) {
|
|
129
|
-
scopes.unshift(ancestor.node.id.name);
|
|
130
|
-
} else if (ancestor.isObjectExpression()) {
|
|
131
|
-
const parent = ancestor.parentPath?.node;
|
|
132
|
-
if (types.isVariableDeclarator(parent)) {
|
|
133
|
-
const name = propertyName(parent.id, types);
|
|
134
|
-
if (name) {
|
|
135
|
-
scopes.unshift(name);
|
|
136
|
-
}
|
|
137
|
-
} else if (types.isObjectProperty(parent) && !parent.computed) {
|
|
138
|
-
const name = propertyName(parent.key, types);
|
|
139
|
-
if (name) {
|
|
140
|
-
scopes.unshift(name);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
ancestor = ancestor.parentPath;
|
|
145
|
-
}
|
|
146
|
-
return [...scopes, ownName].join(".");
|
|
147
|
-
}
|
|
148
|
-
function isTraceDecoratorRoot(path, types) {
|
|
149
|
-
const node = path.node;
|
|
150
|
-
const parent = path.parentPath?.node;
|
|
151
|
-
const decorated = types.isClassMethod(node) || types.isClassPrivateMethod(node) ? node : types.isClassProperty(parent) && parent.value === node ? parent : null;
|
|
152
|
-
if (!decorated) {
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
return decorated.decorators?.some((decorator) => {
|
|
156
|
-
const expression = decorator.expression;
|
|
157
|
-
if (!types.isCallExpression(expression)) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
const callee = expression.callee;
|
|
161
|
-
return types.isMemberExpression(callee) && !callee.computed && types.isIdentifier(callee.property, { name: "trace" });
|
|
162
|
-
}) ?? false;
|
|
163
|
-
}
|
|
164
|
-
function withNodeFunctionName(path, types) {
|
|
165
|
-
if (path.node.arguments.length > 2) {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
const callee = path.node.callee;
|
|
169
|
-
if (!types.isMemberExpression(callee) || callee.computed || !types.isIdentifier(callee.property, { name: "withNode" })) {
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
const fn = path.node.arguments[path.node.arguments.length - 1];
|
|
173
|
-
if (types.isIdentifier(fn)) {
|
|
174
|
-
return fn.name;
|
|
175
|
-
}
|
|
176
|
-
if (types.isMemberExpression(fn) && !fn.computed) {
|
|
177
|
-
return propertyName(fn.property, types);
|
|
178
|
-
}
|
|
179
|
-
if (types.isFunctionExpression(fn) && fn.id) {
|
|
180
|
-
return fn.id.name;
|
|
181
|
-
}
|
|
182
|
-
return null;
|
|
183
|
-
}
|
|
184
|
-
function runtimeParameters(node, types) {
|
|
185
|
-
return node.params.filter(
|
|
186
|
-
(parameter) => !types.isIdentifier(parameter, { name: "this" })
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
function parameterInputs(path, types) {
|
|
190
|
-
const elements = [];
|
|
191
|
-
for (const [index, parameter] of runtimeParameters(
|
|
192
|
-
path.node,
|
|
193
|
-
types
|
|
194
|
-
).entries()) {
|
|
195
|
-
if (!types.isArrowFunctionExpression(path.node)) {
|
|
196
|
-
if (types.isRestElement(parameter)) {
|
|
197
|
-
elements.push(
|
|
198
|
-
types.spreadElement(
|
|
199
|
-
types.callExpression(
|
|
200
|
-
types.memberExpression(
|
|
201
|
-
types.arrayExpression([
|
|
202
|
-
types.spreadElement(types.identifier("arguments"))
|
|
203
|
-
]),
|
|
204
|
-
types.identifier("slice")
|
|
205
|
-
),
|
|
206
|
-
[types.numericLiteral(index)]
|
|
207
|
-
)
|
|
208
|
-
)
|
|
209
|
-
);
|
|
210
|
-
} else {
|
|
211
|
-
elements.push(
|
|
212
|
-
types.memberExpression(
|
|
213
|
-
types.identifier("arguments"),
|
|
214
|
-
types.numericLiteral(index),
|
|
215
|
-
true
|
|
216
|
-
)
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
if (types.isIdentifier(parameter)) {
|
|
222
|
-
elements.push(types.identifier(parameter.name));
|
|
223
|
-
} else if (types.isRestElement(parameter) && types.isIdentifier(parameter.argument)) {
|
|
224
|
-
elements.push(
|
|
225
|
-
types.spreadElement(types.identifier(parameter.argument.name))
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return types.arrayExpression(elements);
|
|
230
|
-
}
|
|
231
|
-
function needsArgumentWrapper(path, types) {
|
|
232
|
-
return types.isArrowFunctionExpression(path.node) && path.node.params.some(
|
|
233
|
-
(parameter) => !types.isIdentifier(parameter) && !(types.isRestElement(parameter) && types.isIdentifier(parameter.argument))
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
function isRestWrapper(path, types) {
|
|
237
|
-
const parameters = runtimeParameters(path.node, types);
|
|
238
|
-
return parameters.length === 1 && types.isRestElement(parameters[0]);
|
|
239
|
-
}
|
|
240
|
-
function bitfabBabelPlugin(api) {
|
|
241
|
-
const { types } = api;
|
|
242
|
-
return {
|
|
243
|
-
name: "bitfab-auto-trace",
|
|
244
|
-
visitor: {
|
|
245
|
-
Program: {
|
|
246
|
-
enter(path, state) {
|
|
247
|
-
const filename = state.file.opts.filename ?? "unknown";
|
|
248
|
-
state.skipFile = !shouldTransformBitfabFile(filename, state.opts) || path.scope.hasBinding(AUTO_TRACE_TRANSFORM_MARKER) || path.node.directives.some(
|
|
249
|
-
(directive) => directive.value.value === "use client"
|
|
250
|
-
);
|
|
251
|
-
state.runtimeIdentifier = path.scope.generateUidIdentifier("bitfabAutoSpan");
|
|
252
|
-
state.activeIdentifier = path.scope.generateUidIdentifier(
|
|
253
|
-
"bitfabAutoTraceActive"
|
|
254
|
-
);
|
|
255
|
-
state.wrapperIdentifier = path.scope.generateUidIdentifier("bitfabAutoWrap");
|
|
256
|
-
state.definitions = [];
|
|
257
|
-
state.usedRuntime = false;
|
|
258
|
-
state.usedWrapper = false;
|
|
259
|
-
},
|
|
260
|
-
exit(path, state) {
|
|
261
|
-
if (state.skipFile || !state.usedRuntime || !state.runtimeIdentifier || !state.activeIdentifier || !state.wrapperIdentifier) {
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
state.file.metadata[AUTO_TRACE_TRANSFORM_MARKER] = true;
|
|
265
|
-
path.unshiftContainer("body", [
|
|
266
|
-
types.importDeclaration(
|
|
267
|
-
[
|
|
268
|
-
types.importSpecifier(
|
|
269
|
-
state.runtimeIdentifier,
|
|
270
|
-
types.identifier("__bitfabAutoSpan")
|
|
271
|
-
),
|
|
272
|
-
types.importSpecifier(
|
|
273
|
-
state.activeIdentifier,
|
|
274
|
-
types.identifier("__bitfabAutoTraceActive")
|
|
275
|
-
),
|
|
276
|
-
...state.usedWrapper ? [
|
|
277
|
-
types.importSpecifier(
|
|
278
|
-
state.wrapperIdentifier,
|
|
279
|
-
types.identifier("__bitfabAutoWrap")
|
|
280
|
-
)
|
|
281
|
-
] : []
|
|
282
|
-
],
|
|
283
|
-
types.stringLiteral(
|
|
284
|
-
state.opts.runtimeModule ?? "@bitfab/sdk/auto"
|
|
285
|
-
)
|
|
286
|
-
),
|
|
287
|
-
types.variableDeclaration("const", [
|
|
288
|
-
types.variableDeclarator(
|
|
289
|
-
types.identifier(AUTO_TRACE_TRANSFORM_MARKER),
|
|
290
|
-
types.assignmentExpression(
|
|
291
|
-
"=",
|
|
292
|
-
types.memberExpression(
|
|
293
|
-
types.identifier("globalThis"),
|
|
294
|
-
types.identifier(AUTO_TRACE_TRANSFORM_MARKER)
|
|
295
|
-
),
|
|
296
|
-
types.booleanLiteral(true)
|
|
297
|
-
)
|
|
298
|
-
)
|
|
299
|
-
]),
|
|
300
|
-
...state.definitions ?? []
|
|
301
|
-
]);
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
CallExpression: {
|
|
305
|
-
exit(path, state) {
|
|
306
|
-
if (state.skipFile) {
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
const configuredName = withNodeFunctionName(path, types);
|
|
310
|
-
if (configuredName === null) {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
if (path.node.arguments.length === 1) {
|
|
314
|
-
path.node.arguments.push(types.identifier("undefined"));
|
|
315
|
-
}
|
|
316
|
-
path.node.arguments.push(types.stringLiteral(configuredName));
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
Function: {
|
|
320
|
-
exit(path, state) {
|
|
321
|
-
const node = path.node;
|
|
322
|
-
if (state.skipFile || node._bitfabInstrumented || !isInstrumentableFunction(node, types) || isTraceDecoratorRoot(path, types) || !state.runtimeIdentifier || !state.activeIdentifier || !state.wrapperIdentifier) {
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
const name = qualifiedFunctionName(path, types);
|
|
326
|
-
if (name.startsWith("anonymous-")) {
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
const normalizedFilename = autoTraceFilename(
|
|
330
|
-
state.file.opts.filename ?? "unknown",
|
|
331
|
-
state.opts.cwd ?? state.file.opts.cwd ?? process.cwd()
|
|
332
|
-
);
|
|
333
|
-
const { line, column } = sourcePosition(path);
|
|
334
|
-
const definition = types.objectExpression([
|
|
335
|
-
types.objectProperty(
|
|
336
|
-
types.identifier("id"),
|
|
337
|
-
types.stringLiteral(
|
|
338
|
-
autoTraceFunctionId(normalizedFilename, name)
|
|
339
|
-
)
|
|
340
|
-
),
|
|
341
|
-
types.objectProperty(
|
|
342
|
-
types.identifier("name"),
|
|
343
|
-
types.stringLiteral(name)
|
|
344
|
-
),
|
|
345
|
-
types.objectProperty(
|
|
346
|
-
types.identifier("file"),
|
|
347
|
-
types.stringLiteral(normalizedFilename)
|
|
348
|
-
),
|
|
349
|
-
types.objectProperty(
|
|
350
|
-
types.identifier("line"),
|
|
351
|
-
types.numericLiteral(line)
|
|
352
|
-
),
|
|
353
|
-
types.objectProperty(
|
|
354
|
-
types.identifier("column"),
|
|
355
|
-
types.numericLiteral(column)
|
|
356
|
-
),
|
|
357
|
-
...node.async ? [
|
|
358
|
-
types.objectProperty(
|
|
359
|
-
types.identifier("async"),
|
|
360
|
-
types.booleanLiteral(true)
|
|
361
|
-
)
|
|
362
|
-
] : [],
|
|
363
|
-
...isRestWrapper(path, types) ? [
|
|
364
|
-
types.objectProperty(
|
|
365
|
-
types.identifier("wrapper"),
|
|
366
|
-
types.booleanLiteral(true)
|
|
367
|
-
)
|
|
368
|
-
] : []
|
|
369
|
-
]);
|
|
370
|
-
const definitionIdentifier = path.scope.getProgramParent().generateUidIdentifier("bitfabAutoDefinition");
|
|
371
|
-
state.definitions?.push(
|
|
372
|
-
types.variableDeclaration("const", [
|
|
373
|
-
types.variableDeclarator(definitionIdentifier, definition)
|
|
374
|
-
])
|
|
375
|
-
);
|
|
376
|
-
if (needsArgumentWrapper(path, types)) {
|
|
377
|
-
node._bitfabInstrumented = true;
|
|
378
|
-
path.replaceWith(
|
|
379
|
-
types.callExpression(types.cloneNode(state.wrapperIdentifier), [
|
|
380
|
-
types.cloneNode(definitionIdentifier),
|
|
381
|
-
node
|
|
382
|
-
])
|
|
383
|
-
);
|
|
384
|
-
state.usedRuntime = true;
|
|
385
|
-
state.usedWrapper = true;
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
const originalBody = types.isBlockStatement(node.body) ? node.body : types.blockStatement([types.returnStatement(node.body)]);
|
|
389
|
-
const directives = originalBody.directives;
|
|
390
|
-
originalBody.directives = [];
|
|
391
|
-
const body = types.blockStatement(
|
|
392
|
-
[
|
|
393
|
-
types.ifStatement(
|
|
394
|
-
types.callExpression(
|
|
395
|
-
types.cloneNode(state.activeIdentifier),
|
|
396
|
-
[]
|
|
397
|
-
),
|
|
398
|
-
types.blockStatement([
|
|
399
|
-
types.returnStatement(
|
|
400
|
-
types.callExpression(
|
|
401
|
-
types.cloneNode(state.runtimeIdentifier),
|
|
402
|
-
[
|
|
403
|
-
types.cloneNode(definitionIdentifier),
|
|
404
|
-
parameterInputs(path, types),
|
|
405
|
-
types.arrowFunctionExpression(
|
|
406
|
-
[],
|
|
407
|
-
types.cloneNode(originalBody, true),
|
|
408
|
-
node.async ?? false
|
|
409
|
-
)
|
|
410
|
-
]
|
|
411
|
-
)
|
|
412
|
-
)
|
|
413
|
-
])
|
|
414
|
-
),
|
|
415
|
-
...originalBody.body
|
|
416
|
-
],
|
|
417
|
-
directives
|
|
418
|
-
);
|
|
419
|
-
node.body = body;
|
|
420
|
-
node._bitfabInstrumented = true;
|
|
421
|
-
state.usedRuntime = true;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// ../bitfab-typescript-transform/src/transform.ts
|
|
429
|
-
function parserPlugins(filename) {
|
|
430
|
-
const path = sourceFilename(filename);
|
|
431
|
-
const typescript = /\.[cm]?tsx?$/.test(path);
|
|
432
|
-
const jsx = /\.tsx$/.test(path) || /\.[cm]?jsx?$/.test(path);
|
|
433
|
-
return [
|
|
434
|
-
...typescript ? ["typescript"] : [],
|
|
435
|
-
...jsx ? ["jsx"] : [],
|
|
436
|
-
"decorators"
|
|
437
|
-
];
|
|
438
|
-
}
|
|
439
|
-
function transformBitfabSource(source, filename, options = {}) {
|
|
440
|
-
if (!shouldTransformBitfabFile(filename, options)) {
|
|
441
|
-
return { code: source };
|
|
442
|
-
}
|
|
443
|
-
const result = (0, import_core.transformSync)(source, {
|
|
444
|
-
babelrc: false,
|
|
445
|
-
configFile: false,
|
|
446
|
-
filename: sourceFilename(filename),
|
|
447
|
-
parserOpts: { plugins: parserPlugins(filename), sourceType: "module" },
|
|
448
|
-
plugins: [[bitfabBabelPlugin, options]],
|
|
449
|
-
sourceMaps: true
|
|
450
|
-
});
|
|
451
|
-
if (!result?.code || !result.metadata?.[AUTO_TRACE_TRANSFORM_MARKER]) {
|
|
452
|
-
return { code: source };
|
|
453
|
-
}
|
|
454
|
-
return {
|
|
455
|
-
code: result.code,
|
|
456
|
-
...result.map ? { map: result.map } : {}
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// ../bitfab-typescript-transform/src/unplugin.ts
|
|
461
|
-
var bitfabTraceUnplugin = (0, import_unplugin.createUnplugin)((options) => {
|
|
462
|
-
const resolvedOptions = options ?? {};
|
|
463
|
-
return {
|
|
464
|
-
name: "bitfab-auto-trace",
|
|
465
|
-
enforce: "pre",
|
|
466
|
-
transform(source, filename) {
|
|
467
|
-
if (!shouldTransformBitfabFile(filename, resolvedOptions)) {
|
|
468
|
-
return null;
|
|
469
|
-
}
|
|
470
|
-
const result = transformBitfabSource(source, filename, resolvedOptions);
|
|
471
|
-
return result.map ? result : null;
|
|
472
|
-
}
|
|
473
|
-
};
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
474
4
|
});
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
5
|
+
const require_babelPlugin = require("../babelPlugin-Nta4-VcL.cjs");
|
|
6
|
+
const require_transform = require("../transform-BjxHGGKc.cjs");
|
|
7
|
+
//#region ../bitfab-typescript-transform/src/unplugin.ts
|
|
8
|
+
const bitfabTraceUnplugin = (0, require("unplugin").createUnplugin)((options) => {
|
|
9
|
+
const resolvedOptions = options ?? {};
|
|
10
|
+
return {
|
|
11
|
+
name: "bitfab-auto-trace",
|
|
12
|
+
enforce: "pre",
|
|
13
|
+
transform(source, filename) {
|
|
14
|
+
if (!require_babelPlugin.shouldTransformBitfabFile(filename, resolvedOptions)) return null;
|
|
15
|
+
const result = require_transform.transformBitfabSource(source, filename, resolvedOptions);
|
|
16
|
+
return result.map ? result : null;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
478
19
|
});
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.bitfabTraceUnplugin = bitfabTraceUnplugin;
|
|
22
|
+
|
|
479
23
|
//# sourceMappingURL=unplugin.cjs.map
|