@bikky/compiler 0.1.17 → 0.2.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.
Files changed (49) hide show
  1. package/.idea/Compiler.iml +1 -0
  2. package/.idea/scopes/All_Typescript_Files.xml +3 -0
  3. package/Execution/generate.mjs +17 -1
  4. package/Execution/generate.mjs.map +1 -1
  5. package/Execution/generate.mts +33 -3
  6. package/Libraries/BiscuitLibraries.d.mts +2 -0
  7. package/Libraries/BiscuitLibraries.d.mts.map +1 -1
  8. package/Libraries/BiscuitLibraries.mjs +4 -0
  9. package/Libraries/BiscuitLibraries.mjs.map +1 -1
  10. package/Libraries/BiscuitLibraries.mts +5 -1
  11. package/Libraries/ClassMigration.d.mts +88 -0
  12. package/Libraries/ClassMigration.d.mts.map +1 -0
  13. package/Libraries/ClassMigration.mjs +368 -0
  14. package/Libraries/ClassMigration.mjs.map +1 -0
  15. package/Libraries/ClassMigration.mts +431 -0
  16. package/Libraries/RBF.d.mts +4 -0
  17. package/Libraries/RBF.d.mts.map +1 -0
  18. package/Libraries/RBF.mjs +36 -0
  19. package/Libraries/RBF.mjs.map +1 -0
  20. package/Libraries/RBF.mts +46 -0
  21. package/Libraries/RBFTypes.d.ts +43 -0
  22. package/Source/ASTInterface/Crawler.d.ts +2 -1
  23. package/Source/ASTInterface/Crawler.d.ts.map +1 -1
  24. package/Source/ASTInterface/Crawler.js +14 -2
  25. package/Transformers/Main.d.ts +1 -1
  26. package/Transformers/Main.d.ts.map +1 -1
  27. package/Transformers/Main.js +3 -2
  28. package/Transformers/RBFHelpers/Constants.d.ts +3 -0
  29. package/Transformers/RBFHelpers/Constants.d.ts.map +1 -0
  30. package/Transformers/RBFHelpers/Constants.js +7 -0
  31. package/Transformers/RBFHelpers/Imports.d.ts +12 -0
  32. package/Transformers/RBFHelpers/Imports.d.ts.map +1 -0
  33. package/Transformers/RBFHelpers/Imports.js +212 -0
  34. package/Transformers/RBFHelpers/Print.d.ts +1 -0
  35. package/Transformers/RBFHelpers/Print.d.ts.map +1 -0
  36. package/Transformers/RBFHelpers/Print.js +2 -0
  37. package/Transformers/RBFHelpers/PropertyConfig.d.ts +65 -0
  38. package/Transformers/RBFHelpers/PropertyConfig.d.ts.map +1 -0
  39. package/Transformers/RBFHelpers/PropertyConfig.js +420 -0
  40. package/Transformers/RBFTransformer.d.ts +2 -0
  41. package/Transformers/RBFTransformer.d.ts.map +1 -0
  42. package/Transformers/RBFTransformer.js +317 -0
  43. package/package.json +1 -1
  44. package/tsconfig.build.libs.tsbuildinfo +1 -1
  45. package/tsconfig.build.src.tsbuildinfo +1 -1
  46. package/tsconfig.tsbuildinfo +1 -1
  47. package/Transformers/ReplicableTransformer.d.ts +0 -2
  48. package/Transformers/ReplicableTransformer.d.ts.map +0 -1
  49. package/Transformers/ReplicableTransformer.js +0 -786
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("./DelayTransformer.js");
4
4
  require("./MixinTransformer.js");
5
- require("./ReplicableTransformer.js");
5
+ require("./RBFTransformer.js");
6
6
  const Crawler_js_1 = require("../Source/ASTInterface/Crawler.js");
7
7
  function default_1(program, pluginOptions) {
8
8
  Crawler_js_1.Crawler.SetProgram(program);
@@ -10,7 +10,8 @@ function default_1(program, pluginOptions) {
10
10
  Crawler_js_1.Crawler.setContext(context);
11
11
  return (sourceFile) => {
12
12
  Crawler_js_1.Crawler.SetFile(sourceFile);
13
- return Crawler_js_1.Crawler.Crawl(sourceFile);
13
+ let result = Crawler_js_1.Crawler.Crawl(sourceFile);
14
+ return result;
14
15
  };
15
16
  };
16
17
  }
