@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.
Files changed (170) hide show
  1. package/dist/autoTrace-CZu0BXhG.js +270 -0
  2. package/dist/autoTrace-CZu0BXhG.js.map +1 -0
  3. package/dist/autoTrace-KM9pYqk9.cjs +395 -0
  4. package/dist/autoTrace-KM9pYqk9.cjs.map +1 -0
  5. package/dist/autoTrace.cjs +15 -353
  6. package/dist/autoTrace.d.cts +44 -44
  7. package/dist/autoTrace.d.ts +44 -44
  8. package/dist/autoTrace.js +1 -28
  9. package/dist/babelPlugin-C70OxrqA.js +209 -0
  10. package/dist/babelPlugin-C70OxrqA.js.map +1 -0
  11. package/dist/babelPlugin-Nta4-VcL.cjs +232 -0
  12. package/dist/babelPlugin-Nta4-VcL.cjs.map +1 -0
  13. package/dist/http-CG1Irqxx.js +2154 -0
  14. package/dist/http-CG1Irqxx.js.map +1 -0
  15. package/dist/index-BFkAwvuc.d.cts +4410 -0
  16. package/dist/index-BFkAwvuc.d.ts +4410 -0
  17. package/dist/index.cjs +48 -12504
  18. package/dist/index.d.cts +2 -4443
  19. package/dist/index.d.ts +2 -4443
  20. package/dist/index.js +3 -96
  21. package/dist/loaderRuntime-0huddOOP.d.ts +12 -0
  22. package/dist/loaderRuntime-CslfDFO7.d.cts +12 -0
  23. package/dist/node.cjs +56 -12520
  24. package/dist/node.cjs.map +1 -1
  25. package/dist/node.d.cts +2 -1
  26. package/dist/node.d.ts +2 -1
  27. package/dist/node.js +10 -105
  28. package/dist/node.js.map +1 -1
  29. package/dist/registryCommand-Di8x0YoJ.js +1111 -0
  30. package/dist/registryCommand-Di8x0YoJ.js.map +1 -0
  31. package/dist/replayCli.js +49 -87
  32. package/dist/replayCli.js.map +1 -1
  33. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  34. package/dist/seedCli.js +10 -24
  35. package/dist/seedCli.js.map +1 -1
  36. package/dist/src-BRKm0P_S.cjs +8434 -0
  37. package/dist/src-BRKm0P_S.cjs.map +1 -0
  38. package/dist/src-CfFkki5l.js +6011 -0
  39. package/dist/src-CfFkki5l.js.map +1 -0
  40. package/dist/transform/babel.cjs +5 -422
  41. package/dist/transform/babel.d.cts +16 -16
  42. package/dist/transform/babel.d.ts +16 -16
  43. package/dist/transform/babel.js +1 -7
  44. package/dist/transform/bun.cjs +9 -478
  45. package/dist/transform/bun.cjs.map +1 -1
  46. package/dist/transform/bun.d.cts +5 -7
  47. package/dist/transform/bun.d.ts +5 -7
  48. package/dist/transform/bun.js +6 -11
  49. package/dist/transform/bun.js.map +1 -1
  50. package/dist/transform/esbuild.cjs +9 -478
  51. package/dist/transform/esbuild.cjs.map +1 -1
  52. package/dist/transform/esbuild.d.cts +5 -7
  53. package/dist/transform/esbuild.d.ts +5 -7
  54. package/dist/transform/esbuild.js +6 -11
  55. package/dist/transform/esbuild.js.map +1 -1
  56. package/dist/transform/loaderRuntime.cjs +85 -532
  57. package/dist/transform/loaderRuntime.cjs.map +1 -1
  58. package/dist/transform/loaderRuntime.d.cts +2 -12
  59. package/dist/transform/loaderRuntime.d.ts +2 -12
  60. package/dist/transform/loaderRuntime.js +56 -98
  61. package/dist/transform/loaderRuntime.js.map +1 -1
  62. package/dist/transform/nest.cjs +12 -481
  63. package/dist/transform/nest.cjs.map +1 -1
  64. package/dist/transform/nest.d.cts +8 -9
  65. package/dist/transform/nest.d.ts +8 -9
  66. package/dist/transform/nest.js +9 -14
  67. package/dist/transform/nest.js.map +1 -1
  68. package/dist/transform/next.cjs +56 -528
  69. package/dist/transform/next.cjs.map +1 -1
  70. package/dist/transform/next.d.cts +25 -25
  71. package/dist/transform/next.d.ts +24 -24
  72. package/dist/transform/next.js +52 -60
  73. package/dist/transform/next.js.map +1 -1
  74. package/dist/transform/nodeLoader.js +260 -506
  75. package/dist/transform/nodeLoader.js.map +1 -1
  76. package/dist/transform/register.js +4 -1
  77. package/dist/transform/register.js.map +1 -1
  78. package/dist/transform/rolldown.cjs +9 -478
  79. package/dist/transform/rolldown.cjs.map +1 -1
  80. package/dist/transform/rolldown.d.cts +5 -7
  81. package/dist/transform/rolldown.d.ts +5 -7
  82. package/dist/transform/rolldown.js +6 -11
  83. package/dist/transform/rolldown.js.map +1 -1
  84. package/dist/transform/rollup.cjs +9 -478
  85. package/dist/transform/rollup.cjs.map +1 -1
  86. package/dist/transform/rollup.d.cts +5 -7
  87. package/dist/transform/rollup.d.ts +5 -7
  88. package/dist/transform/rollup.js +6 -11
  89. package/dist/transform/rollup.js.map +1 -1
  90. package/dist/transform/rsbuild.cjs +9 -478
  91. package/dist/transform/rsbuild.cjs.map +1 -1
  92. package/dist/transform/rsbuild.d.cts +5 -7
  93. package/dist/transform/rsbuild.d.ts +5 -7
  94. package/dist/transform/rsbuild.js +6 -11
  95. package/dist/transform/rsbuild.js.map +1 -1
  96. package/dist/transform/rspack.cjs +9 -478
  97. package/dist/transform/rspack.cjs.map +1 -1
  98. package/dist/transform/rspack.d.cts +5 -7
  99. package/dist/transform/rspack.d.ts +5 -7
  100. package/dist/transform/rspack.js +6 -11
  101. package/dist/transform/rspack.js.map +1 -1
  102. package/dist/transform/swc.cjs +18 -486
  103. package/dist/transform/swc.cjs.map +1 -1
  104. package/dist/transform/swc.d.cts +15 -14
  105. package/dist/transform/swc.d.ts +15 -14
  106. package/dist/transform/swc.js +14 -32
  107. package/dist/transform/swc.js.map +1 -1
  108. package/dist/transform/unplugin.cjs +20 -476
  109. package/dist/transform/unplugin.cjs.map +1 -1
  110. package/dist/transform/unplugin.d.cts +4 -6
  111. package/dist/transform/unplugin.d.ts +4 -6
  112. package/dist/transform/unplugin.js +19 -8
  113. package/dist/transform/unplugin.js.map +1 -1
  114. package/dist/transform/vite.cjs +9 -478
  115. package/dist/transform/vite.cjs.map +1 -1
  116. package/dist/transform/vite.d.cts +5 -7
  117. package/dist/transform/vite.d.ts +5 -7
  118. package/dist/transform/vite.js +6 -11
  119. package/dist/transform/vite.js.map +1 -1
  120. package/dist/transform/webpack.cjs +9 -478
  121. package/dist/transform/webpack.cjs.map +1 -1
  122. package/dist/transform/webpack.d.cts +5 -7
  123. package/dist/transform/webpack.d.ts +5 -7
  124. package/dist/transform/webpack.js +6 -11
  125. package/dist/transform/webpack.js.map +1 -1
  126. package/dist/transform-BcyUocwm.js +36 -0
  127. package/dist/transform-BcyUocwm.js.map +1 -0
  128. package/dist/transform-BjxHGGKc.cjs +47 -0
  129. package/dist/transform-BjxHGGKc.cjs.map +1 -0
  130. package/dist/transformOptions-BsjCELkh.d.cts +11 -0
  131. package/dist/transformOptions-BsjCELkh.d.ts +11 -0
  132. package/package.json +5 -5
  133. package/dist/autoTrace.cjs.map +0 -1
  134. package/dist/autoTrace.js.map +0 -1
  135. package/dist/chunk-27B3UBSS.js +0 -2547
  136. package/dist/chunk-27B3UBSS.js.map +0 -1
  137. package/dist/chunk-B2M4KELA.js +0 -1912
  138. package/dist/chunk-B2M4KELA.js.map +0 -1
  139. package/dist/chunk-I233ERUH.js +0 -2979
  140. package/dist/chunk-I233ERUH.js.map +0 -1
  141. package/dist/chunk-ISU6FQKY.js +0 -6877
  142. package/dist/chunk-ISU6FQKY.js.map +0 -1
  143. package/dist/chunk-MT36GJMW.js +0 -106
  144. package/dist/chunk-MT36GJMW.js.map +0 -1
  145. package/dist/chunk-PTCLRG4E.js +0 -28
  146. package/dist/chunk-PTCLRG4E.js.map +0 -1
  147. package/dist/chunk-QRNHRY7F.js +0 -270
  148. package/dist/chunk-QRNHRY7F.js.map +0 -1
  149. package/dist/chunk-R6M54SPO.js +0 -1176
  150. package/dist/chunk-R6M54SPO.js.map +0 -1
  151. package/dist/chunk-SOP5AFMH.js +0 -2060
  152. package/dist/chunk-SOP5AFMH.js.map +0 -1
  153. package/dist/chunk-YVJAOGHE.js +0 -45
  154. package/dist/chunk-YVJAOGHE.js.map +0 -1
  155. package/dist/chunk-ZG6SHKEF.js +0 -404
  156. package/dist/chunk-ZG6SHKEF.js.map +0 -1
  157. package/dist/http-LL3JD2JE.js +0 -24
  158. package/dist/http-LL3JD2JE.js.map +0 -1
  159. package/dist/http-QZDTQC3C.js +0 -23
  160. package/dist/http-QZDTQC3C.js.map +0 -1
  161. package/dist/index.cjs.map +0 -1
  162. package/dist/index.js.map +0 -1
  163. package/dist/replay-636XZIS2.js +0 -29
  164. package/dist/replay-636XZIS2.js.map +0 -1
  165. package/dist/replay-S4DNF4VR.js +0 -28
  166. package/dist/replay-S4DNF4VR.js.map +0 -1
  167. package/dist/transform/babel.cjs.map +0 -1
  168. package/dist/transform/babel.js.map +0 -1
  169. package/dist/transformOptions-Df2_Chtc.d.cts +0 -10
  170. package/dist/transformOptions-Df2_Chtc.d.ts +0 -10
