@mondaydotcomorg/atp-compiler 0.18.2 → 0.18.4-rc.0
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/__tests__/unit/default-compiler.test.ts +259 -0
- package/__tests__/unit/plugin-system.test.ts +401 -0
- package/dist/atp-compiler/src/index.d.ts +8 -0
- package/dist/atp-compiler/src/index.d.ts.map +1 -1
- package/dist/atp-compiler/src/index.js +9 -0
- package/dist/atp-compiler/src/index.js.map +1 -1
- package/dist/atp-compiler/src/plugin-system/create-default-compiler.d.ts +40 -0
- package/dist/atp-compiler/src/plugin-system/create-default-compiler.d.ts.map +1 -0
- package/dist/atp-compiler/src/plugin-system/create-default-compiler.js +40 -0
- package/dist/atp-compiler/src/plugin-system/create-default-compiler.js.map +1 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/array-transformer-plugin.d.ts +18 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/array-transformer-plugin.d.ts.map +1 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/array-transformer-plugin.js +45 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/array-transformer-plugin.js.map +1 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/detection-plugin.d.ts +17 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/detection-plugin.d.ts.map +1 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/detection-plugin.js +33 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/detection-plugin.js.map +1 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/index.d.ts +11 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/index.d.ts.map +1 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/index.js +11 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/index.js.map +1 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/loop-transformer-plugin.d.ts +17 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/loop-transformer-plugin.d.ts.map +1 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/loop-transformer-plugin.js +36 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/loop-transformer-plugin.js.map +1 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/promise-transformer-plugin.d.ts +19 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/promise-transformer-plugin.d.ts.map +1 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/promise-transformer-plugin.js +49 -0
- package/dist/atp-compiler/src/plugin-system/default-plugins/promise-transformer-plugin.js.map +1 -0
- package/dist/atp-compiler/src/plugin-system/examples/loop-transformer-plugin.d.ts +31 -0
- package/dist/atp-compiler/src/plugin-system/examples/loop-transformer-plugin.d.ts.map +1 -0
- package/dist/atp-compiler/src/plugin-system/examples/loop-transformer-plugin.js +60 -0
- package/dist/atp-compiler/src/plugin-system/examples/loop-transformer-plugin.js.map +1 -0
- package/dist/atp-compiler/src/plugin-system/examples/security-validator-plugin.d.ts +48 -0
- package/dist/atp-compiler/src/plugin-system/examples/security-validator-plugin.d.ts.map +1 -0
- package/dist/atp-compiler/src/plugin-system/examples/security-validator-plugin.js +108 -0
- package/dist/atp-compiler/src/plugin-system/examples/security-validator-plugin.js.map +1 -0
- package/dist/atp-compiler/src/plugin-system/examples/timeout-plugin.d.ts +53 -0
- package/dist/atp-compiler/src/plugin-system/examples/timeout-plugin.d.ts.map +1 -0
- package/dist/atp-compiler/src/plugin-system/examples/timeout-plugin.js +106 -0
- package/dist/atp-compiler/src/plugin-system/examples/timeout-plugin.js.map +1 -0
- package/dist/atp-compiler/src/plugin-system/index.d.ts +14 -0
- package/dist/atp-compiler/src/plugin-system/index.d.ts.map +1 -0
- package/dist/atp-compiler/src/plugin-system/index.js +16 -0
- package/dist/atp-compiler/src/plugin-system/index.js.map +1 -0
- package/dist/atp-compiler/src/plugin-system/pluggable-compiler.d.ts +102 -0
- package/dist/atp-compiler/src/plugin-system/pluggable-compiler.d.ts.map +1 -0
- package/dist/atp-compiler/src/plugin-system/pluggable-compiler.js +280 -0
- package/dist/atp-compiler/src/plugin-system/pluggable-compiler.js.map +1 -0
- package/dist/atp-compiler/src/plugin-system/plugin-api.d.ts +165 -0
- package/dist/atp-compiler/src/plugin-system/plugin-api.d.ts.map +1 -0
- package/dist/atp-compiler/src/plugin-system/plugin-api.js +180 -0
- package/dist/atp-compiler/src/plugin-system/plugin-api.js.map +1 -0
- package/dist/atp-compiler/src/transformer/index.d.ts +15 -1
- package/dist/atp-compiler/src/transformer/index.d.ts.map +1 -1
- package/dist/atp-compiler/src/transformer/index.js +17 -0
- package/dist/atp-compiler/src/transformer/index.js.map +1 -1
- package/dist/atp-compiler/src/types/compiler-interface.d.ts +61 -0
- package/dist/atp-compiler/src/types/compiler-interface.d.ts.map +1 -0
- package/dist/atp-compiler/src/types/compiler-interface.js +18 -0
- package/dist/atp-compiler/src/types/compiler-interface.js.map +1 -0
- package/dist/runtime/src/approval/index.js +2 -1
- package/dist/runtime/src/approval/index.js.map +1 -1
- package/dist/runtime/src/index.d.ts +1 -1
- package/dist/runtime/src/index.d.ts.map +1 -1
- package/dist/runtime/src/index.js +1 -1
- package/dist/runtime/src/index.js.map +1 -1
- package/dist/runtime/src/llm/index.d.ts +1 -1
- package/dist/runtime/src/llm/index.d.ts.map +1 -1
- package/dist/runtime/src/llm/index.js +1 -1
- package/dist/runtime/src/llm/index.js.map +1 -1
- package/dist/runtime/src/llm/replay.d.ts +75 -0
- package/dist/runtime/src/llm/replay.d.ts.map +1 -1
- package/dist/runtime/src/llm/replay.js +187 -5
- package/dist/runtime/src/llm/replay.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -5
- package/src/index.ts +26 -0
- package/src/plugin-system/create-default-compiler.ts +57 -0
- package/src/plugin-system/default-plugins/array-transformer-plugin.ts +57 -0
- package/src/plugin-system/default-plugins/detection-plugin.ts +41 -0
- package/src/plugin-system/default-plugins/index.ts +12 -0
- package/src/plugin-system/default-plugins/loop-transformer-plugin.ts +47 -0
- package/src/plugin-system/default-plugins/promise-transformer-plugin.ts +63 -0
- package/src/plugin-system/examples/loop-transformer-plugin.ts +76 -0
- package/src/plugin-system/examples/security-validator-plugin.ts +168 -0
- package/src/plugin-system/examples/timeout-plugin.ts +158 -0
- package/src/plugin-system/index.ts +19 -0
- package/src/plugin-system/pluggable-compiler.ts +318 -0
- package/src/plugin-system/plugin-api.ts +330 -0
- package/src/transformer/index.ts +21 -1
- package/src/types/compiler-interface.ts +79 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory function to create a PluggableCompiler with all default plugins
|
|
3
|
+
*
|
|
4
|
+
* This makes PluggableCompiler a drop-in replacement for ATPCompiler
|
|
5
|
+
*/
|
|
6
|
+
import { PluggableCompiler } from './pluggable-compiler.js';
|
|
7
|
+
import type { CompilerConfig } from '../types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create a PluggableCompiler with all default ATP transformations
|
|
10
|
+
*
|
|
11
|
+
* This provides the same functionality as ATPCompiler but with plugin extensibility.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Drop-in replacement for ATPCompiler
|
|
16
|
+
* const compiler = createDefaultCompiler({
|
|
17
|
+
* enableBatchParallel: true,
|
|
18
|
+
* maxBatchSize: 10,
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Works exactly like ATPCompiler
|
|
22
|
+
* const result = await compiler.transform(code);
|
|
23
|
+
*
|
|
24
|
+
* // But you can also add custom plugins!
|
|
25
|
+
* compiler.use(myCustomPlugin);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function createDefaultCompiler(config?: Partial<CompilerConfig>): PluggableCompiler;
|
|
29
|
+
/**
|
|
30
|
+
* Type alias for backward compatibility
|
|
31
|
+
*
|
|
32
|
+
* This allows:
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import type { ATPCompilerLike } from '@mondaydotcomorg/atp-compiler';
|
|
35
|
+
*
|
|
36
|
+
* const compiler: ATPCompilerLike = createDefaultCompiler();
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export type ATPCompilerLike = PluggableCompiler;
|
|
40
|
+
//# sourceMappingURL=create-default-compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-default-compiler.d.ts","sourceRoot":"","sources":["../../../../src/plugin-system/create-default-compiler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAK5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,OAAO,CAAC,cAAc,CAAM,GAAG,iBAAiB,CAU7F;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory function to create a PluggableCompiler with all default plugins
|
|
3
|
+
*
|
|
4
|
+
* This makes PluggableCompiler a drop-in replacement for ATPCompiler
|
|
5
|
+
*/
|
|
6
|
+
import { PluggableCompiler } from './pluggable-compiler.js';
|
|
7
|
+
import { DefaultDetectionPlugin } from './default-plugins/detection-plugin.js';
|
|
8
|
+
import { DefaultLoopTransformerPlugin } from './default-plugins/loop-transformer-plugin.js';
|
|
9
|
+
import { DefaultArrayTransformerPlugin } from './default-plugins/array-transformer-plugin.js';
|
|
10
|
+
import { DefaultPromiseTransformerPlugin } from './default-plugins/promise-transformer-plugin.js';
|
|
11
|
+
/**
|
|
12
|
+
* Create a PluggableCompiler with all default ATP transformations
|
|
13
|
+
*
|
|
14
|
+
* This provides the same functionality as ATPCompiler but with plugin extensibility.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Drop-in replacement for ATPCompiler
|
|
19
|
+
* const compiler = createDefaultCompiler({
|
|
20
|
+
* enableBatchParallel: true,
|
|
21
|
+
* maxBatchSize: 10,
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Works exactly like ATPCompiler
|
|
25
|
+
* const result = await compiler.transform(code);
|
|
26
|
+
*
|
|
27
|
+
* // But you can also add custom plugins!
|
|
28
|
+
* compiler.use(myCustomPlugin);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function createDefaultCompiler(config = {}) {
|
|
32
|
+
const compiler = new PluggableCompiler(config);
|
|
33
|
+
// Register default plugins that provide all ATP compiler functionality
|
|
34
|
+
compiler.use(new DefaultDetectionPlugin());
|
|
35
|
+
compiler.use(new DefaultLoopTransformerPlugin(config.batchSizeThreshold));
|
|
36
|
+
compiler.use(new DefaultArrayTransformerPlugin(config.batchSizeThreshold));
|
|
37
|
+
compiler.use(new DefaultPromiseTransformerPlugin(config.enableBatchParallel));
|
|
38
|
+
return compiler;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=create-default-compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-default-compiler.js","sourceRoot":"","sources":["../../../../src/plugin-system/create-default-compiler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAAE,6BAA6B,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,EAAE,+BAA+B,EAAE,MAAM,iDAAiD,CAAC;AAGlG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAkC,EAAE;IACzE,MAAM,QAAQ,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAE/C,uEAAuE;IACvE,QAAQ,CAAC,GAAG,CAAC,IAAI,sBAAsB,EAAE,CAAC,CAAC;IAC3C,QAAQ,CAAC,GAAG,CAAC,IAAI,4BAA4B,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC1E,QAAQ,CAAC,GAAG,CAAC,IAAI,6BAA6B,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC3E,QAAQ,CAAC,GAAG,CAAC,IAAI,+BAA+B,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAE9E,OAAO,QAAQ,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Array Transformer Plugin
|
|
3
|
+
* Wraps the existing ArrayTransformer
|
|
4
|
+
*/
|
|
5
|
+
import type { TransformationPlugin, BabelVisitor } from '../plugin-api.js';
|
|
6
|
+
import type { CompilerConfig, TransformMetadata } from '../../types.js';
|
|
7
|
+
export declare class DefaultArrayTransformerPlugin implements TransformationPlugin {
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
priority: number;
|
|
11
|
+
private transformer;
|
|
12
|
+
constructor(batchSizeThreshold?: number);
|
|
13
|
+
getVisitor(config: CompilerConfig): BabelVisitor;
|
|
14
|
+
getMetadata(): Partial<TransformMetadata>;
|
|
15
|
+
reset(): void;
|
|
16
|
+
private isArrayMethodCall;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=array-transformer-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-transformer-plugin.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-system/default-plugins/array-transformer-plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,qBAAa,6BAA8B,YAAW,oBAAoB;IACzE,IAAI,SAA2B;IAC/B,OAAO,SAAW;IAClB,QAAQ,SAAO;IAEf,OAAO,CAAC,WAAW,CAAmB;gBAE1B,kBAAkB,CAAC,EAAE,MAAM;IAIvC,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,YAAY;IAWhD,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAMzC,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,iBAAiB;CAazB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Array Transformer Plugin
|
|
3
|
+
* Wraps the existing ArrayTransformer
|
|
4
|
+
*/
|
|
5
|
+
import * as t from '@babel/types';
|
|
6
|
+
import { ArrayTransformer } from '../../transformer/array-transformer.js';
|
|
7
|
+
export class DefaultArrayTransformerPlugin {
|
|
8
|
+
name = 'atp-array-transformer';
|
|
9
|
+
version = '1.0.0';
|
|
10
|
+
priority = 100;
|
|
11
|
+
transformer;
|
|
12
|
+
constructor(batchSizeThreshold) {
|
|
13
|
+
this.transformer = new ArrayTransformer(batchSizeThreshold);
|
|
14
|
+
}
|
|
15
|
+
getVisitor(config) {
|
|
16
|
+
return {
|
|
17
|
+
CallExpression: (path) => {
|
|
18
|
+
const node = path.node;
|
|
19
|
+
if (this.isArrayMethodCall(node)) {
|
|
20
|
+
this.transformer.transformArrayMethod(path);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
getMetadata() {
|
|
26
|
+
return {
|
|
27
|
+
arrayMethodCount: this.transformer.getTransformCount(),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
reset() {
|
|
31
|
+
this.transformer.resetTransformCount();
|
|
32
|
+
}
|
|
33
|
+
isArrayMethodCall(node) {
|
|
34
|
+
if (!t.isMemberExpression(node.callee)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const property = node.callee.property;
|
|
38
|
+
if (!t.isIdentifier(property)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
const arrayMethods = ['map', 'forEach', 'filter', 'reduce', 'find', 'some', 'every', 'flatMap'];
|
|
42
|
+
return arrayMethods.includes(property.name);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=array-transformer-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-transformer-plugin.js","sourceRoot":"","sources":["../../../../../src/plugin-system/default-plugins/array-transformer-plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE1E,MAAM,OAAO,6BAA6B;IACzC,IAAI,GAAG,uBAAuB,CAAC;IAC/B,OAAO,GAAG,OAAO,CAAC;IAClB,QAAQ,GAAG,GAAG,CAAC;IAEP,WAAW,CAAmB;IAEtC,YAAY,kBAA2B;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;IAC7D,CAAC;IAED,UAAU,CAAC,MAAsB;QAChC,OAAO;YACN,cAAc,EAAE,CAAC,IAAS,EAAE,EAAE;gBAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;gBACvB,IAAI,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;oBAClC,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;gBAC7C,CAAC;YACF,CAAC;SACD,CAAC;IACH,CAAC;IAED,WAAW;QACV,OAAO;YACN,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE;SACtD,CAAC;IACH,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC;IACxC,CAAC;IAEO,iBAAiB,CAAC,IAAsB;QAC/C,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACxC,OAAO,KAAK,CAAC;QACd,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC;QACd,CAAC;QAED,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAChG,OAAO,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Detection Plugin
|
|
3
|
+
* Wraps the existing AsyncIterationDetector
|
|
4
|
+
*/
|
|
5
|
+
import type * as t from '@babel/types';
|
|
6
|
+
import type { DetectionPlugin } from '../plugin-api.js';
|
|
7
|
+
import type { AsyncPattern, DetectionResult } from '../../types.js';
|
|
8
|
+
export declare class DefaultDetectionPlugin implements DetectionPlugin {
|
|
9
|
+
name: string;
|
|
10
|
+
version: string;
|
|
11
|
+
priority: number;
|
|
12
|
+
patterns: AsyncPattern[];
|
|
13
|
+
private detector;
|
|
14
|
+
constructor();
|
|
15
|
+
detect(code: string, ast: t.File): Promise<DetectionResult>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=detection-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detection-plugin.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-system/default-plugins/detection-plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAkB,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGpF,qBAAa,sBAAuB,YAAW,eAAe;IAC7D,IAAI,SAA0B;IAC9B,OAAO,SAAW;IAClB,QAAQ,SAAO;IACf,QAAQ,EAAE,YAAY,EAAE,CAatB;IAEF,OAAO,CAAC,QAAQ,CAAyB;;IAMnC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC;CAIjE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Detection Plugin
|
|
3
|
+
* Wraps the existing AsyncIterationDetector
|
|
4
|
+
*/
|
|
5
|
+
import { AsyncIterationDetector } from '../../transformer/detector.js';
|
|
6
|
+
export class DefaultDetectionPlugin {
|
|
7
|
+
name = 'atp-default-detector';
|
|
8
|
+
version = '1.0.0';
|
|
9
|
+
priority = 100;
|
|
10
|
+
patterns = [
|
|
11
|
+
'for-of-await',
|
|
12
|
+
'while-await',
|
|
13
|
+
'map-async',
|
|
14
|
+
'forEach-async',
|
|
15
|
+
'filter-async',
|
|
16
|
+
'reduce-async',
|
|
17
|
+
'find-async',
|
|
18
|
+
'some-async',
|
|
19
|
+
'every-async',
|
|
20
|
+
'flatMap-async',
|
|
21
|
+
'promise-all',
|
|
22
|
+
'promise-allSettled',
|
|
23
|
+
];
|
|
24
|
+
detector;
|
|
25
|
+
constructor() {
|
|
26
|
+
this.detector = new AsyncIterationDetector();
|
|
27
|
+
}
|
|
28
|
+
async detect(code, ast) {
|
|
29
|
+
// Use existing detector
|
|
30
|
+
return this.detector.detect(code);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=detection-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detection-plugin.js","sourceRoot":"","sources":["../../../../../src/plugin-system/default-plugins/detection-plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,MAAM,OAAO,sBAAsB;IAClC,IAAI,GAAG,sBAAsB,CAAC;IAC9B,OAAO,GAAG,OAAO,CAAC;IAClB,QAAQ,GAAG,GAAG,CAAC;IACf,QAAQ,GAAmB;QAC1B,cAAc;QACd,aAAa;QACb,WAAW;QACX,eAAe;QACf,cAAc;QACd,cAAc;QACd,YAAY;QACZ,YAAY;QACZ,aAAa;QACb,eAAe;QACf,aAAa;QACb,oBAAoB;KACpB,CAAC;IAEM,QAAQ,CAAyB;IAEzC;QACC,IAAI,CAAC,QAAQ,GAAG,IAAI,sBAAsB,EAAE,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,GAAW;QACrC,wBAAwB;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Plugins
|
|
3
|
+
*
|
|
4
|
+
* These plugins wrap the existing ATP Compiler functionality,
|
|
5
|
+
* making the PluggableCompiler a drop-in replacement for ATPCompiler.
|
|
6
|
+
*/
|
|
7
|
+
export * from './detection-plugin.js';
|
|
8
|
+
export * from './loop-transformer-plugin.js';
|
|
9
|
+
export * from './array-transformer-plugin.js';
|
|
10
|
+
export * from './promise-transformer-plugin.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-system/default-plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Plugins
|
|
3
|
+
*
|
|
4
|
+
* These plugins wrap the existing ATP Compiler functionality,
|
|
5
|
+
* making the PluggableCompiler a drop-in replacement for ATPCompiler.
|
|
6
|
+
*/
|
|
7
|
+
export * from './detection-plugin.js';
|
|
8
|
+
export * from './loop-transformer-plugin.js';
|
|
9
|
+
export * from './array-transformer-plugin.js';
|
|
10
|
+
export * from './promise-transformer-plugin.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/plugin-system/default-plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Loop Transformer Plugin
|
|
3
|
+
* Wraps the existing LoopTransformer
|
|
4
|
+
*/
|
|
5
|
+
import type { TransformationPlugin, BabelVisitor } from '../plugin-api.js';
|
|
6
|
+
import type { CompilerConfig, TransformMetadata } from '../../types.js';
|
|
7
|
+
export declare class DefaultLoopTransformerPlugin implements TransformationPlugin {
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
priority: number;
|
|
11
|
+
private transformer;
|
|
12
|
+
constructor(batchSizeThreshold?: number);
|
|
13
|
+
getVisitor(config: CompilerConfig): BabelVisitor;
|
|
14
|
+
getMetadata(): Partial<TransformMetadata>;
|
|
15
|
+
reset(): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=loop-transformer-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-transformer-plugin.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-system/default-plugins/loop-transformer-plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,qBAAa,4BAA6B,YAAW,oBAAoB;IACxE,IAAI,SAA0B;IAC9B,OAAO,SAAW;IAClB,QAAQ,SAAO;IAEf,OAAO,CAAC,WAAW,CAAkB;gBAEzB,kBAAkB,CAAC,EAAE,MAAM;IAIvC,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,YAAY;IAgBhD,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAMzC,KAAK,IAAI,IAAI;CAGb"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Loop Transformer Plugin
|
|
3
|
+
* Wraps the existing LoopTransformer
|
|
4
|
+
*/
|
|
5
|
+
import { LoopTransformer } from '../../transformer/loop-transformer.js';
|
|
6
|
+
export class DefaultLoopTransformerPlugin {
|
|
7
|
+
name = 'atp-loop-transformer';
|
|
8
|
+
version = '1.0.0';
|
|
9
|
+
priority = 100;
|
|
10
|
+
transformer;
|
|
11
|
+
constructor(batchSizeThreshold) {
|
|
12
|
+
this.transformer = new LoopTransformer(batchSizeThreshold);
|
|
13
|
+
}
|
|
14
|
+
getVisitor(config) {
|
|
15
|
+
return {
|
|
16
|
+
ForOfStatement: (path) => {
|
|
17
|
+
this.transformer.transformForOfLoop(path);
|
|
18
|
+
},
|
|
19
|
+
WhileStatement: (path) => {
|
|
20
|
+
this.transformer.transformWhileLoop(path);
|
|
21
|
+
},
|
|
22
|
+
ForStatement: (path) => {
|
|
23
|
+
this.transformer.transformForLoop(path);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
getMetadata() {
|
|
28
|
+
return {
|
|
29
|
+
loopCount: this.transformer.getTransformCount(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
reset() {
|
|
33
|
+
this.transformer.resetTransformCount();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=loop-transformer-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-transformer-plugin.js","sourceRoot":"","sources":["../../../../../src/plugin-system/default-plugins/loop-transformer-plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,MAAM,OAAO,4BAA4B;IACxC,IAAI,GAAG,sBAAsB,CAAC;IAC9B,OAAO,GAAG,OAAO,CAAC;IAClB,QAAQ,GAAG,GAAG,CAAC;IAEP,WAAW,CAAkB;IAErC,YAAY,kBAA2B;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,eAAe,CAAC,kBAAkB,CAAC,CAAC;IAC5D,CAAC;IAED,UAAU,CAAC,MAAsB;QAChC,OAAO;YACN,cAAc,EAAE,CAAC,IAAS,EAAE,EAAE;gBAC7B,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAC3C,CAAC;YAED,cAAc,EAAE,CAAC,IAAS,EAAE,EAAE;gBAC7B,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAC3C,CAAC;YAED,YAAY,EAAE,CAAC,IAAS,EAAE,EAAE;gBAC3B,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;YACzC,CAAC;SACD,CAAC;IACH,CAAC;IAED,WAAW;QACV,OAAO;YACN,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE;SAC/C,CAAC;IACH,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC;IACxC,CAAC;CACD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Promise Transformer Plugin
|
|
3
|
+
* Wraps the existing PromiseTransformer
|
|
4
|
+
*/
|
|
5
|
+
import type { TransformationPlugin, BabelVisitor } from '../plugin-api.js';
|
|
6
|
+
import type { CompilerConfig, TransformMetadata } from '../../types.js';
|
|
7
|
+
export declare class DefaultPromiseTransformerPlugin implements TransformationPlugin {
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
priority: number;
|
|
11
|
+
private transformer;
|
|
12
|
+
constructor(enableBatchParallel?: boolean);
|
|
13
|
+
getVisitor(config: CompilerConfig): BabelVisitor;
|
|
14
|
+
getMetadata(): Partial<TransformMetadata>;
|
|
15
|
+
reset(): void;
|
|
16
|
+
private isPromiseAllCall;
|
|
17
|
+
private isPromiseAllSettledCall;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=promise-transformer-plugin.d.ts.map
|
package/dist/atp-compiler/src/plugin-system/default-plugins/promise-transformer-plugin.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-transformer-plugin.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-system/default-plugins/promise-transformer-plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,qBAAa,+BAAgC,YAAW,oBAAoB;IAC3E,IAAI,SAA6B;IACjC,OAAO,SAAW;IAClB,QAAQ,SAAO;IAEf,OAAO,CAAC,WAAW,CAAqB;gBAE5B,mBAAmB,CAAC,EAAE,OAAO;IAIzC,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,YAAY;IAahD,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAMzC,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,uBAAuB;CAQ/B"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Promise Transformer Plugin
|
|
3
|
+
* Wraps the existing PromiseTransformer
|
|
4
|
+
*/
|
|
5
|
+
import * as t from '@babel/types';
|
|
6
|
+
import { PromiseTransformer } from '../../transformer/promise-transformer.js';
|
|
7
|
+
export class DefaultPromiseTransformerPlugin {
|
|
8
|
+
name = 'atp-promise-transformer';
|
|
9
|
+
version = '1.0.0';
|
|
10
|
+
priority = 100;
|
|
11
|
+
transformer;
|
|
12
|
+
constructor(enableBatchParallel) {
|
|
13
|
+
this.transformer = new PromiseTransformer(enableBatchParallel);
|
|
14
|
+
}
|
|
15
|
+
getVisitor(config) {
|
|
16
|
+
return {
|
|
17
|
+
CallExpression: (path) => {
|
|
18
|
+
const node = path.node;
|
|
19
|
+
if (this.isPromiseAllCall(node)) {
|
|
20
|
+
this.transformer.transformPromiseAll(path);
|
|
21
|
+
}
|
|
22
|
+
else if (this.isPromiseAllSettledCall(node)) {
|
|
23
|
+
this.transformer.transformPromiseAllSettled(path);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
getMetadata() {
|
|
29
|
+
return {
|
|
30
|
+
parallelCallCount: this.transformer.getTransformCount(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
reset() {
|
|
34
|
+
this.transformer.resetTransformCount();
|
|
35
|
+
}
|
|
36
|
+
isPromiseAllCall(node) {
|
|
37
|
+
const callee = node.callee;
|
|
38
|
+
return (t.isMemberExpression(callee) &&
|
|
39
|
+
t.isIdentifier(callee.object, { name: 'Promise' }) &&
|
|
40
|
+
t.isIdentifier(callee.property, { name: 'all' }));
|
|
41
|
+
}
|
|
42
|
+
isPromiseAllSettledCall(node) {
|
|
43
|
+
const callee = node.callee;
|
|
44
|
+
return (t.isMemberExpression(callee) &&
|
|
45
|
+
t.isIdentifier(callee.object, { name: 'Promise' }) &&
|
|
46
|
+
t.isIdentifier(callee.property, { name: 'allSettled' }));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=promise-transformer-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-transformer-plugin.js","sourceRoot":"","sources":["../../../../../src/plugin-system/default-plugins/promise-transformer-plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAE9E,MAAM,OAAO,+BAA+B;IAC3C,IAAI,GAAG,yBAAyB,CAAC;IACjC,OAAO,GAAG,OAAO,CAAC;IAClB,QAAQ,GAAG,GAAG,CAAC;IAEP,WAAW,CAAqB;IAExC,YAAY,mBAA6B;QACxC,IAAI,CAAC,WAAW,GAAG,IAAI,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IAChE,CAAC;IAED,UAAU,CAAC,MAAsB;QAChC,OAAO;YACN,cAAc,EAAE,CAAC,IAAS,EAAE,EAAE;gBAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;gBACvB,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;oBACjC,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;gBAC5C,CAAC;qBAAM,IAAI,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC/C,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAC;gBACnD,CAAC;YACF,CAAC;SACD,CAAC;IACH,CAAC;IAED,WAAW;QACV,OAAO;YACN,iBAAiB,EAAE,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE;SACvD,CAAC;IACH,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC;IACxC,CAAC;IAEO,gBAAgB,CAAC,IAAsB;QAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,OAAO,CACN,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC;YAC5B,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;YAClD,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAChD,CAAC;IACH,CAAC;IAEO,uBAAuB,CAAC,IAAsB;QACrD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,OAAO,CACN,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC;YAC5B,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;YAClD,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CACvD,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: Loop Transformer as a Plugin
|
|
3
|
+
*
|
|
4
|
+
* Shows how to migrate existing LoopTransformer to plugin architecture
|
|
5
|
+
* This demonstrates the migration path for built-in transformers
|
|
6
|
+
*/
|
|
7
|
+
import type { TransformationPlugin, BabelVisitor } from '../plugin-api.js';
|
|
8
|
+
import type { CompilerConfig, TransformMetadata } from '../../types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Loop Transformer Plugin
|
|
11
|
+
*
|
|
12
|
+
* Transforms for...of, while, and for loops into resumable versions
|
|
13
|
+
* with checkpoint-based state management
|
|
14
|
+
*/
|
|
15
|
+
export declare class LoopTransformerPlugin implements TransformationPlugin {
|
|
16
|
+
name: string;
|
|
17
|
+
version: string;
|
|
18
|
+
priority: number;
|
|
19
|
+
private transformer;
|
|
20
|
+
constructor(batchSizeThreshold?: number);
|
|
21
|
+
initialize(config: CompilerConfig): void;
|
|
22
|
+
getVisitor(config: CompilerConfig): BabelVisitor;
|
|
23
|
+
getMetadata(): Partial<TransformMetadata>;
|
|
24
|
+
reset(): void;
|
|
25
|
+
dispose(): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Factory function for easy creation
|
|
29
|
+
*/
|
|
30
|
+
export declare function createLoopTransformerPlugin(batchSizeThreshold?: number): LoopTransformerPlugin;
|
|
31
|
+
//# sourceMappingURL=loop-transformer-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-transformer-plugin.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-system/examples/loop-transformer-plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxE;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,oBAAoB;IACjE,IAAI,SAAsB;IAC1B,OAAO,SAAW;IAClB,QAAQ,SAAM;IAEd,OAAO,CAAC,WAAW,CAAkB;gBAEzB,kBAAkB,GAAE,MAAW;IAI3C,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAKxC,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,YAAY;IAgBhD,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;IASzC,KAAK,IAAI,IAAI;IAIb,OAAO,IAAI,IAAI;CAGf;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAE9F"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: Loop Transformer as a Plugin
|
|
3
|
+
*
|
|
4
|
+
* Shows how to migrate existing LoopTransformer to plugin architecture
|
|
5
|
+
* This demonstrates the migration path for built-in transformers
|
|
6
|
+
*/
|
|
7
|
+
import { LoopTransformer } from '../../transformer/loop-transformer.js';
|
|
8
|
+
/**
|
|
9
|
+
* Loop Transformer Plugin
|
|
10
|
+
*
|
|
11
|
+
* Transforms for...of, while, and for loops into resumable versions
|
|
12
|
+
* with checkpoint-based state management
|
|
13
|
+
*/
|
|
14
|
+
export class LoopTransformerPlugin {
|
|
15
|
+
name = 'loop-transformer';
|
|
16
|
+
version = '1.0.0';
|
|
17
|
+
priority = 50; // Standard priority for core transformations
|
|
18
|
+
transformer;
|
|
19
|
+
constructor(batchSizeThreshold = 10) {
|
|
20
|
+
this.transformer = new LoopTransformer(batchSizeThreshold);
|
|
21
|
+
}
|
|
22
|
+
initialize(config) {
|
|
23
|
+
// Initialize with config if needed
|
|
24
|
+
console.log('[LoopTransformerPlugin] Initialized');
|
|
25
|
+
}
|
|
26
|
+
getVisitor(config) {
|
|
27
|
+
return {
|
|
28
|
+
ForOfStatement: (path) => {
|
|
29
|
+
this.transformer.transformForOfLoop(path);
|
|
30
|
+
},
|
|
31
|
+
WhileStatement: (path) => {
|
|
32
|
+
this.transformer.transformWhileLoop(path);
|
|
33
|
+
},
|
|
34
|
+
ForStatement: (path) => {
|
|
35
|
+
this.transformer.transformForLoop(path);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
getMetadata() {
|
|
40
|
+
return {
|
|
41
|
+
loopCount: this.transformer.getTransformCount(),
|
|
42
|
+
arrayMethodCount: 0,
|
|
43
|
+
parallelCallCount: 0,
|
|
44
|
+
batchableCount: 0,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
reset() {
|
|
48
|
+
this.transformer.resetTransformCount();
|
|
49
|
+
}
|
|
50
|
+
dispose() {
|
|
51
|
+
console.log('[LoopTransformerPlugin] Disposed');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Factory function for easy creation
|
|
56
|
+
*/
|
|
57
|
+
export function createLoopTransformerPlugin(batchSizeThreshold) {
|
|
58
|
+
return new LoopTransformerPlugin(batchSizeThreshold);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=loop-transformer-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-transformer-plugin.js","sourceRoot":"","sources":["../../../../../src/plugin-system/examples/loop-transformer-plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IACjC,IAAI,GAAG,kBAAkB,CAAC;IAC1B,OAAO,GAAG,OAAO,CAAC;IAClB,QAAQ,GAAG,EAAE,CAAC,CAAC,6CAA6C;IAEpD,WAAW,CAAkB;IAErC,YAAY,qBAA6B,EAAE;QAC1C,IAAI,CAAC,WAAW,GAAG,IAAI,eAAe,CAAC,kBAAkB,CAAC,CAAC;IAC5D,CAAC;IAED,UAAU,CAAC,MAAsB;QAChC,mCAAmC;QACnC,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;IACpD,CAAC;IAED,UAAU,CAAC,MAAsB;QAChC,OAAO;YACN,cAAc,EAAE,CAAC,IAAgC,EAAE,EAAE;gBACpD,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAW,CAAC,CAAC;YAClD,CAAC;YAED,cAAc,EAAE,CAAC,IAAgC,EAAE,EAAE;gBACpD,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAW,CAAC,CAAC;YAClD,CAAC;YAED,YAAY,EAAE,CAAC,IAA8B,EAAE,EAAE;gBAChD,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAW,CAAC,CAAC;YAChD,CAAC;SACD,CAAC;IACH,CAAC;IAED,WAAW;QACV,OAAO;YACN,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,iBAAiB,EAAE;YAC/C,gBAAgB,EAAE,CAAC;YACnB,iBAAiB,EAAE,CAAC;YACpB,cAAc,EAAE,CAAC;SACjB,CAAC;IACH,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC;IACxC,CAAC;IAED,OAAO;QACN,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IACjD,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAAC,kBAA2B;IACtE,OAAO,IAAI,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example Plugin: Security Validator
|
|
3
|
+
*
|
|
4
|
+
* Validates code for security issues before transformation
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const compiler = new PluggableCompiler();
|
|
8
|
+
* compiler.use(new SecurityValidatorPlugin({
|
|
9
|
+
* forbiddenPatterns: [/eval\s*\(/],
|
|
10
|
+
* maxComplexity: 20
|
|
11
|
+
* }));
|
|
12
|
+
*/
|
|
13
|
+
import type * as t from '@babel/types';
|
|
14
|
+
import type { ValidatorPlugin } from '../plugin-api.js';
|
|
15
|
+
export interface SecurityValidatorOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Forbidden patterns (regex)
|
|
18
|
+
*/
|
|
19
|
+
forbiddenPatterns?: RegExp[];
|
|
20
|
+
/**
|
|
21
|
+
* Maximum cyclomatic complexity
|
|
22
|
+
*/
|
|
23
|
+
maxComplexity?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Maximum nesting depth
|
|
26
|
+
*/
|
|
27
|
+
maxNesting?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Forbidden global access
|
|
30
|
+
*/
|
|
31
|
+
forbiddenGlobals?: string[];
|
|
32
|
+
}
|
|
33
|
+
export declare class SecurityValidatorPlugin implements ValidatorPlugin {
|
|
34
|
+
name: string;
|
|
35
|
+
version: string;
|
|
36
|
+
priority: number;
|
|
37
|
+
private options;
|
|
38
|
+
constructor(options?: SecurityValidatorOptions);
|
|
39
|
+
validate(code: string, ast: t.File, phase: 'pre' | 'post'): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Security validation error
|
|
43
|
+
*/
|
|
44
|
+
export declare class SecurityValidationError extends Error {
|
|
45
|
+
code: string;
|
|
46
|
+
constructor(message: string, code: string);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=security-validator-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-validator-plugin.d.ts","sourceRoot":"","sources":["../../../../../src/plugin-system/examples/security-validator-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAC;AAGvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGxD,MAAM,WAAW,wBAAwB;IACxC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE7B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,qBAAa,uBAAwB,YAAW,eAAe;IAC9D,IAAI,SAAwB;IAC5B,OAAO,SAAW;IAClB,QAAQ,SAAO;IAEf,OAAO,CAAC,OAAO,CAA2B;gBAE9B,OAAO,GAAE,wBAA6B;IAkB5C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAkE/E;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAGzC,IAAI,EAAE,MAAM;gBADnB,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM;CAKpB"}
|