@mondaydotcomorg/atp-compiler 0.19.22 → 0.19.23
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/index.cjs +114 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +114 -7
- package/dist/index.js.map +1 -1
- package/dist/transformer/array-transformer-batch-reconstruct.d.ts +11 -0
- package/dist/transformer/array-transformer-batch-reconstruct.d.ts.map +1 -0
- package/dist/transformer/array-transformer-batch-reconstruct.js +97 -0
- package/dist/transformer/array-transformer-batch-reconstruct.js.map +1 -0
- package/dist/transformer/array-transformer.d.ts.map +1 -1
- package/dist/transformer/array-transformer.js +15 -1
- package/dist/transformer/array-transformer.js.map +1 -1
- package/dist/transformer/index.d.ts +1 -0
- package/dist/transformer/index.d.ts.map +1 -1
- package/dist/transformer/index.js +1 -0
- package/dist/transformer/index.js.map +1 -1
- package/package.json +1 -1
- package/src/transformer/array-transformer-batch-reconstruct.ts +155 -0
- package/src/transformer/array-transformer.ts +29 -1
- package/src/transformer/index.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1265,6 +1265,100 @@ function transformToSequential(path, node, methodName, callback, onTransform) {
|
|
|
1265
1265
|
return true;
|
|
1266
1266
|
}
|
|
1267
1267
|
__name(transformToSequential, "transformToSequential");
|
|
1268
|
+
var traverse2 = typeof _traverse__default.default.default === "function" ? _traverse__default.default.default : _traverse__default.default;
|
|
1269
|
+
function transformToBatchWithReconstruction(path, node, methodName, callback, batchDetector, onTransform) {
|
|
1270
|
+
if (methodName !== "map") {
|
|
1271
|
+
return false;
|
|
1272
|
+
}
|
|
1273
|
+
const paramName = callback.params[0];
|
|
1274
|
+
if (!t7__namespace.isIdentifier(paramName)) {
|
|
1275
|
+
return false;
|
|
1276
|
+
}
|
|
1277
|
+
const param = paramName.name;
|
|
1278
|
+
const array = node.callee.object;
|
|
1279
|
+
const llmCall = findLLMCallExpression(callback.body);
|
|
1280
|
+
if (!llmCall) {
|
|
1281
|
+
return false;
|
|
1282
|
+
}
|
|
1283
|
+
const callInfo = batchDetector.extractCallInfo(llmCall);
|
|
1284
|
+
if (!callInfo) {
|
|
1285
|
+
return false;
|
|
1286
|
+
}
|
|
1287
|
+
const payloadNode = batchDetector.extractPayloadNode(llmCall);
|
|
1288
|
+
if (!payloadNode) {
|
|
1289
|
+
return false;
|
|
1290
|
+
}
|
|
1291
|
+
const methodId = generateUniqueId(`${methodName}_batch_reconstruct`);
|
|
1292
|
+
const resultsVar = `__batch_results_${methodId.replace(/[^a-zA-Z0-9]/g, "_")}`;
|
|
1293
|
+
const indexVar = "__idx";
|
|
1294
|
+
const payloadMapper = t7__namespace.arrowFunctionExpression([
|
|
1295
|
+
t7__namespace.identifier(param)
|
|
1296
|
+
], t7__namespace.objectExpression([
|
|
1297
|
+
t7__namespace.objectProperty(t7__namespace.identifier("type"), t7__namespace.stringLiteral(callInfo.type)),
|
|
1298
|
+
t7__namespace.objectProperty(t7__namespace.identifier("operation"), t7__namespace.stringLiteral(callInfo.operation)),
|
|
1299
|
+
t7__namespace.objectProperty(t7__namespace.identifier("payload"), t7__namespace.cloneNode(payloadNode, true))
|
|
1300
|
+
]));
|
|
1301
|
+
const clonedBody = t7__namespace.cloneNode(callback.body, true);
|
|
1302
|
+
const resultAccess = t7__namespace.memberExpression(t7__namespace.identifier(resultsVar), t7__namespace.identifier(indexVar), true);
|
|
1303
|
+
let traversableNode;
|
|
1304
|
+
if (t7__namespace.isBlockStatement(clonedBody)) {
|
|
1305
|
+
traversableNode = t7__namespace.functionDeclaration(t7__namespace.identifier("__temp"), [], clonedBody);
|
|
1306
|
+
} else {
|
|
1307
|
+
traversableNode = t7__namespace.expressionStatement(clonedBody);
|
|
1308
|
+
}
|
|
1309
|
+
let replaced = false;
|
|
1310
|
+
traverse2(t7__namespace.file(t7__namespace.program([
|
|
1311
|
+
traversableNode
|
|
1312
|
+
])), {
|
|
1313
|
+
AwaitExpression(awaitPath) {
|
|
1314
|
+
if (replaced) return;
|
|
1315
|
+
const arg = awaitPath.node.argument;
|
|
1316
|
+
if (t7__namespace.isCallExpression(arg)) {
|
|
1317
|
+
const info = batchDetector.extractCallInfo(arg);
|
|
1318
|
+
if (info && info.type === callInfo.type && info.operation === callInfo.operation) {
|
|
1319
|
+
awaitPath.replaceWith(resultAccess);
|
|
1320
|
+
replaced = true;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
},
|
|
1324
|
+
noScope: true
|
|
1325
|
+
});
|
|
1326
|
+
if (!replaced) {
|
|
1327
|
+
return false;
|
|
1328
|
+
}
|
|
1329
|
+
let reconstructBody;
|
|
1330
|
+
if (t7__namespace.isBlockStatement(clonedBody)) {
|
|
1331
|
+
reconstructBody = clonedBody;
|
|
1332
|
+
} else {
|
|
1333
|
+
reconstructBody = clonedBody;
|
|
1334
|
+
}
|
|
1335
|
+
const reconstructMapper = t7__namespace.arrowFunctionExpression([
|
|
1336
|
+
t7__namespace.identifier(param),
|
|
1337
|
+
t7__namespace.identifier(indexVar)
|
|
1338
|
+
], reconstructBody);
|
|
1339
|
+
reconstructMapper.async = false;
|
|
1340
|
+
const batchCall = t7__namespace.awaitExpression(t7__namespace.callExpression(t7__namespace.memberExpression(t7__namespace.identifier("__runtime"), t7__namespace.identifier("batchParallel")), [
|
|
1341
|
+
t7__namespace.callExpression(t7__namespace.memberExpression(t7__namespace.cloneNode(array, true), t7__namespace.identifier("map")), [
|
|
1342
|
+
payloadMapper
|
|
1343
|
+
]),
|
|
1344
|
+
t7__namespace.stringLiteral(methodId)
|
|
1345
|
+
]));
|
|
1346
|
+
const resultsDeclaration = t7__namespace.variableDeclaration("const", [
|
|
1347
|
+
t7__namespace.variableDeclarator(t7__namespace.identifier(resultsVar), batchCall)
|
|
1348
|
+
]);
|
|
1349
|
+
const reconstructCall = t7__namespace.callExpression(t7__namespace.memberExpression(t7__namespace.cloneNode(array, true), t7__namespace.identifier("map")), [
|
|
1350
|
+
reconstructMapper
|
|
1351
|
+
]);
|
|
1352
|
+
const iife = t7__namespace.callExpression(t7__namespace.arrowFunctionExpression([], t7__namespace.blockStatement([
|
|
1353
|
+
resultsDeclaration,
|
|
1354
|
+
t7__namespace.returnStatement(reconstructCall)
|
|
1355
|
+
]), true), []);
|
|
1356
|
+
const awaitIife = t7__namespace.awaitExpression(iife);
|
|
1357
|
+
path.replaceWith(awaitIife);
|
|
1358
|
+
onTransform();
|
|
1359
|
+
return true;
|
|
1360
|
+
}
|
|
1361
|
+
__name(transformToBatchWithReconstruction, "transformToBatchWithReconstruction");
|
|
1268
1362
|
|
|
1269
1363
|
// src/transformer/array-transformer.ts
|
|
1270
1364
|
var ArrayTransformer = class {
|
|
@@ -1291,6 +1385,19 @@ var ArrayTransformer = class {
|
|
|
1291
1385
|
return false;
|
|
1292
1386
|
}
|
|
1293
1387
|
const batchResult = this.batchOptimizer.canBatchArrayMethod(callback);
|
|
1388
|
+
if (!batchResult.canBatch && methodName === "map") {
|
|
1389
|
+
const reason = batchResult.reason || "";
|
|
1390
|
+
const hasObjectOrArrayReturn = reason.includes("object expression") || reason.includes("array expression");
|
|
1391
|
+
if (hasObjectOrArrayReturn) {
|
|
1392
|
+
const llmCall = findLLMCallExpression(callback.body);
|
|
1393
|
+
if (llmCall) {
|
|
1394
|
+
const success = transformToBatchWithReconstruction(path, node, methodName, callback, this.batchDetector, () => this.transformCount++);
|
|
1395
|
+
if (success) {
|
|
1396
|
+
return true;
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1294
1401
|
if (batchResult.canBatch && canUseBatchParallel(methodName)) {
|
|
1295
1402
|
const array = node.callee.object;
|
|
1296
1403
|
const decision = this.batchOptimizer.makeSmartBatchDecision(methodName, batchResult, array, this.batchSizeThreshold);
|
|
@@ -1594,7 +1701,7 @@ function isTransformationError(error) {
|
|
|
1594
1701
|
__name(isTransformationError, "isTransformationError");
|
|
1595
1702
|
|
|
1596
1703
|
// src/transformer/index.ts
|
|
1597
|
-
var
|
|
1704
|
+
var traverse3 = _traverse__default.default.default || _traverse__default.default;
|
|
1598
1705
|
var generate = _generate__default.default.default || _generate__default.default;
|
|
1599
1706
|
var ATPCompiler = class {
|
|
1600
1707
|
static {
|
|
@@ -1646,7 +1753,7 @@ var ATPCompiler = class {
|
|
|
1646
1753
|
this.loopTransformer.resetTransformCount();
|
|
1647
1754
|
this.arrayTransformer.resetTransformCount();
|
|
1648
1755
|
this.promiseTransformer.resetTransformCount();
|
|
1649
|
-
|
|
1756
|
+
traverse3(ast, {
|
|
1650
1757
|
ForOfStatement: /* @__PURE__ */ __name((path) => {
|
|
1651
1758
|
this.loopTransformer.transformForOfLoop(path);
|
|
1652
1759
|
}, "ForOfStatement"),
|
|
@@ -2329,7 +2436,7 @@ function createTransformPlugin(config) {
|
|
|
2329
2436
|
};
|
|
2330
2437
|
}
|
|
2331
2438
|
__name(createTransformPlugin, "createTransformPlugin");
|
|
2332
|
-
var
|
|
2439
|
+
var traverse4 = _traverse__default.default.default || _traverse__default.default;
|
|
2333
2440
|
var generate2 = _generate__default.default.default || _generate__default.default;
|
|
2334
2441
|
var PluggableCompiler = class {
|
|
2335
2442
|
static {
|
|
@@ -2450,7 +2557,7 @@ var PluggableCompiler = class {
|
|
|
2450
2557
|
}
|
|
2451
2558
|
}
|
|
2452
2559
|
}
|
|
2453
|
-
|
|
2560
|
+
traverse4(ast, visitors);
|
|
2454
2561
|
let optimizedAst = ast;
|
|
2455
2562
|
const optimizers = this.registry.getOptimizers();
|
|
2456
2563
|
for (const optimizer of optimizers) {
|
|
@@ -2842,7 +2949,7 @@ var AsyncTimeoutPlugin = class {
|
|
|
2842
2949
|
return null;
|
|
2843
2950
|
}
|
|
2844
2951
|
};
|
|
2845
|
-
var
|
|
2952
|
+
var traverse5 = _traverse__default.default.default || _traverse__default.default;
|
|
2846
2953
|
var SecurityValidatorPlugin = class {
|
|
2847
2954
|
static {
|
|
2848
2955
|
__name(this, "SecurityValidatorPlugin");
|
|
@@ -2879,7 +2986,7 @@ var SecurityValidatorPlugin = class {
|
|
|
2879
2986
|
}
|
|
2880
2987
|
let maxNestingFound = 0;
|
|
2881
2988
|
let complexityScore = 0;
|
|
2882
|
-
|
|
2989
|
+
traverse5(ast, {
|
|
2883
2990
|
enter(path) {
|
|
2884
2991
|
const depth = path.scope.path.node ? getDepth(path) : 0;
|
|
2885
2992
|
maxNestingFound = Math.max(maxNestingFound, depth);
|
|
@@ -2994,6 +3101,7 @@ exports.resumableSome = resumableSome;
|
|
|
2994
3101
|
exports.resumableWhile = resumableWhile;
|
|
2995
3102
|
exports.setCheckpointManager = setCheckpointManager;
|
|
2996
3103
|
exports.setRuntimeContext = setRuntimeContext;
|
|
3104
|
+
exports.transformToBatchWithReconstruction = transformToBatchWithReconstruction;
|
|
2997
3105
|
exports.wrapInAsyncFunction = wrapInAsyncFunction;
|
|
2998
3106
|
//# sourceMappingURL=index.cjs.map
|
|
2999
3107
|
//# sourceMappingURL=index.cjs.map
|