rbx-transformer-alpha 1.0.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/README.md ADDED
@@ -0,0 +1 @@
1
+ not thing there now.
package/out/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const transformer_1 = require("./transformer");
5
+ /**
6
+ * The transformer entry point.
7
+ * This provides access to necessary resources and the user specified configuration.
8
+ */
9
+ function default_1(program, config) {
10
+ return (transformationContext) => {
11
+ const context = new transformer_1.TransformContext(program, transformationContext, config);
12
+ return (file) => context.transform(file);
13
+ };
14
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TransformContext = void 0;
7
+ const typescript_1 = __importDefault(require("typescript"));
8
+ /**
9
+ * This is a utility object to pass around your dependencies.
10
+ *
11
+ * You can also use this object to store state, e.g prereqs.
12
+ */
13
+ class TransformContext {
14
+ constructor(program, context, config) {
15
+ this.program = program;
16
+ this.context = context;
17
+ this.config = config;
18
+ this.factory = context.factory;
19
+ }
20
+ /**
21
+ * Transforms the children of the specified node.
22
+ */
23
+ transform(node) {
24
+ return typescript_1.default.visitEachChild(node, (node) => visitNode(this, node), this.context);
25
+ }
26
+ }
27
+ exports.TransformContext = TransformContext;
28
+ function visitImportDeclaration(context, node) {
29
+ return context.transform(node);
30
+ }
31
+ function visitStatement(context, node) {
32
+ // This is used to transform statements.
33
+ // TypeScript allows you to return multiple statements here.
34
+ if (typescript_1.default.isImportDeclaration(node)) {
35
+ // We have encountered an import declaration,
36
+ // so we should transform it using a separate function.
37
+ return visitImportDeclaration(context, node);
38
+ }
39
+ return context.transform(node);
40
+ }
41
+ function visitExpression(context, node) {
42
+ return context.transform(node);
43
+ }
44
+ function visitCallExpression(context, node) {
45
+ var _a;
46
+ const { factory } = context;
47
+ const typeChecker = context.program.getTypeChecker();
48
+ const expr = node.expression;
49
+ if (expr.kind === typescript_1.default.SyntaxKind.Identifier && expr.text === "createNetworkEvents") {
50
+ const typeArg = (_a = node.typeArguments) === null || _a === void 0 ? void 0 : _a[1];
51
+ if (typeArg) {
52
+ const type = typeChecker.getTypeFromTypeNode(typeArg);
53
+ const properties = type.getProperties();
54
+ const stringArgs = properties.map((prop) => factory.createStringLiteral(prop.getName()));
55
+ const arrayLiteral = factory.createArrayLiteralExpression(stringArgs);
56
+ return factory.updateCallExpression(node, node.expression, node.typeArguments, [
57
+ ...node.arguments,
58
+ arrayLiteral,
59
+ ]);
60
+ }
61
+ }
62
+ return context.transform(node);
63
+ }
64
+ function visitNode(context, node) {
65
+ if (typescript_1.default.isStatement(node)) {
66
+ return visitStatement(context, node);
67
+ }
68
+ else if (typescript_1.default.isExpression(node)) {
69
+ return visitExpression(context, node);
70
+ }
71
+ else if (typescript_1.default.isCallExpression(node)) {
72
+ return visitCallExpression(context, node);
73
+ }
74
+ // We encountered a node that we don't handle above,
75
+ // but we should keep iterating the AST in case we find something we want to transform.
76
+ return context.transform(node);
77
+ }
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "rbx-transformer-alpha",
3
+ "version": "1.0.0",
4
+ "author": "Konma",
5
+ "license": "MIT",
6
+ "description": "",
7
+ "keywords": [],
8
+ "repository": {
9
+ "url": "https://github.com/Konmaa/rbx-transformer-alpha.git"
10
+ },
11
+
12
+ "main": "out/index.js",
13
+ "scripts": {
14
+ "build": "tsc",
15
+ "watch": "tsc -w"
16
+ },
17
+ "peerDependencies": {
18
+ "typescript": "^5.9.3"
19
+ },
20
+ "files": [
21
+ "out"
22
+ ]
23
+ }