@@ -0,0 +1,3 @@
1
+ export declare const rbfExt = ".rbf.js";
2
+ export declare const defExt = ".data.d.ts";
3
+ //# sourceMappingURL=Constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["Constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,YAAY,CAAC;AAChC,eAAO,MAAM,MAAM,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defExt = exports.rbfExt = void 0;
4
+ //RBF = Replication Breakdown File.
5
+ exports.rbfExt = ".rbf.js";
6
+ exports.defExt = ".data.d.ts";
7
+ //# sourceMappingURL=Constants.js.map
@@ -0,0 +1,12 @@
1
+ import * as ts from "../../Cache/typescript.js";
2
+ export declare namespace Imports {
3
+ function getRBFImports(): string;
4
+ function getDefImports(): string;
5
+ function resolveAliases(name: string): string;
6
+ function requestValueImport(value: string | ts.Identifier | ts.QualifiedName | ts.PropertyAccessExpression, locations: ("RBF" | "Data")[]): boolean;
7
+ /**
8
+ * Imports a class or the appropriate class's declaration.
9
+ */
10
+ function requestClassImport(value: string | ts.Identifier | ts.QualifiedName, postfixes: string[]): boolean;
11
+ }
12
+ //# sourceMappingURL=Imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Imports.d.ts","sourceRoot":"","sources":["Imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAMhD,yBAAc,OAAO,CAAC;IAQrB,SAAgB,aAAa,WAO5B;IAED,SAAgB,aAAa,WAM5B;IAUD,SAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKnD;IA4BD,SAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,aAAa,GAAG,EAAE,CAAC,wBAAwB,EAAE,SAAS,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC;IAkC3J;;OAEG;IACH,SAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;CA0GnH"}
@@ -0,0 +1,212 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Imports = void 0;
4
+ const ts = require("../../Cache/typescript.js");
5
+ const Crawler_js_1 = require("../../Source/ASTInterface/Crawler.js");
6
+ const ASTHelper_js_1 = require("../../Source/ASTHelper.js");
7
+ const Constants_js_1 = require("./Constants.js");
8
+ var Imports;
9
+ (function (Imports) {
10
+ let allFileImports = new Map();
11
+ let currentFileAliases = new Map();
12
+ let rbfImports = new Map();
13
+ let rbfAliases = [];
14
+ let defImports = new Map();
15
+ let defAliases = [];
16
+ function getRBFImports() {
17
+ return Array.from(rbfImports.entries()).map(([key, value]) => {
18
+ value = Array.from(new Set(value));
19
+ return `import { ${value.join(", ")} } from "${key}";`;
20
+ }).join("\n") + "\n"
21
+ + `import { RegisterClassRBF } from "@bikky/compiler";\n`
22
+ + rbfAliases.join("\n");
23
+ }
24
+ Imports.getRBFImports = getRBFImports;
25
+ function getDefImports() {
26
+ return Array.from(defImports.entries()).map(([key, value]) => {
27
+ value = Array.from(new Set(value));
28
+ return `import { ${value.join(", ")} } from "${key}";`;
29
+ }).join("\n") + "\n"
30
+ + defAliases.join("\n");
31
+ }
32
+ Imports.getDefImports = getDefImports;
33
+ function replaceExtension(path, ext) {
34
+ let result = path.replace(/\.js$/, ext);
35
+ if (result === path) {
36
+ result = path + ext;
37
+ }
38
+ return result;
39
+ }
40
+ function resolveAliases(name) {
41
+ while (currentFileAliases.has(name)) {
42
+ name = currentFileAliases.get(name);
43
+ }
44
+ return name;
45
+ }
46
+ Imports.resolveAliases = resolveAliases;
47
+ function getQualifierBase(name) {
48
+ if (typeof name === "string") {
49
+ return name;
50
+ }
51
+ while (ts.isPropertyAccessExpression(name)) {
52
+ let expr = name.expression;
53
+ if (ts.isIdentifier(expr)) {
54
+ name = expr;
55
+ break;
56
+ }
57
+ if (!ts.isIdentifier(expr) && !ts.isPropertyAccessExpression(expr)) {
58
+ (0, ASTHelper_js_1.logError)(name, `Left-most value of property is not an identifier, abandoning attempt to import.`);
59
+ return null;
60
+ }
61
+ name = expr;
62
+ }
63
+ while (ts.isQualifiedName(name)) {
64
+ name = name.left;
65
+ if (!ts.isIdentifier(name) && !ts.isQualifiedName(name)) {
66
+ (0, ASTHelper_js_1.logError)(name, `Left-most value in a reference type is not an identifier, abandoning attempt to import.`);
67
+ return null;
68
+ }
69
+ }
70
+ return name.text;
71
+ }
72
+ function requestValueImport(value, locations) {
73
+ var _a, _b;
74
+ value = getQualifierBase(value);
75
+ if (value === null) {
76
+ //Don't import items that aren't identifiers.
77
+ return false;
78
+ }
79
+ let sourceAlias = resolveAliases(value);
80
+ let impo = allFileImports.get(sourceAlias);
81
+ if (!impo) {
82
+ return false;
83
+ }
84
+ if (locations.length === 0) {
85
+ return false;
86
+ }
87
+ if (locations.includes("RBF")) {
88
+ let arr = (_a = rbfImports.get(impo)) !== null && _a !== void 0 ? _a : [];
89
+ rbfImports.set(impo, arr);
90
+ arr.push(value);
91
+ if (sourceAlias != value) {
92
+ rbfAliases.push(`import ${value} = ${sourceAlias};`);
93
+ }
94
+ }
95
+ if (locations.includes("Data")) {
96
+ let arr = (_b = defImports.get(impo)) !== null && _b !== void 0 ? _b : [];
97
+ defImports.set(impo, arr);
98
+ arr.push(value);
99
+ if (sourceAlias != value) {
100
+ defAliases.push(`import ${value} = ${sourceAlias};`);
101
+ }
102
+ }
103
+ return true;
104
+ }
105
+ Imports.requestValueImport = requestValueImport;
106
+ function requestClassImport(value, postfixes) {
107
+ var _a, _b, _c;
108
+ value = getQualifierBase(value);
109
+ if (value === null) {
110
+ //Don't import items that aren't identifiers.
111
+ return false;
112
+ }
113
+ let sourceAlias = resolveAliases(value);
114
+ let impo = allFileImports.get(sourceAlias);
115
+ if (!impo) {
116
+ return false;
117
+ }
118
+ // Handle the RBF additions.
119
+ if (postfixes.includes("RBF")) {
120
+ let rbf = replaceExtension(impo, Constants_js_1.rbfExt);
121
+ let arr = (_a = rbfImports.get(rbf)) !== null && _a !== void 0 ? _a : [];
122
+ rbfImports.set(rbf, arr);
123
+ for (let postfix of postfixes) {
124
+ if (postfix !== "RBF")
125
+ continue;
126
+ arr.push(value + postfix);
127
+ if (sourceAlias != value) {
128
+ rbfAliases.push(`import ${value}${postfix} = ${sourceAlias}${postfix};`);
129
+ }
130
+ }
131
+ if (postfixes.length === 1) {
132
+ return true;
133
+ }
134
+ }
135
+ if (postfixes.includes("")) {
136
+ let arr = (_b = defImports.get(impo)) !== null && _b !== void 0 ? _b : [];
137
+ defImports.set(impo, arr);
138
+ arr.push(value);
139
+ if (sourceAlias != value) {
140
+ defAliases.push(`import ${value} = ${sourceAlias};`);
141
+ }
142
+ }
143
+ //Handle the Data file additions.
144
+ let def = replaceExtension(impo, Constants_js_1.defExt);
145
+ let arr = (_c = defImports.get(def)) !== null && _c !== void 0 ? _c : [];
146
+ defImports.set(def, arr);
147
+ for (let postfix of postfixes) {
148
+ if (postfix === "RBF" || postfix === "") {
149
+ continue;
150
+ }
151
+ arr.push(value + postfix);
152
+ if (sourceAlias != value) {
153
+ defAliases.push(`import ${value}${postfix} = ${sourceAlias}${postfix};`);
154
+ }
155
+ }
156
+ return true;
157
+ }
158
+ Imports.requestClassImport = requestClassImport;
159
+ function resetImports() {
160
+ allFileImports.clear();
161
+ currentFileAliases.clear();
162
+ rbfImports.clear();
163
+ defImports.clear();
164
+ rbfAliases = [];
165
+ defAliases = [];
166
+ }
167
+ Crawler_js_1.Crawler.OnFile((node) => {
168
+ resetImports();
169
+ });
170
+ /**
171
+ * For any import statement in the .ts file, we record it so that we can create an equivalent
172
+ * import in a .d.ts or .rbf.js file later.
173
+ */
174
+ Crawler_js_1.Crawler.Register((node) => {
175
+ return !!(ts.isImportDeclaration(node) && node.importClause);
176
+ }, (node) => {
177
+ let declaration = node;
178
+ let localPath = declaration.moduleSpecifier.getText().slice(1, -1);
179
+ // let rbfpath = joinPaths(getPathDir(node.getSourceFile().fileName), localPath)
180
+ // .replace(/\.ts$/, rbfExt);
181
+ let rbfpath = localPath.replace(/\.js$/, Constants_js_1.rbfExt);
182
+ // let defpath = localPath.replace(/\.js$/, defExt);
183
+ let clause = declaration.importClause;
184
+ if (clause.name) {
185
+ // import name from "module"
186
+ allFileImports.set(clause.name.getText() + "RBF", rbfpath);
187
+ allFileImports.set(clause.name.getText(), localPath);
188
+ }
189
+ else if (clause.namedBindings) {
190
+ if ("elements" in clause.namedBindings) {
191
+ for (let binding of clause.namedBindings.elements) {
192
+ // import { name as alias } from "module"
193
+ // import { name } from "module"
194
+ if (ts.isImportSpecifier(binding)) {
195
+ if (binding.propertyName) {
196
+ currentFileAliases.set(binding.propertyName.getText(), binding.name.getText());
197
+ }
198
+ allFileImports.set(binding.name.getText() + "RBF", rbfpath);
199
+ allFileImports.set(binding.name.getText(), localPath);
200
+ }
201
+ }
202
+ }
203
+ else {
204
+ // import * as name from "module"
205
+ allFileImports.set(clause.namedBindings.name.getText() + "RBF", rbfpath);
206
+ allFileImports.set(clause.namedBindings.name.getText(), localPath);
207
+ }
208
+ }
209
+ return node;
210
+ });
211
+ })(Imports || (exports.Imports = Imports = {}));
212
+ //# sourceMappingURL=Imports.js.map
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=Print.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Print.d.ts","sourceRoot":"","sources":["Print.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=Print.js.map
@@ -0,0 +1,65 @@
1
+ import * as ts from "../../Cache/typescript.js";
2
+ import { RBFTypes } from "../../Libraries/RBFTypes.js";
3
+ export declare namespace PropertyConfig {
4
+ const primitiveReaders: {
5
+ String: {
6
+ tryReadLiteral: (node: ts.Node) => string | null;
7
+ };
8
+ Boolean: {
9
+ tryReadLiteral(node: ts.Node): boolean | null;
10
+ };
11
+ Number: {
12
+ tryReadLiteral(node: ts.Node): number | null;
13
+ };
14
+ };
15
+ function extractConfigData(arg: ts.ObjectLiteralExpression, optional: boolean): RBFTypes.PropertyConfiguration;
16
+ }
17
+ export declare namespace MakeRBFTypes {
18
+ /**
19
+ * Reads primitive's data and converts it into usable formats.
20
+ */
21
+ interface PrimitiveReader {
22
+ /**
23
+ * Whether or not multiple entries of this thing should be grouped,
24
+ * for example string and number literals.
25
+ */
26
+ shouldGroup: boolean;
27
+ /**
28
+ * The name on the left-hand side when serialising the type.
29
+ */
30
+ serialisedName: string;
31
+ /**
32
+ * True if the node is one of these, false if not. Alternatively can
33
+ * return an options object which contains
34
+ * @param valid: whether the node is or is not of this type.
35
+ * @param values: if this node has a limited number of possible values.
36
+ * @param containTypes: if this node has specific generic types for it's properties.
37
+ */
38
+ isThisType: (node: ts.TypeNode) => boolean | {
39
+ valid: boolean;
40
+ values?: any[];
41
+ containsTypes?: ts.TypeNode[];
42
+ };
43
+ /**
44
+ * If this node has a custom load format, do that here.
45
+ */
46
+ makeDataNodes?: (node: ts.TypeNode) => ts.TypeNode[];
47
+ /**
48
+ * If this node has a custom serialise format, do that here.
49
+ */
50
+ makeSerialisedNodes?: (node: ts.TypeNode) => ts.TypeNode[];
51
+ tryReadLiteral?: (node: ts.Node) => string | number | boolean | null;
52
+ }
53
+ const primitiveReaders: {
54
+ [typeName: string]: PrimitiveReader;
55
+ };
56
+ function recurseBasicType(child: ts.TypeNode, childrenTypes: {
57
+ [name: string]: {
58
+ values?: (string | number | boolean)[];
59
+ subTypes?: RBFTypes.RecursivePropertyType[];
60
+ };
61
+ }): void;
62
+ function recursivelyConvertType(typeNode: ts.TypeNode): RBFTypes.RecursivePropertyType;
63
+ }
64
+ export declare function convertTypeToDeclarationFormats(postfixes: string[], node: ts.TypeNode): string;
65
+ //# sourceMappingURL=PropertyConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertyConfig.d.ts","sourceRoot":"","sources":["PropertyConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAChD,OAAO,EAAE,QAAQ,EA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