@bitfab/sdk 0.65.4 → 0.65.6
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-CQw0qMBt.cjs +396 -0
- package/dist/autoTrace-CQw0qMBt.cjs.map +1 -0
- package/dist/autoTrace-O40k8f5M.js +271 -0
- package/dist/autoTrace-O40k8f5M.js.map +1 -0
- package/dist/autoTrace.cjs +15 -353
- package/dist/autoTrace.d.cts +48 -44
- package/dist/autoTrace.d.ts +48 -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-lnqCEnB1.js +2154 -0
- package/dist/http-lnqCEnB1.js.map +1 -0
- package/dist/index-CFOLQ1IF.d.cts +4410 -0
- package/dist/index-CFOLQ1IF.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-BungStQw.js +6015 -0
- package/dist/src-BungStQw.js.map +1 -0
- package/dist/src-FFSCRXpz.cjs +8438 -0
- package/dist/src-FFSCRXpz.cjs.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/next.cjs
CHANGED
|
@@ -1,537 +1,65 @@
|
|
|
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/nextSdk.ts
|
|
21
|
-
var nextSdk_exports = {};
|
|
22
|
-
__export(nextSdk_exports, {
|
|
23
|
-
default: () => nextSdk_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(nextSdk_exports);
|
|
26
|
-
|
|
27
|
-
// ../bitfab-typescript-transform/src/unplugin.ts
|
|
28
|
-
var import_unplugin = require("unplugin");
|
|
29
|
-
|
|
30
|
-
// ../bitfab-typescript-transform/src/transform.ts
|
|
31
|
-
var import_core = require("@babel/core");
|
|
32
|
-
|
|
33
|
-
// ../bitfab-typescript-transform/src/transformOptions.ts
|
|
34
|
-
var AUTO_TRACE_FUNCTION_ID_VERSION = "ts-auto-v1";
|
|
35
|
-
var AUTO_TRACE_TRANSFORM_MARKER = "__bitfab_auto_trace_transformed_v1__";
|
|
36
|
-
function autoTraceFunctionId(file, name) {
|
|
37
|
-
return `${AUTO_TRACE_FUNCTION_ID_VERSION}:${file}#${name}`;
|
|
38
|
-
}
|
|
39
|
-
function sourceFilename(filename) {
|
|
40
|
-
return filename.replace(/\\/g, "/").split(/[?#]/, 1)[0] ?? "";
|
|
41
|
-
}
|
|
42
|
-
function autoTraceFilename(filename, cwd) {
|
|
43
|
-
const normalized = sourceFilename(filename);
|
|
44
|
-
const normalizedCwd = cwd.replace(/\\/g, "/").replace(/\/$/, "");
|
|
45
|
-
return normalized.startsWith(`${normalizedCwd}/`) ? normalized.slice(normalizedCwd.length + 1) : normalized;
|
|
46
|
-
}
|
|
47
|
-
function shouldTransformBitfabFile(filename, options) {
|
|
48
|
-
if (!filename) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
if (options.include && !options.include(filename)) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
const normalized = sourceFilename(filename);
|
|
55
|
-
const normalizedCwd = options.cwd?.replace(/\\/g, "/").replace(/\/$/, "");
|
|
56
|
-
const isAbsolute = normalized.startsWith("/") || /^[A-Za-z]:\//.test(normalized);
|
|
57
|
-
if (normalizedCwd && isAbsolute && normalized !== normalizedCwd && !normalized.startsWith(`${normalizedCwd}/`)) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
return !normalized.includes("/node_modules/") && !normalized.endsWith(".d.ts") && /\.[cm]?[jt]sx?$/.test(normalized);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// ../bitfab-typescript-transform/src/babelPlugin.ts
|
|
64
|
-
function propertyName(node, types) {
|
|
65
|
-
if (types.isIdentifier(node)) {
|
|
66
|
-
return node.name;
|
|
67
|
-
}
|
|
68
|
-
if (types.isStringLiteral(node)) {
|
|
69
|
-
return node.value;
|
|
70
|
-
}
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
function functionName(path, types) {
|
|
74
|
-
const node = path.node;
|
|
75
|
-
if (types.isFunctionDeclaration(node) || types.isFunctionExpression(node)) {
|
|
76
|
-
if (node.id) {
|
|
77
|
-
return node.id.name;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if ((types.isClassMethod(node) || types.isObjectMethod(node)) && !node.computed && types.isIdentifier(node.key)) {
|
|
81
|
-
return node.key.name;
|
|
82
|
-
}
|
|
83
|
-
const parent = path.parentPath?.node;
|
|
84
|
-
if (types.isVariableDeclarator(parent)) {
|
|
85
|
-
return propertyName(parent.id, types) ?? "anonymous";
|
|
86
|
-
}
|
|
87
|
-
if (types.isObjectProperty(parent) && !parent.computed) {
|
|
88
|
-
return propertyName(parent.key, types) ?? "anonymous";
|
|
89
|
-
}
|
|
90
|
-
if (types.isClassProperty(parent) && !parent.computed) {
|
|
91
|
-
const name = propertyName(parent.key, types);
|
|
92
|
-
if (name) {
|
|
93
|
-
return name;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const { line, column } = sourcePosition(path);
|
|
97
|
-
return `anonymous-${line}-${column}`;
|
|
98
|
-
}
|
|
99
|
-
function isInstrumentableFunction(node, types) {
|
|
100
|
-
if (node.generator || types.isClassPrivateMethod(node)) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
return !(types.isClassMethod(node) || types.isObjectMethod(node)) || node.kind === "method";
|
|
104
|
-
}
|
|
105
|
-
function sourcePosition(path) {
|
|
106
|
-
const exportDeclaration = path.parentPath?.isExportDeclaration() ? path.parentPath.node : void 0;
|
|
107
|
-
const start = (exportDeclaration ?? path.node).loc?.start;
|
|
108
|
-
return { line: start?.line ?? 0, column: start?.column ?? 0 };
|
|
109
|
-
}
|
|
110
|
-
function qualifiedFunctionName(path, types) {
|
|
111
|
-
const ownName = functionName(path, types);
|
|
112
|
-
if (ownName.startsWith("anonymous-")) {
|
|
113
|
-
return ownName;
|
|
114
|
-
}
|
|
115
|
-
const scopes = [];
|
|
116
|
-
let ancestor = path.parentPath;
|
|
117
|
-
while (ancestor) {
|
|
118
|
-
if (ancestor.isFunction()) {
|
|
119
|
-
if (!isInstrumentableFunction(ancestor.node, types)) {
|
|
120
|
-
ancestor = ancestor.parentPath;
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
const name = functionName(
|
|
124
|
-
ancestor,
|
|
125
|
-
types
|
|
126
|
-
);
|
|
127
|
-
if (!name.startsWith("anonymous-")) {
|
|
128
|
-
scopes.unshift(name);
|
|
129
|
-
}
|
|
130
|
-
} else if ((ancestor.isClassDeclaration() || ancestor.isClassExpression()) && ancestor.node.id) {
|
|
131
|
-
scopes.unshift(ancestor.node.id.name);
|
|
132
|
-
} else if (ancestor.isObjectExpression()) {
|
|
133
|
-
const parent = ancestor.parentPath?.node;
|
|
134
|
-
if (types.isVariableDeclarator(parent)) {
|
|
135
|
-
const name = propertyName(parent.id, types);
|
|
136
|
-
if (name) {
|
|
137
|
-
scopes.unshift(name);
|
|
138
|
-
}
|
|
139
|
-
} else if (types.isObjectProperty(parent) && !parent.computed) {
|
|
140
|
-
const name = propertyName(parent.key, types);
|
|
141
|
-
if (name) {
|
|
142
|
-
scopes.unshift(name);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
ancestor = ancestor.parentPath;
|
|
147
|
-
}
|
|
148
|
-
return [...scopes, ownName].join(".");
|
|
149
|
-
}
|
|
150
|
-
function isTraceDecoratorRoot(path, types) {
|
|
151
|
-
const node = path.node;
|
|
152
|
-
const parent = path.parentPath?.node;
|
|
153
|
-
const decorated = types.isClassMethod(node) || types.isClassPrivateMethod(node) ? node : types.isClassProperty(parent) && parent.value === node ? parent : null;
|
|
154
|
-
if (!decorated) {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
return decorated.decorators?.some((decorator) => {
|
|
158
|
-
const expression = decorator.expression;
|
|
159
|
-
if (!types.isCallExpression(expression)) {
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
const callee = expression.callee;
|
|
163
|
-
return types.isMemberExpression(callee) && !callee.computed && types.isIdentifier(callee.property, { name: "trace" });
|
|
164
|
-
}) ?? false;
|
|
165
|
-
}
|
|
166
|
-
function withNodeFunctionName(path, types) {
|
|
167
|
-
if (path.node.arguments.length > 2) {
|
|
168
|
-
return null;
|
|
169
|
-
}
|
|
170
|
-
const callee = path.node.callee;
|
|
171
|
-
if (!types.isMemberExpression(callee) || callee.computed || !types.isIdentifier(callee.property, { name: "withNode" })) {
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
const fn = path.node.arguments[path.node.arguments.length - 1];
|
|
175
|
-
if (types.isIdentifier(fn)) {
|
|
176
|
-
return fn.name;
|
|
177
|
-
}
|
|
178
|
-
if (types.isMemberExpression(fn) && !fn.computed) {
|
|
179
|
-
return propertyName(fn.property, types);
|
|
180
|
-
}
|
|
181
|
-
if (types.isFunctionExpression(fn) && fn.id) {
|
|
182
|
-
return fn.id.name;
|
|
183
|
-
}
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
function runtimeParameters(node, types) {
|
|
187
|
-
return node.params.filter(
|
|
188
|
-
(parameter) => !types.isIdentifier(parameter, { name: "this" })
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
function parameterInputs(path, types) {
|
|
192
|
-
const elements = [];
|
|
193
|
-
for (const [index, parameter] of runtimeParameters(
|
|
194
|
-
path.node,
|
|
195
|
-
types
|
|
196
|
-
).entries()) {
|
|
197
|
-
if (!types.isArrowFunctionExpression(path.node)) {
|
|
198
|
-
if (types.isRestElement(parameter)) {
|
|
199
|
-
elements.push(
|
|
200
|
-
types.spreadElement(
|
|
201
|
-
types.callExpression(
|
|
202
|
-
types.memberExpression(
|
|
203
|
-
types.arrayExpression([
|
|
204
|
-
types.spreadElement(types.identifier("arguments"))
|
|
205
|
-
]),
|
|
206
|
-
types.identifier("slice")
|
|
207
|
-
),
|
|
208
|
-
[types.numericLiteral(index)]
|
|
209
|
-
)
|
|
210
|
-
)
|
|
211
|
-
);
|
|
212
|
-
} else {
|
|
213
|
-
elements.push(
|
|
214
|
-
types.memberExpression(
|
|
215
|
-
types.identifier("arguments"),
|
|
216
|
-
types.numericLiteral(index),
|
|
217
|
-
true
|
|
218
|
-
)
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
if (types.isIdentifier(parameter)) {
|
|
224
|
-
elements.push(types.identifier(parameter.name));
|
|
225
|
-
} else if (types.isRestElement(parameter) && types.isIdentifier(parameter.argument)) {
|
|
226
|
-
elements.push(
|
|
227
|
-
types.spreadElement(types.identifier(parameter.argument.name))
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return types.arrayExpression(elements);
|
|
232
|
-
}
|
|
233
|
-
function needsArgumentWrapper(path, types) {
|
|
234
|
-
return types.isArrowFunctionExpression(path.node) && path.node.params.some(
|
|
235
|
-
(parameter) => !types.isIdentifier(parameter) && !(types.isRestElement(parameter) && types.isIdentifier(parameter.argument))
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
function isRestWrapper(path, types) {
|
|
239
|
-
const parameters = runtimeParameters(path.node, types);
|
|
240
|
-
return parameters.length === 1 && types.isRestElement(parameters[0]);
|
|
241
|
-
}
|
|
242
|
-
function bitfabBabelPlugin(api) {
|
|
243
|
-
const { types } = api;
|
|
244
|
-
return {
|
|
245
|
-
name: "bitfab-auto-trace",
|
|
246
|
-
visitor: {
|
|
247
|
-
Program: {
|
|
248
|
-
enter(path, state) {
|
|
249
|
-
const filename = state.file.opts.filename ?? "unknown";
|
|
250
|
-
state.skipFile = !shouldTransformBitfabFile(filename, state.opts) || path.scope.hasBinding(AUTO_TRACE_TRANSFORM_MARKER) || path.node.directives.some(
|
|
251
|
-
(directive) => directive.value.value === "use client"
|
|
252
|
-
);
|
|
253
|
-
state.runtimeIdentifier = path.scope.generateUidIdentifier("bitfabAutoSpan");
|
|
254
|
-
state.activeIdentifier = path.scope.generateUidIdentifier(
|
|
255
|
-
"bitfabAutoTraceActive"
|
|
256
|
-
);
|
|
257
|
-
state.wrapperIdentifier = path.scope.generateUidIdentifier("bitfabAutoWrap");
|
|
258
|
-
state.definitions = [];
|
|
259
|
-
state.usedRuntime = false;
|
|
260
|
-
state.usedWrapper = false;
|
|
261
|
-
},
|
|
262
|
-
exit(path, state) {
|
|
263
|
-
if (state.skipFile || !state.usedRuntime || !state.runtimeIdentifier || !state.activeIdentifier || !state.wrapperIdentifier) {
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
state.file.metadata[AUTO_TRACE_TRANSFORM_MARKER] = true;
|
|
267
|
-
path.unshiftContainer("body", [
|
|
268
|
-
types.importDeclaration(
|
|
269
|
-
[
|
|
270
|
-
types.importSpecifier(
|
|
271
|
-
state.runtimeIdentifier,
|
|
272
|
-
types.identifier("__bitfabAutoSpan")
|
|
273
|
-
),
|
|
274
|
-
types.importSpecifier(
|
|
275
|
-
state.activeIdentifier,
|
|
276
|
-
types.identifier("__bitfabAutoTraceActive")
|
|
277
|
-
),
|
|
278
|
-
...state.usedWrapper ? [
|
|
279
|
-
types.importSpecifier(
|
|
280
|
-
state.wrapperIdentifier,
|
|
281
|
-
types.identifier("__bitfabAutoWrap")
|
|
282
|
-
)
|
|
283
|
-
] : []
|
|
284
|
-
],
|
|
285
|
-
types.stringLiteral(
|
|
286
|
-
state.opts.runtimeModule ?? "@bitfab/sdk/auto"
|
|
287
|
-
)
|
|
288
|
-
),
|
|
289
|
-
types.variableDeclaration("const", [
|
|
290
|
-
types.variableDeclarator(
|
|
291
|
-
types.identifier(AUTO_TRACE_TRANSFORM_MARKER),
|
|
292
|
-
types.assignmentExpression(
|
|
293
|
-
"=",
|
|
294
|
-
types.memberExpression(
|
|
295
|
-
types.identifier("globalThis"),
|
|
296
|
-
types.identifier(AUTO_TRACE_TRANSFORM_MARKER)
|
|
297
|
-
),
|
|
298
|
-
types.booleanLiteral(true)
|
|
299
|
-
)
|
|
300
|
-
)
|
|
301
|
-
]),
|
|
302
|
-
...state.definitions ?? []
|
|
303
|
-
]);
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
CallExpression: {
|
|
307
|
-
exit(path, state) {
|
|
308
|
-
if (state.skipFile) {
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
const configuredName = withNodeFunctionName(path, types);
|
|
312
|
-
if (configuredName === null) {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
if (path.node.arguments.length === 1) {
|
|
316
|
-
path.node.arguments.push(types.identifier("undefined"));
|
|
317
|
-
}
|
|
318
|
-
path.node.arguments.push(types.stringLiteral(configuredName));
|
|
319
|
-
}
|
|
320
|
-
},
|
|
321
|
-
Function: {
|
|
322
|
-
exit(path, state) {
|
|
323
|
-
const node = path.node;
|
|
324
|
-
if (state.skipFile || node._bitfabInstrumented || !isInstrumentableFunction(node, types) || isTraceDecoratorRoot(path, types) || !state.runtimeIdentifier || !state.activeIdentifier || !state.wrapperIdentifier) {
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
const name = qualifiedFunctionName(path, types);
|
|
328
|
-
if (name.startsWith("anonymous-")) {
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
const normalizedFilename = autoTraceFilename(
|
|
332
|
-
state.file.opts.filename ?? "unknown",
|
|
333
|
-
state.opts.cwd ?? state.file.opts.cwd ?? process.cwd()
|
|
334
|
-
);
|
|
335
|
-
const { line, column } = sourcePosition(path);
|
|
336
|
-
const definition = types.objectExpression([
|
|
337
|
-
types.objectProperty(
|
|
338
|
-
types.identifier("id"),
|
|
339
|
-
types.stringLiteral(
|
|
340
|
-
autoTraceFunctionId(normalizedFilename, name)
|
|
341
|
-
)
|
|
342
|
-
),
|
|
343
|
-
types.objectProperty(
|
|
344
|
-
types.identifier("name"),
|
|
345
|
-
types.stringLiteral(name)
|
|
346
|
-
),
|
|
347
|
-
types.objectProperty(
|
|
348
|
-
types.identifier("file"),
|
|
349
|
-
types.stringLiteral(normalizedFilename)
|
|
350
|
-
),
|
|
351
|
-
types.objectProperty(
|
|
352
|
-
types.identifier("line"),
|
|
353
|
-
types.numericLiteral(line)
|
|
354
|
-
),
|
|
355
|
-
types.objectProperty(
|
|
356
|
-
types.identifier("column"),
|
|
357
|
-
types.numericLiteral(column)
|
|
358
|
-
),
|
|
359
|
-
...node.async ? [
|
|
360
|
-
types.objectProperty(
|
|
361
|
-
types.identifier("async"),
|
|
362
|
-
types.booleanLiteral(true)
|
|
363
|
-
)
|
|
364
|
-
] : [],
|
|
365
|
-
...isRestWrapper(path, types) ? [
|
|
366
|
-
types.objectProperty(
|
|
367
|
-
types.identifier("wrapper"),
|
|
368
|
-
types.booleanLiteral(true)
|
|
369
|
-
)
|
|
370
|
-
] : []
|
|
371
|
-
]);
|
|
372
|
-
const definitionIdentifier = path.scope.getProgramParent().generateUidIdentifier("bitfabAutoDefinition");
|
|
373
|
-
state.definitions?.push(
|
|
374
|
-
types.variableDeclaration("const", [
|
|
375
|
-
types.variableDeclarator(definitionIdentifier, definition)
|
|
376
|
-
])
|
|
377
|
-
);
|
|
378
|
-
if (needsArgumentWrapper(path, types)) {
|
|
379
|
-
node._bitfabInstrumented = true;
|
|
380
|
-
path.replaceWith(
|
|
381
|
-
types.callExpression(types.cloneNode(state.wrapperIdentifier), [
|
|
382
|
-
types.cloneNode(definitionIdentifier),
|
|
383
|
-
node
|
|
384
|
-
])
|
|
385
|
-
);
|
|
386
|
-
state.usedRuntime = true;
|
|
387
|
-
state.usedWrapper = true;
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
const originalBody = types.isBlockStatement(node.body) ? node.body : types.blockStatement([types.returnStatement(node.body)]);
|
|
391
|
-
const directives = originalBody.directives;
|
|
392
|
-
originalBody.directives = [];
|
|
393
|
-
const body = types.blockStatement(
|
|
394
|
-
[
|
|
395
|
-
types.ifStatement(
|
|
396
|
-
types.callExpression(
|
|
397
|
-
types.cloneNode(state.activeIdentifier),
|
|
398
|
-
[]
|
|
399
|
-
),
|
|
400
|
-
types.blockStatement([
|
|
401
|
-
types.returnStatement(
|
|
402
|
-
types.callExpression(
|
|
403
|
-
types.cloneNode(state.runtimeIdentifier),
|
|
404
|
-
[
|
|
405
|
-
types.cloneNode(definitionIdentifier),
|
|
406
|
-
parameterInputs(path, types),
|
|
407
|
-
types.arrowFunctionExpression(
|
|
408
|
-
[],
|
|
409
|
-
types.cloneNode(originalBody, true),
|
|
410
|
-
node.async ?? false
|
|
411
|
-
)
|
|
412
|
-
]
|
|
413
|
-
)
|
|
414
|
-
)
|
|
415
|
-
])
|
|
416
|
-
),
|
|
417
|
-
...originalBody.body
|
|
418
|
-
],
|
|
419
|
-
directives
|
|
420
|
-
);
|
|
421
|
-
node.body = body;
|
|
422
|
-
node._bitfabInstrumented = true;
|
|
423
|
-
state.usedRuntime = true;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// ../bitfab-typescript-transform/src/transform.ts
|
|
431
|
-
function parserPlugins(filename) {
|
|
432
|
-
const path = sourceFilename(filename);
|
|
433
|
-
const typescript = /\.[cm]?tsx?$/.test(path);
|
|
434
|
-
const jsx = /\.tsx$/.test(path) || /\.[cm]?jsx?$/.test(path);
|
|
435
|
-
return [
|
|
436
|
-
...typescript ? ["typescript"] : [],
|
|
437
|
-
...jsx ? ["jsx"] : [],
|
|
438
|
-
"decorators"
|
|
439
|
-
];
|
|
440
|
-
}
|
|
441
|
-
function transformBitfabSource(source, filename, options = {}) {
|
|
442
|
-
if (!shouldTransformBitfabFile(filename, options)) {
|
|
443
|
-
return { code: source };
|
|
444
|
-
}
|
|
445
|
-
const result = (0, import_core.transformSync)(source, {
|
|
446
|
-
babelrc: false,
|
|
447
|
-
configFile: false,
|
|
448
|
-
filename: sourceFilename(filename),
|
|
449
|
-
parserOpts: { plugins: parserPlugins(filename), sourceType: "module" },
|
|
450
|
-
plugins: [[bitfabBabelPlugin, options]],
|
|
451
|
-
sourceMaps: true
|
|
452
|
-
});
|
|
453
|
-
if (!result?.code || !result.metadata?.[AUTO_TRACE_TRANSFORM_MARKER]) {
|
|
454
|
-
return { code: source };
|
|
455
|
-
}
|
|
456
|
-
return {
|
|
457
|
-
code: result.code,
|
|
458
|
-
...result.map ? { map: result.map } : {}
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// ../bitfab-typescript-transform/src/unplugin.ts
|
|
463
|
-
var bitfabTraceUnplugin = (0, import_unplugin.createUnplugin)((options) => {
|
|
464
|
-
const resolvedOptions = options ?? {};
|
|
465
|
-
return {
|
|
466
|
-
name: "bitfab-auto-trace",
|
|
467
|
-
enforce: "pre",
|
|
468
|
-
transform(source, filename) {
|
|
469
|
-
if (!shouldTransformBitfabFile(filename, resolvedOptions)) {
|
|
470
|
-
return null;
|
|
471
|
-
}
|
|
472
|
-
const result = transformBitfabSource(source, filename, resolvedOptions);
|
|
473
|
-
return result.map ? result : null;
|
|
474
|
-
}
|
|
475
|
-
};
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
476
4
|
});
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
5
|
+
const require_transform_unplugin = require("./unplugin.cjs");
|
|
6
|
+
//#region ../bitfab-typescript-transform/src/next.ts
|
|
7
|
+
const SERVER_MODULE_GLOBS = [
|
|
8
|
+
"*.js",
|
|
9
|
+
"*.jsx",
|
|
10
|
+
"*.ts",
|
|
11
|
+
"*.tsx",
|
|
12
|
+
"*.mjs",
|
|
13
|
+
"*.mts",
|
|
14
|
+
"*.cjs",
|
|
15
|
+
"*.cts"
|
|
488
16
|
];
|
|
489
17
|
function appendRule(existing, rule) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
return existing === void 0 ? rule : [existing, rule];
|
|
18
|
+
if (Array.isArray(existing)) return [...existing, rule];
|
|
19
|
+
return existing === void 0 ? rule : [existing, rule];
|
|
494
20
|
}
|
|
495
21
|
function turbopackRules(existing, options, loader) {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
22
|
+
const rules = { ...existing };
|
|
23
|
+
const serverRule = () => ({
|
|
24
|
+
condition: { all: ["node", { not: "foreign" }] },
|
|
25
|
+
loaders: [{
|
|
26
|
+
loader,
|
|
27
|
+
options
|
|
28
|
+
}]
|
|
29
|
+
});
|
|
30
|
+
for (const glob of SERVER_MODULE_GLOBS) rules[glob] = appendRule(rules[glob], serverRule());
|
|
31
|
+
return rules;
|
|
505
32
|
}
|
|
506
33
|
function createWithBitfabTrace(defaultLoader) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
// ../bitfab-typescript-transform/src/nextSdk.ts
|
|
34
|
+
return function withBitfabTrace(nextConfig, options = {}) {
|
|
35
|
+
const { loader = defaultLoader, cwd = process.cwd(), ...rest } = options;
|
|
36
|
+
const transformOptions = {
|
|
37
|
+
cwd,
|
|
38
|
+
...rest
|
|
39
|
+
};
|
|
40
|
+
const config = nextConfig;
|
|
41
|
+
const existingWebpack = config.webpack;
|
|
42
|
+
return {
|
|
43
|
+
...nextConfig,
|
|
44
|
+
turbopack: {
|
|
45
|
+
...config.turbopack,
|
|
46
|
+
rules: turbopackRules(config.turbopack?.rules ?? {}, transformOptions, loader)
|
|
47
|
+
},
|
|
48
|
+
webpack(config, context) {
|
|
49
|
+
const resolved = existingWebpack ? existingWebpack(config, context) : config;
|
|
50
|
+
if (context.isServer && context.nextRuntime !== "edge") {
|
|
51
|
+
resolved.plugins ?? (resolved.plugins = []);
|
|
52
|
+
resolved.plugins.push(require_transform_unplugin.bitfabTraceUnplugin.webpack(transformOptions));
|
|
53
|
+
}
|
|
54
|
+
return resolved;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region ../bitfab-typescript-transform/src/nextSdk.ts
|
|
536
61
|
var nextSdk_default = createWithBitfabTrace("@bitfab/sdk/transform/loader");
|
|
62
|
+
//#endregion
|
|
63
|
+
exports.default = nextSdk_default;
|
|
64
|
+
|
|
537
65
|
//# sourceMappingURL=next.cjs.map
|