@@ -1,548 +1,101 @@
1
- "use strict";
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ //#region \0rolldown/runtime.js
2
6
  var __create = Object.create;
3
7
  var __defProp = Object.defineProperty;
4
8
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
9
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
10
  var __getProtoOf = Object.getPrototypeOf;
7
11
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
12
  var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
13
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
+ key = keys[i];
15
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: ((k) => from[k]).bind(null, key),
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
19
21
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // ../bitfab-typescript-transform/src/loaderRuntime.ts
31
- var loaderRuntime_exports = {};
32
- __export(loaderRuntime_exports, {
33
- transformBitfabModuleToJavaScript: () => transformBitfabModuleToJavaScript
34
- });
35
- module.exports = __toCommonJS(loaderRuntime_exports);
36
- var import_node_path = require("path");
37
- var import_core2 = require("@babel/core");
38
- var import_plugin_proposal_decorators = __toESM(require("@babel/plugin-proposal-decorators"), 1);
39
- var import_plugin_transform_modules_commonjs = __toESM(require("@babel/plugin-transform-modules-commonjs"), 1);
40
- var import_plugin_transform_react_jsx = __toESM(require("@babel/plugin-transform-react-jsx"), 1);
41
- var import_plugin_transform_typescript = __toESM(require("@babel/plugin-transform-typescript"), 1);
42
- var import_get_tsconfig = require("get-tsconfig");
43
-
44
- // ../bitfab-typescript-transform/src/transformOptions.ts
45
- var AUTO_TRACE_FUNCTION_ID_VERSION = "ts-auto-v1";
46
- var AUTO_TRACE_TRANSFORM_MARKER = "__bitfab_auto_trace_transformed_v1__";
47
- function autoTraceFunctionId(file, name) {
48
- return `${AUTO_TRACE_FUNCTION_ID_VERSION}:${file}#${name}`;
49
- }
50
- function sourceFilename(filename) {
51
- return filename.replace(/\\/g, "/").split(/[?#]/, 1)[0] ?? "";
52
- }
53
- function autoTraceFilename(filename, cwd) {
54
- const normalized = sourceFilename(filename);
55
- const normalizedCwd = cwd.replace(/\\/g, "/").replace(/\/$/, "");
56
- return normalized.startsWith(`${normalizedCwd}/`) ? normalized.slice(normalizedCwd.length + 1) : normalized;
57
- }
58
- function shouldTransformBitfabFile(filename, options) {
59
- if (!filename) {
60
- return false;
61
- }
62
- if (options.include && !options.include(filename)) {
63
- return false;
64
- }
65
- const normalized = sourceFilename(filename);
66
- const normalizedCwd = options.cwd?.replace(/\\/g, "/").replace(/\/$/, "");
67
- const isAbsolute = normalized.startsWith("/") || /^[A-Za-z]:\//.test(normalized);
68
- if (normalizedCwd && isAbsolute && normalized !== normalizedCwd && !normalized.startsWith(`${normalizedCwd}/`)) {
69
- return false;
70
- }
71
- return !normalized.includes("/node_modules/") && !normalized.endsWith(".d.ts") && /\.[cm]?[jt]sx?$/.test(normalized);
72
- }
73
-
74
- // ../bitfab-typescript-transform/src/babelPlugin.ts
75
- function propertyName(node, types) {
76
- if (types.isIdentifier(node)) {
77
- return node.name;
78
- }
79
- if (types.isStringLiteral(node)) {
80
- return node.value;
81
- }
82
- return null;
83
- }
84
- function functionName(path, types) {
85
- const node = path.node;
86
- if (types.isFunctionDeclaration(node) || types.isFunctionExpression(node)) {
87
- if (node.id) {
88
- return node.id.name;
89
- }
90
- }
91
- if ((types.isClassMethod(node) || types.isObjectMethod(node)) && !node.computed && types.isIdentifier(node.key)) {
92
- return node.key.name;
93
- }
94
- const parent = path.parentPath?.node;
95
- if (types.isVariableDeclarator(parent)) {
96
- return propertyName(parent.id, types) ?? "anonymous";
97
- }
98
- if (types.isObjectProperty(parent) && !parent.computed) {
99
- return propertyName(parent.key, types) ?? "anonymous";
100
- }
101
- if (types.isClassProperty(parent) && !parent.computed) {
102
- const name = propertyName(parent.key, types);
103
- if (name) {
104
- return name;
105
- }
106
- }
107
- const { line, column } = sourcePosition(path);
108
- return `anonymous-${line}-${column}`;
109
- }
110
- function isInstrumentableFunction(node, types) {
111
- if (node.generator || types.isClassPrivateMethod(node)) {
112
- return false;
113
- }
114
- return !(types.isClassMethod(node) || types.isObjectMethod(node)) || node.kind === "method";
115
- }
116
- function sourcePosition(path) {
117
- const exportDeclaration = path.parentPath?.isExportDeclaration() ? path.parentPath.node : void 0;
118
- const start = (exportDeclaration ?? path.node).loc?.start;
119
- return { line: start?.line ?? 0, column: start?.column ?? 0 };
120
- }
121
- function qualifiedFunctionName(path, types) {
122
- const ownName = functionName(path, types);
123
- if (ownName.startsWith("anonymous-")) {
124
- return ownName;
125
- }
126
- const scopes = [];
127
- let ancestor = path.parentPath;
128
- while (ancestor) {
129
- if (ancestor.isFunction()) {
130
- if (!isInstrumentableFunction(ancestor.node, types)) {
131
- ancestor = ancestor.parentPath;
132
- continue;
133
- }
134
- const name = functionName(
135
- ancestor,
136
- types
137
- );
138
- if (!name.startsWith("anonymous-")) {
139
- scopes.unshift(name);
140
- }
141
- } else if ((ancestor.isClassDeclaration() || ancestor.isClassExpression()) && ancestor.node.id) {
142
- scopes.unshift(ancestor.node.id.name);
143
- } else if (ancestor.isObjectExpression()) {
144
- const parent = ancestor.parentPath?.node;
145
- if (types.isVariableDeclarator(parent)) {
146
- const name = propertyName(parent.id, types);
147
- if (name) {
148
- scopes.unshift(name);
149
- }
150
- } else if (types.isObjectProperty(parent) && !parent.computed) {
151
- const name = propertyName(parent.key, types);
152
- if (name) {
153
- scopes.unshift(name);
154
- }
155
- }
156
- }
157
- ancestor = ancestor.parentPath;
158
- }
159
- return [...scopes, ownName].join(".");
160
- }
161
- function isTraceDecoratorRoot(path, types) {
162
- const node = path.node;
163
- const parent = path.parentPath?.node;
164
- const decorated = types.isClassMethod(node) || types.isClassPrivateMethod(node) ? node : types.isClassProperty(parent) && parent.value === node ? parent : null;
165
- if (!decorated) {
166
- return false;
167
- }
168
- return decorated.decorators?.some((decorator) => {
169
- const expression = decorator.expression;
170
- if (!types.isCallExpression(expression)) {
171
- return false;
172
- }
173
- const callee = expression.callee;
174
- return types.isMemberExpression(callee) && !callee.computed && types.isIdentifier(callee.property, { name: "trace" });
175
- }) ?? false;
176
- }
177
- function withNodeFunctionName(path, types) {
178
- if (path.node.arguments.length > 2) {
179
- return null;
180
- }
181
- const callee = path.node.callee;
182
- if (!types.isMemberExpression(callee) || callee.computed || !types.isIdentifier(callee.property, { name: "withNode" })) {
183
- return null;
184
- }
185
- const fn = path.node.arguments[path.node.arguments.length - 1];
186
- if (types.isIdentifier(fn)) {
187
- return fn.name;
188
- }
189
- if (types.isMemberExpression(fn) && !fn.computed) {
190
- return propertyName(fn.property, types);
191
- }
192
- if (types.isFunctionExpression(fn) && fn.id) {
193
- return fn.id.name;
194
- }
195
- return null;
196
- }
197
- function runtimeParameters(node, types) {
198
- return node.params.filter(
199
- (parameter) => !types.isIdentifier(parameter, { name: "this" })
200
- );
201
- }
202
- function parameterInputs(path, types) {
203
- const elements = [];
204
- for (const [index, parameter] of runtimeParameters(
205
- path.node,
206
- types
207
- ).entries()) {
208
- if (!types.isArrowFunctionExpression(path.node)) {
209
- if (types.isRestElement(parameter)) {
210
- elements.push(
211
- types.spreadElement(
212
- types.callExpression(
213
- types.memberExpression(
214
- types.arrayExpression([
215
- types.spreadElement(types.identifier("arguments"))
216
- ]),
217
- types.identifier("slice")
218
- ),
219
- [types.numericLiteral(index)]
220
- )
221
- )
222
- );
223
- } else {
224
- elements.push(
225
- types.memberExpression(
226
- types.identifier("arguments"),
227
- types.numericLiteral(index),
228
- true
229
- )
230
- );
231
- }
232
- continue;
233
- }
234
- if (types.isIdentifier(parameter)) {
235
- elements.push(types.identifier(parameter.name));
236
- } else if (types.isRestElement(parameter) && types.isIdentifier(parameter.argument)) {
237
- elements.push(
238
- types.spreadElement(types.identifier(parameter.argument.name))
239
- );
240
- }
241
- }
242
- return types.arrayExpression(elements);
243
- }
244
- function needsArgumentWrapper(path, types) {
245
- return types.isArrowFunctionExpression(path.node) && path.node.params.some(
246
- (parameter) => !types.isIdentifier(parameter) && !(types.isRestElement(parameter) && types.isIdentifier(parameter.argument))
247
- );
248
- }
249
- function isRestWrapper(path, types) {
250
- const parameters = runtimeParameters(path.node, types);
251
- return parameters.length === 1 && types.isRestElement(parameters[0]);
252
- }
253
- function bitfabBabelPlugin(api) {
254
- const { types } = api;
255
- return {
256
- name: "bitfab-auto-trace",
257
- visitor: {
258
- Program: {
259
- enter(path, state) {
260
- const filename = state.file.opts.filename ?? "unknown";
261
- state.skipFile = !shouldTransformBitfabFile(filename, state.opts) || path.scope.hasBinding(AUTO_TRACE_TRANSFORM_MARKER) || path.node.directives.some(
262
- (directive) => directive.value.value === "use client"
263
- );
264
- state.runtimeIdentifier = path.scope.generateUidIdentifier("bitfabAutoSpan");
265
- state.activeIdentifier = path.scope.generateUidIdentifier(
266
- "bitfabAutoTraceActive"
267
- );
268
- state.wrapperIdentifier = path.scope.generateUidIdentifier("bitfabAutoWrap");
269
- state.definitions = [];
270
- state.usedRuntime = false;
271
- state.usedWrapper = false;
272
- },
273
- exit(path, state) {
274
- if (state.skipFile || !state.usedRuntime || !state.runtimeIdentifier || !state.activeIdentifier || !state.wrapperIdentifier) {
275
- return;
276
- }
277
- state.file.metadata[AUTO_TRACE_TRANSFORM_MARKER] = true;
278
- path.unshiftContainer("body", [
279
- types.importDeclaration(
280
- [
281
- types.importSpecifier(
282
- state.runtimeIdentifier,
283
- types.identifier("__bitfabAutoSpan")
284
- ),
285
- types.importSpecifier(
286
- state.activeIdentifier,
287
- types.identifier("__bitfabAutoTraceActive")
288
- ),
289
- ...state.usedWrapper ? [
290
- types.importSpecifier(
291
- state.wrapperIdentifier,
292
- types.identifier("__bitfabAutoWrap")
293
- )
294
- ] : []
295
- ],
296
- types.stringLiteral(
297
- state.opts.runtimeModule ?? "@bitfab/sdk/auto"
298
- )
299
- ),
300
- types.variableDeclaration("const", [
301
- types.variableDeclarator(
302
- types.identifier(AUTO_TRACE_TRANSFORM_MARKER),
303
- types.assignmentExpression(
304
- "=",
305
- types.memberExpression(
306
- types.identifier("globalThis"),
307
- types.identifier(AUTO_TRACE_TRANSFORM_MARKER)
308
- ),
309
- types.booleanLiteral(true)
310
- )
311
- )
312
- ]),
313
- ...state.definitions ?? []
314
- ]);
315
- }
316
- },
317
- CallExpression: {
318
- exit(path, state) {
319
- if (state.skipFile) {
320
- return;
321
- }
322
- const configuredName = withNodeFunctionName(path, types);
323
- if (configuredName === null) {
324
- return;
325
- }
326
- if (path.node.arguments.length === 1) {
327
- path.node.arguments.push(types.identifier("undefined"));
328
- }
329
- path.node.arguments.push(types.stringLiteral(configuredName));
330
- }
331
- },
332
- Function: {
333
- exit(path, state) {
334
- const node = path.node;
335
- if (state.skipFile || node._bitfabInstrumented || !isInstrumentableFunction(node, types) || isTraceDecoratorRoot(path, types) || !state.runtimeIdentifier || !state.activeIdentifier || !state.wrapperIdentifier) {
336
- return;
337
- }
338
- const name = qualifiedFunctionName(path, types);
339
- if (name.startsWith("anonymous-")) {
340
- return;
341
- }
342
- const normalizedFilename = autoTraceFilename(
343
- state.file.opts.filename ?? "unknown",
344
- state.opts.cwd ?? state.file.opts.cwd ?? process.cwd()
345
- );
346
- const { line, column } = sourcePosition(path);
347
- const definition = types.objectExpression([
348
- types.objectProperty(
349
- types.identifier("id"),
350
- types.stringLiteral(
351
- autoTraceFunctionId(normalizedFilename, name)
352
- )
353
- ),
354
- types.objectProperty(
355
- types.identifier("name"),
356
- types.stringLiteral(name)
357
- ),
358
- types.objectProperty(
359
- types.identifier("file"),
360
- types.stringLiteral(normalizedFilename)
361
- ),
362
- types.objectProperty(
363
- types.identifier("line"),
364
- types.numericLiteral(line)
365
- ),
366
- types.objectProperty(
367
- types.identifier("column"),
368
- types.numericLiteral(column)
369
- ),
370
- ...node.async ? [
371
- types.objectProperty(
372
- types.identifier("async"),
373
- types.booleanLiteral(true)
374
- )
375
- ] : [],
376
- ...isRestWrapper(path, types) ? [
377
- types.objectProperty(
378
- types.identifier("wrapper"),
379
- types.booleanLiteral(true)
380
- )
381
- ] : []
382
- ]);
383
- const definitionIdentifier = path.scope.getProgramParent().generateUidIdentifier("bitfabAutoDefinition");
384
- state.definitions?.push(
385
- types.variableDeclaration("const", [
386
- types.variableDeclarator(definitionIdentifier, definition)
387
- ])
388
- );
389
- if (needsArgumentWrapper(path, types)) {
390
- node._bitfabInstrumented = true;
391
- path.replaceWith(
392
- types.callExpression(types.cloneNode(state.wrapperIdentifier), [
393
- types.cloneNode(definitionIdentifier),
394
- node
395
- ])
396
- );
397
- state.usedRuntime = true;
398
- state.usedWrapper = true;
399
- return;
400
- }
401
- const originalBody = types.isBlockStatement(node.body) ? node.body : types.blockStatement([types.returnStatement(node.body)]);
402
- const directives = originalBody.directives;
403
- originalBody.directives = [];
404
- const body = types.blockStatement(
405
- [
406
- types.ifStatement(
407
- types.callExpression(
408
- types.cloneNode(state.activeIdentifier),
409
- []
410
- ),
411
- types.blockStatement([
412
- types.returnStatement(
413
- types.callExpression(
414
- types.cloneNode(state.runtimeIdentifier),
415
- [
416
- types.cloneNode(definitionIdentifier),
417
- parameterInputs(path, types),
418
- types.arrowFunctionExpression(
419
- [],
420
- types.cloneNode(originalBody, true),
421
- node.async ?? false
422
- )
423
- ]
424
- )
425
- )
426
- ])
427
- ),
428
- ...originalBody.body
429
- ],
430
- directives
431
- );
432
- node.body = body;
433
- node._bitfabInstrumented = true;
434
- state.usedRuntime = true;
435
- }
436
- }
437
- }
438
- };
439
- }
440
-
441
- // ../bitfab-typescript-transform/src/transform.ts
442
- var import_core = require("@babel/core");
443
- function parserPlugins(filename) {
444
- const path = sourceFilename(filename);
445
- const typescript = /\.[cm]?tsx?$/.test(path);
446
- const jsx = /\.tsx$/.test(path) || /\.[cm]?jsx?$/.test(path);
447
- return [
448
- ...typescript ? ["typescript"] : [],
449
- ...jsx ? ["jsx"] : [],
450
- "decorators"
451
- ];
452
- }
453
-
454
- // ../bitfab-typescript-transform/src/loaderRuntime.ts
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+ //#endregion
27
+ const require_babelPlugin = require("../babelPlugin-Nta4-VcL.cjs");
28
+ const require_transform = require("../transform-BjxHGGKc.cjs");
29
+ let _babel_core = require("@babel/core");
30
+ let path = require("path");
31
+ let _babel_plugin_proposal_decorators = require("@babel/plugin-proposal-decorators");
32
+ _babel_plugin_proposal_decorators = __toESM(_babel_plugin_proposal_decorators, 1);
33
+ let _babel_plugin_transform_modules_commonjs = require("@babel/plugin-transform-modules-commonjs");
34
+ _babel_plugin_transform_modules_commonjs = __toESM(_babel_plugin_transform_modules_commonjs, 1);
35
+ let _babel_plugin_transform_react_jsx = require("@babel/plugin-transform-react-jsx");
36
+ _babel_plugin_transform_react_jsx = __toESM(_babel_plugin_transform_react_jsx, 1);
37
+ let _babel_plugin_transform_typescript = require("@babel/plugin-transform-typescript");
38
+ _babel_plugin_transform_typescript = __toESM(_babel_plugin_transform_typescript, 1);
39
+ let get_tsconfig = require("get-tsconfig");
40
+ //#region ../bitfab-typescript-transform/src/loaderRuntime.ts
455
41
  function readCompilerOptions(filename, configuredPath) {
456
- const config = configuredPath ? (0, import_get_tsconfig.parseTsconfig)(configuredPath) : (0, import_get_tsconfig.getTsconfig)((0, import_node_path.dirname)(filename))?.config;
457
- return config?.compilerOptions ?? {};
42
+ return (configuredPath ? (0, get_tsconfig.parseTsconfig)(configuredPath) : (0, get_tsconfig.getTsconfig)((0, path.dirname)(filename))?.config)?.compilerOptions ?? {};
458
43
  }
459
44
  function reactJsxOptions(compilerOptions) {
460
- if (compilerOptions.jsx === "react") {
461
- return [
462
- import_plugin_transform_react_jsx.default,
463
- {
464
- runtime: "classic",
465
- ...compilerOptions.jsxFactory && {
466
- pragma: compilerOptions.jsxFactory
467
- },
468
- ...compilerOptions.jsxFragmentFactory && {
469
- pragmaFrag: compilerOptions.jsxFragmentFactory
470
- }
471
- }
472
- ];
473
- }
474
- return [
475
- import_plugin_transform_react_jsx.default,
476
- {
477
- runtime: "automatic",
478
- importSource: compilerOptions.jsxImportSource ?? "react"
479
- }
480
- ];
45
+ if (compilerOptions.jsx === "react") return [_babel_plugin_transform_react_jsx.default, {
46
+ runtime: "classic",
47
+ ...compilerOptions.jsxFactory && { pragma: compilerOptions.jsxFactory },
48
+ ...compilerOptions.jsxFragmentFactory && { pragmaFrag: compilerOptions.jsxFragmentFactory }
49
+ }];
50
+ return [_babel_plugin_transform_react_jsx.default, {
51
+ runtime: "automatic",
52
+ importSource: compilerOptions.jsxImportSource ?? "react"
53
+ }];
481
54
  }
482
55
  function compilePlugins(filename, compilerOptions, format) {
483
- const path = sourceFilename(filename);
484
- const isTypeScript = /\.[cm]?tsx?$/.test(path);
485
- const hasJsx = /\.[jt]sx$/.test(path);
486
- const isCommonJs = format === "commonjs" || path.endsWith(".cts");
487
- return [
488
- ...isTypeScript ? [
489
- [
490
- import_plugin_transform_typescript.default,
491
- {
492
- onlyRemoveTypeImports: compilerOptions.verbatimModuleSyntax === true
493
- }
494
- ]
495
- ] : [],
496
- [
497
- import_plugin_proposal_decorators.default,
498
- {
499
- version: compilerOptions.experimentalDecorators ? "legacy" : "2023-11"
500
- }
501
- ],
502
- ...hasJsx ? [reactJsxOptions(compilerOptions)] : [],
503
- ...isCommonJs ? [import_plugin_transform_modules_commonjs.default] : []
504
- ];
56
+ const path$1 = require_babelPlugin.sourceFilename(filename);
57
+ const isTypeScript = /\.[cm]?tsx?$/.test(path$1);
58
+ const hasJsx = /\.[jt]sx$/.test(path$1);
59
+ const isCommonJs = format === "commonjs" || path$1.endsWith(".cts");
60
+ return [
61
+ ...isTypeScript ? [[_babel_plugin_transform_typescript.default, { onlyRemoveTypeImports: compilerOptions.verbatimModuleSyntax === true }]] : [],
62
+ [_babel_plugin_proposal_decorators.default, { version: compilerOptions.experimentalDecorators ? "legacy" : "2023-11" }],
63
+ ...hasJsx ? [reactJsxOptions(compilerOptions)] : [],
64
+ ...isCommonJs ? [_babel_plugin_transform_modules_commonjs.default] : []
65
+ ];
505
66
  }
506
67
  function transformBitfabModuleToJavaScript(source, filename, options = {}, format, sourceMapMode = "external") {
507
- const { tsconfig, ...transformOptions } = options;
508
- if (!shouldTransformBitfabFile(filename, transformOptions)) {
509
- return { code: source };
510
- }
511
- const sourceFile = sourceFilename(filename);
512
- const instrumented = (0, import_core2.transformSync)(source, {
513
- ast: true,
514
- babelrc: false,
515
- code: false,
516
- configFile: false,
517
- filename: sourceFile,
518
- parserOpts: { plugins: parserPlugins(filename), sourceType: "module" },
519
- plugins: [[bitfabBabelPlugin, transformOptions]]
520
- });
521
- if (!instrumented?.ast) {
522
- throw new Error(`Bitfab could not parse ${sourceFile}`);
523
- }
524
- const compiled = (0, import_core2.transformFromAstSync)(instrumented.ast, source, {
525
- babelrc: false,
526
- cloneInputAst: false,
527
- configFile: false,
528
- filename: sourceFile,
529
- plugins: compilePlugins(
530
- filename,
531
- readCompilerOptions(filename, tsconfig),
532
- format
533
- ),
534
- sourceMaps: sourceMapMode === "inline" ? "inline" : true
535
- });
536
- if (compiled?.code === void 0 || compiled.code === null) {
537
- throw new Error(`Bitfab could not compile ${sourceFile}`);
538
- }
539
- return {
540
- code: compiled.code,
541
- ...compiled.map ? { map: JSON.stringify(compiled.map) } : {}
542
- };
543
- }
544
- // Annotate the CommonJS export names for ESM import in node:
545
- 0 && (module.exports = {
546
- transformBitfabModuleToJavaScript
547
- });
68
+ const { tsconfig, ...transformOptions } = options;
69
+ if (!require_babelPlugin.shouldTransformBitfabFile(filename, transformOptions)) return { code: source };
70
+ const sourceFile = require_babelPlugin.sourceFilename(filename);
71
+ const instrumented = (0, _babel_core.transformSync)(source, {
72
+ ast: true,
73
+ babelrc: false,
74
+ code: false,
75
+ configFile: false,
76
+ filename: sourceFile,
77
+ parserOpts: {
78
+ plugins: require_transform.parserPlugins(filename),
79
+ sourceType: "module"
80
+ },
81
+ plugins: [[require_babelPlugin.bitfabBabelPlugin, transformOptions]]
82
+ });
83
+ if (!instrumented?.ast) throw new Error(`Bitfab could not parse ${sourceFile}`);
84
+ const compiled = (0, _babel_core.transformFromAstSync)(instrumented.ast, source, {
85
+ babelrc: false,
86
+ cloneInputAst: false,
87
+ configFile: false,
88
+ filename: sourceFile,
89
+ plugins: compilePlugins(filename, readCompilerOptions(filename, tsconfig), format),
90
+ sourceMaps: sourceMapMode === "inline" ? "inline" : true
91
+ });
92
+ if (compiled?.code === void 0 || compiled.code === null) throw new Error(`Bitfab could not compile ${sourceFile}`);
93
+ return {
94
+ code: compiled.code,
95
+ ...compiled.map ? { map: JSON.stringify(compiled.map) } : {}
96
+ };
97
+ }
98
+ //#endregion
99
+ exports.transformBitfabModuleToJavaScript = transformBitfabModuleToJavaScript;
100
+
548
101
  //# sourceMappingURL=loaderRuntime.cjs.map